Skip to content

Commit

Permalink
CI tests with Hatch (#11)
Browse files Browse the repository at this point in the history
Setup CI tests with hatch
  • Loading branch information
nightblure authored Oct 27, 2024
1 parent 74cbfd8 commit 094fec7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
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

0 comments on commit 094fec7

Please sign in to comment.