Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI tests with Hatch #11

Merged
merged 5 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
runs-on: ubuntu-latest

strategy:
fail-fast: true
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
Expand All @@ -66,21 +66,21 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- uses: pdm-project/setup-pdm@v4
name: Set up PDM
with:
python-version: ${{ matrix.python-version }}
allow-python-prereleases: false
prerelease: false
cache: true
cache-dependency-path: |
./pdm.lock
# - uses: pdm-project/setup-pdm@v4
# name: Set up PDM
# with:
# python-version: ${{ matrix.python-version }}
# allow-python-prereleases: false
# prerelease: false
# cache: true
# cache-dependency-path: |
# ./pdm.lock

- name: Install dependencies
run: pdm install -G:all
- name: Install Hatch
run: python -m pip install hatch==1.13.0

- name: Test with coverage
run: make test-ci
run: make test-py v="${{ matrix.python-version }}"

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
test:
hatch test --cover --all --randomize

test-ci:
pdm run pytest -rA tests --cov=src --cov-report term-missing --cov-report=xml --asyncio-mode=auto
#test-ci:
#pdm run pytest -rA tests --cov=src --cov-report term-missing --cov-report=xml --asyncio-mode=auto

test-py:
hatch test -i python="$(v)" --cover --randomize

lint:
pdm run pre-commit install
Expand Down
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ extra-dependencies = [
"flask",
]

# https://hatch.pypa.io/1.13/config/internal/testing/#scripts
[tool.hatch.envs.hatch-test.scripts]
run = "pytest{env:HATCH_TEST_ARGS:} {args}"
run-cov = "coverage run -m pytest{env:HATCH_TEST_ARGS:} {args}"
cov-combine = "coverage combine"
cov-report = [
"coverage xml",
"coverage report"
]

[[tool.hatch.envs.hatch-test.matrix]]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]

Expand Down