|
| 1 | +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions |
| 2 | +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python |
| 3 | + |
| 4 | +name: Python |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: [ "main" ] |
| 9 | + pull_request: |
| 10 | + branches: [ "main", "develop" ] |
| 11 | + |
| 12 | +jobs: |
| 13 | + test: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + python-version: ["3.11", "3.12", "3.13"] |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + - name: Set up Python ${{ matrix.python-version }} |
| 23 | + uses: actions/setup-python@v5 |
| 24 | + with: |
| 25 | + python-version: ${{ matrix.python-version }} |
| 26 | + - name: Install poetry |
| 27 | + run: curl -sSL https://install.python-poetry.org | python3 - |
| 28 | + - name: Configure poetry |
| 29 | + run: poetry config virtualenvs.in-project true |
| 30 | + - name: set PY |
| 31 | + run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV |
| 32 | + - name: Set up poetry cache |
| 33 | + uses: actions/cache@v4 |
| 34 | + with: |
| 35 | + path: .venv |
| 36 | + key: venv-${{ runner.os }}-${{ env.PY }}-${{ hashFiles('**/poetry.lock') }} |
| 37 | + - name: Ensure cache is healthy |
| 38 | + if: steps.cache.outputs.cache-hit == 'true' |
| 39 | + run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv |
| 40 | + - name: Set up pre-commit cache |
| 41 | + uses: actions/cache@v4 |
| 42 | + with: |
| 43 | + path: ~/.cache/pre-commit |
| 44 | + key: pre-commit-${{ runner.os }}-${{ env.PY }}-${{ hashFiles('.pre-commit-config.yaml') }} |
| 45 | + - name: Install dependencies |
| 46 | + run: poetry install --with dev |
| 47 | + - name: Run pre-commit hooks |
| 48 | + run: poetry run pre-commit run |
| 49 | + - name: Lint with flake8 |
| 50 | + run: make lint |
| 51 | + - name: Test with pytest |
| 52 | + run: make test |
| 53 | + - name: Test building |
| 54 | + run: poetry build |
| 55 | + - name: Coveralls |
| 56 | + uses: coverallsapp/github-action@v2 |
| 57 | + with: |
| 58 | + flag-name: run-${{ matrix.python-version }} |
| 59 | + parallel: true |
| 60 | + |
| 61 | + finish: |
| 62 | + needs: test |
| 63 | + if: ${{ always() }} |
| 64 | + runs-on: ubuntu-latest |
| 65 | + steps: |
| 66 | + - name: Coveralls Finished |
| 67 | + uses: coverallsapp/github-action@v2 |
| 68 | + with: |
| 69 | + parallel-finished: true |
| 70 | + carryforward: "run-3.11,run-3.12,run-3.13" |
0 commit comments