Skip to content

New dseq - draft

New dseq - draft #1213

name: Tests & Coverage
on:
push:
branches:
- "**"
- "!testpypi" # excludes testpypi branch
pull_request: {}
jobs:
build:
name: Test (${{ matrix.python-version }}, ${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: ["macos-latest", "windows-latest"]
python-version: ["3.13", "3.12", "3.11", "3.10"]
include:
- os: ubuntu-latest
python-version: "3.10"
- os: ubuntu-latest
python-version: "3.11"
- os: ubuntu-latest
python-version: "3.12"
codecov: true
- os: ubuntu-latest
python-version: "3.12"
hooks: true
# Don't run hooks check on master, otherwise no-commit-to-branch hook will fail
if: github.ref != 'refs/heads/master'
- os: ubuntu-latest
python-version: "3.13"
# This mimics what would happen installing using pip install pydna (removes the
# poetry.lock file before installing)
- os: ubuntu-latest
python-version: "3.12"
fresh-install: true
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.11.0
- name: ⬇️ Checkout
uses: actions/checkout@v3
- name: 🔩 Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: 🐍 Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install Poetry
uses: snok/install-poetry@v1.4.1
- name: 🔩 list Poetry settings
run: poetry config --list
- name: remove poetry.lock for fresh install
run: rm poetry.lock
if: matrix.fresh-install == 'true'
- name: 🔩 Install with Poetry
run: poetry install --all-extras
- name: 🔎 poetry run python run_test.py
# Don't run tests if we're just checking hooks
if: (!matrix.hooks)
run: poetry run python run_test.py
# Enforce pre-commit hooks ===========================
- name: Get changed files
if: (matrix.hooks)
id: changed-files
uses: tj-actions/changed-files@v45
with:
since_last_remote_commit: true
- uses: actions/cache@v4
if: (matrix.hooks)
id: cache-precommit
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-precommit-hooks-v2-${{ hashFiles('**/.pre-commit-config.yaml') }}
- name: Installing pre-commit hooks (cached)
if: (matrix.hooks) && (steps.cache-precommit.outputs.cache-hit != 'true')
run: poetry run pre-commit install --install-hooks
- name: Run style checking via pre-commit
if: (matrix.hooks && steps.changed-files.outputs.all_changed_files)
run: |
echo "Changed files:"
echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n'
poetry run pre-commit run --files ${{ steps.changed-files.outputs.all_changed_files }}
# ======================================================
- name: 🔼 Upload coverage to Codecov
if: (matrix.codecov)
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: true