Skip to content

improve readability, separate build run tasks #285

improve readability, separate build run tasks

improve readability, separate build run tasks #285

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
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest # Which OS this runs on
strategy:
matrix:
python-version: ["3.11.13"] # You can build against multiple Python versions
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} # Name of an action that sets up Python
uses: actions/setup-python@v5 # https://github.com/actions/setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Install and upgrade core tools
run: |
python -m pip install --upgrade pip
python -m pip install pip-tools
- name: Verify lockfile consistency (diagnostic mode)
run: |
echo "Generating requirements.txt from source to check for differences..."
pip-compile --quiet requirements.in -o requirements.txt
echo "Comparing the generated file with the one in the repository:"
# 'git diff' will show any diff's. '|| true' ensures the step doesn't fail.
git diff requirements.txt || true
- name: Install Python dependencies from lockfile
run: |
echo "Installing dependencies from requirements.txt..."
if [ -f requirements.txt ]; then python -m pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
# Final action: runs pytest for all tests in the ./tests dir
pytest ./tests/*.py -vv