Skip to content

Add VERSION file

Add VERSION file #236

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python application (flake8 linter, pytest)
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout project source code
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
- name: Restore cached virtualenv
uses: actions/cache/restore@v4
with:
key: venv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}
path: .venv
- name: Install dependencies, using cached venv
run: |
# use [cached] virtual environment, see https://adamj.eu/tech/2023/11/02/github-actions-faster-python-virtual-environments/
python -m venv .venv
source .venv/bin/activate
# upgrade pip
python -m pip install --upgrade pip
# install dependencies for next steps
python -m pip install flake8 pytest ruff
# install the package and its dependencies; note: it uses requirements.txt
python -m pip install --editable .[dev]
# add to $VIRTUAL_ENV/bin to $PATH to be able to run scripts
echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH
# add information about active virtual environment to environment variables
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV
- name: Saved cached virtualenv
uses: actions/cache/save@v4
with:
key: venv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}
path: .venv
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 src/ --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 src/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Lint with ruff (non-blocking)
run: |
# --target-version should match requires-python in pyproject.toml
ruff check src/ --target-version=py37 --output-format=github
continue-on-error: true
- name: Test with pytest
run: |
pytest