diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml new file mode 100644 index 0000000..0316ecb --- /dev/null +++ b/.github/workflows/check.yaml @@ -0,0 +1,52 @@ +name: check +on: + workflow_dispatch: + push: + branches: ["main"] + tags-ignore: ["**"] + pull_request: + schedule: + - cron: "0 8 * * *" + +concurrency: + group: check-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + env: + - "3.13" + - "3.12" + - "3.11" + - "3.10" + - type + - dev + - pkg_meta + steps: + - name: Install OS dependencies + run: sudo apt-get install graphviz -y + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v3 + with: + enable-cache: true + cache-dependency-glob: "pyproject.toml" + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Install tox + run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv + - name: Install Python + if: startsWith(matrix.env, '3.') && matrix.env != '3.13' + run: uv python install --python-preference only-managed ${{ matrix.env }} + - name: Setup test suite + run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.env }} + - name: Run test suite + run: tox run --skip-pkg-install -e ${{ matrix.env }} + env: + PYTEST_ADDOPTS: "-vv --durations=20" + DIFF_AGAINST: HEAD diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index fd93e1c..0000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,114 +0,0 @@ -name: check -on: - workflow_dispatch: - push: - branches: ["main"] - tags-ignore: ["**"] - pull_request: - schedule: - - cron: "0 8 * * *" - -concurrency: - group: check-${{ github.ref }} - cancel-in-progress: true - -jobs: - test: - name: test with CPython ${{ matrix.py }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - py: - - "3.13" - - "3.12" - - "3.11" - - "3.10" - steps: - - name: Setup python for tox - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - name: Install tox - run: python -m pip install tox-uv - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup python for test ${{ matrix.py }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.py }} - allow-prereleases: true - - name: setup test suite - run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.py }} - - name: run test suite - run: tox run --skip-pkg-install -e ${{ matrix.py }} - env: - PYTEST_ADDOPTS: "-vv --durations=20" - CI_RUN: "yes" - DIFF_AGAINST: HEAD - - name: Upload coverage data - uses: actions/upload-artifact@v4 - with: - include-hidden-files: true - name: .coverage.${{ matrix.py }} - path: ".tox/.coverage.*" - retention-days: 3 - - coverage: - name: Combine coverage - runs-on: ubuntu-latest - needs: test - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - name: Install tox - run: python -m pip install tox-uv - - name: Setup coverage tool - run: tox -e coverage --notest - - name: Install package builder - run: python -m pip install build[uv] - - name: Build package - run: pyproject-build --wheel --installer uv . - - name: Download coverage data - uses: actions/download-artifact@v4 - with: - path: .tox - pattern: .coverage.* - merge-multiple: true - - name: Combine and report coverage - run: tox -e coverage - - name: Upload HTML report - uses: actions/upload-artifact@v4 - with: - name: html-report - path: .tox/htmlcov - - check: - name: tox env ${{ matrix.tox_env }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - tox_env: - - dev - - readme - - type - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup Python "3.12" - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - name: Install tox - run: python -m pip install tox-uv - - name: Setup test suite - run: tox -vv --notest --skip-missing-interpreters false -e ${{ matrix.tox_env }} - - name: Run test suite - run: tox --skip-pkg-install -e ${{ matrix.tox_env }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..49a6c8a --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,48 @@ +name: Release to PyPI +on: + push: + tags: ["*"] + +env: + dists-artifact-name: python-package-distributions + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v3 + with: + enable-cache: true + cache-dependency-glob: "pyproject.toml" + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Build package + run: uv build --python 3.13 --python-preference only-managed --sdist --wheel . --out-dir dist + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: ${{ env.dists-artifact-name }} + path: dist/* + + release: + needs: + - build + runs-on: ubuntu-latest + environment: + name: release + url: https://pypi.org/project/sphinx-autodoc-typehints/${{ github.ref_name }} + permissions: + id-token: write + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: ${{ env.dists-artifact-name }} + path: dist/ + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@v1.10.1 + with: + attestations: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index ceebf6e..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Release to PyPI -on: - push: - tags: ["*"] - -jobs: - release: - runs-on: ubuntu-latest - environment: - name: release - url: https://pypi.org/p/sphinx-autodoc-typehints - permissions: - id-token: write - steps: - - name: Setup python to build package - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - name: Install build - run: python -m pip install build - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Build package - run: pyproject-build -s -w . -o dist - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@v1.10.1 diff --git a/tox.ini b/tox.ini index ec9a346..7c95248 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,7 @@ [tox] requires = tox>=4.2 + tox-uv>=1.11.3 env_list = fix 3.13 @@ -8,12 +9,11 @@ env_list = 3.11 3.10 type - coverage - readme + pkg_meta skip_missing_interpreters = true [testenv] -description = run tests with {basepython} +description = run the unit tests with pytest under {base_python} package = wheel wheel_build_env = .pkg extras = @@ -21,31 +21,27 @@ extras = testing type-comment pass_env = - PIP_* + DIFF_AGAINST PYTEST_* set_env = - COVERAGE_FILE = {toxworkdir}{/}.coverage.{envname} + COVERAGE_FILE = {work_dir}/.coverage.{env_name} commands = - pytest {tty:--color=yes} {posargs: \ - --junitxml {toxworkdir}{/}junit.{envname}.xml --cov {envsitepackagesdir}{/}sphinx_autodoc_typehints --cov {toxinidir}{/}tests \ + python -m pytest {tty:--color=yes} {posargs: \ + --cov {env_site_packages_dir}{/}sphinx_autodoc_typehints --cov {tox_root}{/}tests \ --cov-config=pyproject.toml --no-cov-on-fail --cov-report term-missing:skip-covered --cov-context=test \ - --cov-report html:{envtmpdir}{/}htmlcov --cov-report xml:{toxworkdir}{/}coverage.{envname}.xml \ + --cov-report html:{env_tmp_dir}{/}htmlcov --cov-report xml:{work_dir}{/}coverage.{env_name}.xml \ + --junitxml {work_dir}{/}junit.{env_name}.xml \ tests} - diff-cover --compare-branch {env:DIFF_AGAINST:origin/main} {toxworkdir}{/}coverage.{envname}.xml + diff-cover --compare-branch {env:DIFF_AGAINST:origin/main} {work_dir}{/}coverage.{env_name}.xml --fail-under 100 [testenv:fix] description = format the code base to adhere to our styles, and complain about what we cannot do automatically skip_install = true deps = - pre-commit-uv>=4.1 + pre-commit-uv>=4.1.1 commands = pre-commit run --all-files --show-diff-on-failure -[testenv:3.13] -extras = - testing - type-comment - [testenv:type] description = run type check on code base deps = @@ -55,46 +51,21 @@ commands = mypy src mypy tests -[testenv:coverage] -description = combine coverage files and generate diff (against DIFF_AGAINST defaulting to origin/main) -skip_install = true -deps = - covdefaults>=2.3 - coverage>=7.6.1 - diff-cover>=9.1.1 -extras = -parallel_show_output = true -pass_env = - DIFF_AGAINST -set_env = - COVERAGE_FILE = {toxworkdir}/.coverage -commands = - coverage combine - coverage report --skip-covered --show-missing - coverage xml -o {toxworkdir}/coverage.xml - coverage html -d {toxworkdir}/htmlcov - diff-cover --compare-branch {env:DIFF_AGAINST:origin/main} {toxworkdir}/coverage.xml -depends = - 3.13 - 3.12 - 3.11 - 3.10 - -[testenv:readme] -description = check that the long description is valid (need for PyPI) +[testenv:pkg_meta] +description = check that the long description is valid skip_install = true deps = - build[virtualenv]>=1.2.2 + check-wheel-contents>=0.6 twine>=5.1.1 -extras = + uv>=0.4.10 commands = - pyproject-build -o {envtmpdir} --wheel --sdist . - twine check {envtmpdir}/* + uv build --sdist --wheel --out-dir {env_tmp_dir} . + twine check {env_tmp_dir}{/}* + check-wheel-contents --no-config {env_tmp_dir} [testenv:dev] description = generate a DEV environment package = editable commands = - python -m pip list --format=columns + uv pip tree python -c 'import sys; print(sys.executable)' -uv_seed = true