diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml deleted file mode 100644 index 23b03dd..0000000 --- a/.github/workflows/python-tests.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Python tests - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: - - '3.8' - - '3.9' - - '3.10' - - '3.11' - - '3.12' - steps: - - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: "${{matrix.python-version}}" - cache: "pip" - - - name: Install Hatch - run: pip install --user --upgrade hatch - - - name: Test with pytest - run: hatch run cov - env: - PYTHONDEVMODE: 1 - - - uses: codecov/codecov-action@v4 - with: - name: "build-${{ matrix.python-version }}" - fail_ci_if_error: true - env: - CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..a9dbfd1 --- /dev/null +++ b/.github/workflows/test.yml @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 8c2cd11..5760b24 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -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",