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 2ce43f8
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 72 deletions.
3 changes: 1 addition & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"features": {
"ghcr.io/devcontainers-contrib/features/zsh-plugins": {
"omzPlugins": "https://github.com/zsh-users/zsh-autosuggestions"
},
"ghcr.io/devcontainers/features/docker-in-docker": {}
}
},

// Features to add to the dev container. More info: https://containers.dev/features.
Expand Down
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
3 changes: 1 addition & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ repos:
repo: https://github.com/commitizen-tools/commitizen
rev: c2bbc92202e9080adcdf8fa2e99c9e4406a1f684 # frozen: v3.26.0
- hooks:
- entry: hatch run python3 -m mypy
exclude: tests/.*
- entry: hatch run types:check
id: mypy
language: system
name: mypy
Expand Down
51 changes: 26 additions & 25 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ packages = ["polymatch"]
[tool.hatch.build.hooks.vcs]
version-file = "polymatch/_version.py"

[tool.hatch.env]
requires = ["hatch-containers"]

[tool.hatch.envs.default]
dependencies = [
"coverage[toml]>=6.5",
Expand All @@ -51,27 +48,23 @@ dependencies = [
]

[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"]

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.testall.matrix]]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
setup-dev = ["hatch run pre-commit install"]

[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.hatch-test.matrix]]
python = ["3.12", "3.11", "3.10", "3.9", "3.8"]

[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 +161,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 All @@ -185,6 +177,13 @@ addopts = "--doctest-modules"
testpaths = ["polymatch", "tests"]
filterwarnings = ["error"]

[tool.coverage.paths]
polymatch = [
"polymatch",
"*/polymatch/src/polymatch",
]
tests = ["tests", "*/polymatch/tests"]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
Expand All @@ -197,6 +196,8 @@ exclude_lines = [
[tool.coverage.run]
branch = true
relative_files = true
source_pkgs = ["polymatch", "tests"]
omit = ["polymatch/_version.py"]

[tool.commitizen]
name = "cz_conventional_commits"
Expand Down

0 comments on commit 2ce43f8

Please sign in to comment.