Skip to content

Commit 1ca567d

Browse files
committed
ci: Migrate to hatch test command
1 parent a4061b8 commit 1ca567d

2 files changed

Lines changed: 32 additions & 29 deletions

File tree

.github/workflows/python-tests.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ on:
66
pull_request:
77
branches: [main]
88

9+
concurrency:
10+
group: test-${{ github.head_ref }}
11+
cancel-in-progress: true
12+
13+
env:
14+
PYTHONUNBUFFERED: "1"
15+
FORCE_COLOR: "1"
16+
917
jobs:
1018
build:
1119
runs-on: ubuntu-latest
@@ -21,7 +29,7 @@ jobs:
2129
steps:
2230
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
2331

24-
- name: Setup Python
32+
- name: Set up Python ${{ matrix.python-version }}
2533
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
2634
with:
2735
python-version: "${{matrix.python-version}}"
@@ -30,14 +38,13 @@ jobs:
3038
- name: Install Hatch
3139
run: pip install --user --upgrade hatch
3240

33-
- name: Test with pytest
34-
run: hatch run cov
35-
env:
36-
PYTHONDEVMODE: 1
41+
- name: Run type check
42+
run: hatch run types:check
3743

38-
- uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
39-
with:
40-
name: "build-${{ matrix.python-version }}"
41-
fail_ci_if_error: true
44+
- name: Run pre-commit
45+
run: hatch run pre-commit run --all
4246
env:
43-
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
47+
SKIP: nitpick
48+
49+
- name: Run tests
50+
run: hatch test --python ${{ matrix.python-version }} --cover --randomize --parallel --retries 2 --retry-delay 1

pyproject.toml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ packages = ["irclib"]
3838
[tool.hatch.build.hooks.vcs]
3939
version-file = "irclib/_version.py"
4040

41-
[tool.hatch.env]
42-
requires = ["hatch-containers"]
43-
4441
[tool.hatch.envs.default]
4542
dependencies = [
4643
"coverage[toml]>=6.5",
@@ -51,27 +48,26 @@ dependencies = [
5148
]
5249

5350
[tool.hatch.envs.default.scripts]
54-
test = "pytest"
55-
test-cov = ["coverage run -pm pytest"]
56-
cov-report = [
57-
"- coverage combine",
58-
"coverage xml",
59-
"coverage report --show-missing",
60-
]
61-
cov = ["- coverage erase", "test-cov", "cov-report"]
62-
cov-all = ["- coverage erase", "hatch run testall:test-cov", "cov-report"]
63-
6451
setup-pre-commit = "python3 -m pre_commit install --install-hooks -t commit-msg -t pre-push -t pre-commit"
6552
setup-dev = ["setup-pre-commit"]
6653

6754
pre-commit = "python3 -m pre_commit run {args:--all}"
6855

69-
[tool.hatch.envs.testall]
70-
type = "container"
71-
dependencies = ["coverage[toml]>=6.5", "pytest>=6.0", "irc-parser-tests"]
72-
73-
[[tool.hatch.envs.testall.matrix]]
74-
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
56+
[tool.hatch.envs.hatch-test]
57+
default-args = ["tests", "polymatch"]
58+
extra-args = ["-vv"]
59+
[tool.hatch.envs.hatch-test.scripts]
60+
run = "pytest{env:HATCH_TEST_ARGS:} {args}"
61+
run-cov = "coverage run -m pytest{env:HATCH_TEST_ARGS:} {args}"
62+
cov-combine = "coverage combine"
63+
cov-report = ["coverage report --show-missing --skip-covered", "coverage xml"]
64+
[[tool.hatch.envs.hatch-test.matrix]]
65+
python = ["3.13", "3.12", "3.11", "3.10", "3.9"]
66+
67+
[tool.hatch.envs.types]
68+
extra-dependencies = ["mypy>=1.0.0"]
69+
[tool.hatch.envs.types.scripts]
70+
check = "mypy --install-types --non-interactive {args:polymatch tests}"
7571

7672
[tool.isort]
7773
profile = "black"

0 commit comments

Comments
 (0)