Skip to content

chore: Setup CI (#1) #5

chore: Setup CI (#1)

chore: Setup CI (#1) #5

Workflow file for this run

name: Test
on:
push:
branches: [ main ]
paths:
- src/**
- tests/**
- pyproject.toml
- .github/workflows/test.yml
- .github/workflows/constraints.txt
pull_request:
branches: [ main ]
paths:
- src/**
- tests/**
- pyproject.toml
- .github/workflows/test.yml
- .github/workflows/constraints.txt
workflow_dispatch: {}
schedule:
# Run every 27 hours to avoid running at the same time every day
- cron: "40 12 * * 1-5"
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
cache: pip
python-version: "3.11"
- name: Install dependencies
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
run: |
pipx install hatch
- name: Run lint
env:
HATCH_ENV: lint
run: |
hatch run style
typing:
name: Typing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
cache: pip
python-version: "3.11"
- name: Install dependencies
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
run: |
pipx install hatch
- name: Run typing
env:
HATCH_ENV: lint
run: |
hatch run typing
test:
name: Pytest (Python ${{ matrix.python-version }}, ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
include:
- python-version: "3.11"
os: "windows-latest"
- python-version: "3.11"
os: "macos-latest"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
cache: pip
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install dependencies
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
run: |
pipx install hatch
- name: Run tests
env:
HATCH_ENV: "test.py${{ matrix.python-version }}"
run: |
hatch run cov
- uses: actions/upload-artifact@v3
with:
name: coverage-data
path: ".coverage.*"
coverage:
name: Coverage
runs-on: ubuntu-latest
needs: test
env:
PYTHON: "3.11"
HATCH_ENV: coverage
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON }}
- name: Install dependencies
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
run: |
pipx install hatch
- uses: actions/download-artifact@v3
with:
name: coverage-data
- name: Combine coverage data
run: |
hatch run report
- name: Create coverage XML report
run: |
hatch run xml
- uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}