diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1357a63..b6f1e07 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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. 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/.pre-commit-config.yaml b/.pre-commit-config.yaml index 85954ad..0332b6f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 8c2cd11..32f889f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", @@ -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" @@ -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", @@ -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", @@ -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"