Skip to content

Commit

Permalink
ci: migrate to hatch test command
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdaemon committed May 23, 2024
1 parent 9a7a066 commit 798d132
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 59 deletions.
43 changes: 0 additions & 43 deletions .github/workflows/python-tests.yml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: test

on:
push:
branches: [main]
pull_request:
branches: [main]

concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"

jobs:
run:
name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Hatch
run: pip install --upgrade hatch

# - name: Run static analysis
# run: hatch fmt --check

- name: Run type check
run: hatch run types:check

- name: Run pre-commit
run: hatch run pre-commit run --all
env:
SKIP: nitpick

- name: Run tests
run: hatch test --python ${{ matrix.python-version }} --cover --randomize --parallel --retries 2 --retry-delay 1
31 changes: 15 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,28 @@ dependencies = [
"types-regex",
]

[tool.hatch.envs.default.scripts]
test = "pytest"
test-cov = ["coverage run -pm pytest"]
cov-report = [
"- coverage combine",
"coverage xml",
"coverage report --show-missing",
]
cov = ["- coverage erase", "test-cov", "cov-report"]
cov-all = ["- coverage erase", "hatch run testall:test-cov", "cov-report"]
[[tool.hatch.envs.default.matrix]]
python = ["3.12", "3.11", "3.10", "3.9", "3.8"]

[tool.hatch.envs.default.scripts]
setup-pre-commit = "python3 -m pre_commit install --install-hooks -t commit-msg -t pre-push -t pre-commit"
setup-dev = ["setup-pre-commit"]

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

[tool.hatch.envs.testall]
type = "container"
dependencies = ["coverage[toml]>=6.5", "pytest>=6.0"]
[tool.hatch.envs.hatch-test]
default-args = ["tests", "polymatch"]
extra-args = ["-vv"]
[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 report --show-missing --skip-covered", "coverage xml"]

[[tool.hatch.envs.testall.matrix]]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
[tool.hatch.envs.types]
extra-dependencies = ["mypy>=1.0.0"]
[tool.hatch.envs.types.scripts]
check = "mypy --install-types --non-interactive {args:polymatch tests}"

[tool.isort]
profile = "black"
Expand Down Expand Up @@ -168,7 +168,6 @@ extra_checks = true
warn_unreachable = true
warn_return_any = true
warn_no_return = true
incremental = false
enable_error_code = [
"redundant-self",
"redundant-expr",
Expand Down

0 comments on commit 798d132

Please sign in to comment.