diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml new file mode 100644 index 0000000..15ad3a6 --- /dev/null +++ b/.github/workflows/check.yaml @@ -0,0 +1,154 @@ +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 ${{ matrix.py }} - ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + py: + - "pypy3.10" # ahead to start it earlier because takes longer + - "3.13" + - "3.12" + - "3.11" + - "3.10" + - "3.9" + - "3.8" + os: + - ubuntu-latest + - windows-latest + - macos-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: Add .local/bin to Windows PATH + if: runner.os == 'Windows' + shell: bash + run: echo "$USERPROFILE/.local/bin" >> $GITHUB_PATH + - name: Install tox + run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv + - name: Install Python + run: uv python install --python-preference only-managed ${{ matrix.py }} + - name: Setup test suite + run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.py }} + - name: Run test suite + if: ${{ !startsWith(matrix.py, 'pypy')}} + run: tox run --skip-pkg-install -e ${{ matrix.py }} + env: + PYTEST_ADDOPTS: "-vv --durations=20" + DIFF_AGAINST: HEAD + - name: Run test suite without coverage + if: ${{ startsWith(matrix.py, 'pypy')}} + run: tox run --skip-pkg-install -e ${{ matrix.py }} -- + env: + PYTEST_ADDOPTS: "-vv --durations=20" + - name: Rename coverage report file + if: ${{ !startsWith(matrix.py, 'pypy')}} + run: | + import os; import sys + os.rename(f".tox/.coverage.${{ matrix.py }}", f".tox/.coverage.${{ matrix.py }}-{sys.platform}") + shell: python + - name: Upload coverage data + if: ${{ !startsWith(matrix.py, 'pypy')}} + uses: actions/upload-artifact@v4 + with: + include-hidden-files: true + name: .coverage.${{ matrix.os }}.${{ 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 + - 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: Add .local/bin to Windows PATH + if: runner.os == 'Windows' + shell: bash + run: echo "$USERPROFILE/.local/bin" >> $GITHUB_PATH + - name: Install hatch + run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv + - name: Build package to generate version + run: uv build --python 3.13 --python-preference only-managed --wheel . --out-dir dist + - name: Setup coverage tool + run: tox -e coverage --notest + - 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 --skip-pkg-install + - name: Upload HTML report + uses: actions/upload-artifact@v4 + with: + name: html-report + path: .tox/htmlcov + + check: + name: ${{ matrix.tox_env }} - ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - windows-latest + tox_env: + - dev + - type + - docs + - readme + exclude: + - { os: windows-latest, tox_env: readme } + 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: Add .local/bin to Windows PATH + if: runner.os == 'Windows' + shell: bash + run: echo "$USERPROFILE/.local/bin" >> $GITHUB_PATH + - name: Install tox + run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv + - name: Setup test suite + run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.tox_env }} + - name: Run test suite + run: tox run --skip-pkg-install -e ${{ matrix.tox_env }} diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index a487148..0000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,154 +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 ${{ matrix.py }} - ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - py: - - "3.13" - - "3.12" - - "3.11" - - "3.10" - - "3.9" - - "3.8" - - "pypy3.10" - os: - - ubuntu-latest - - windows-latest - - macos-latest - - 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: Pick environment to run - run: | - import os; import platform; import sys; from pathlib import Path - env = f'TOXENV=py{"" if platform.python_implementation() == "CPython" else "py"}3{sys.version_info.minor}' - print(f"Picked: {env} for {sys.version} based of {sys.executable}") - with Path(os.environ["GITHUB_ENV"]).open("ta") as file_handler: - file_handler.write(env) - shell: python - - name: Setup test suite - run: tox r -vv --notest - - if: ${{ startsWith(matrix.py, 'pypy') }} - name: Run test suite - run: tox r --skip-pkg-install -- - env: - PYTEST_ADDOPTS: "-vv --durations=20" - CI_RUN: "yes" - - if: ${{ !startsWith(matrix.py, 'pypy')}} - name: Run test suite - run: tox r --skip-pkg-install - env: - PYTEST_ADDOPTS: "-vv --durations=20" - CI_RUN: "yes" - DIFF_AGAINST: HEAD - - if: ${{ !startsWith(matrix.py, 'pypy')}} - name: Rename coverage report file - run: | - import os; import sys - os.rename(f".tox/.coverage.{os.environ['TOXENV']}", f".tox/.coverage.{os.environ['TOXENV']}-{sys.platform}") - shell: python - - if: ${{ !startsWith(matrix.py, 'pypy')}} - name: Upload coverage data - uses: actions/upload-artifact@v4 - with: - include-hidden-files: true - name: .coverage.${{ matrix.os }}.${{ 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 build[uv] - - name: Setup coverage tool - run: tox -e coverage --notest - - name: Install package builder - run: python -m pip install build - - name: Build package - run: pyproject-build --wheel . - - name: Download coverage data - uses: actions/download-artifact@v4 - with: - path: .tox - pattern: .coverage.* - merge-multiple: true - - name: Show contents - run: ls -alth * - - name: pwd - run: pwd - - 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: ${{ matrix.tox_env }} - ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: - - ubuntu-latest - - windows-latest - tox_env: - - dev - - type - - docs - - readme - exclude: - - { os: windows-latest, tox_env: readme } - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - name: Install tox - run: python -m pip install tox - - name: Setup test suite - run: tox -vv --notest -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..a6593a7 --- /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/filelock/${{ 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 54e33b8..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/filelock - 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/pyproject.toml b/pyproject.toml index e864255..259d8e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,18 +44,18 @@ dynamic = [ optional-dependencies.docs = [ "furo>=2024.8.6", "sphinx>=8.0.2", - "sphinx-autodoc-typehints!=1.23.4,>=2.4", + "sphinx-autodoc-typehints>=2.4.1", ] optional-dependencies.testing = [ "covdefaults>=2.3", "coverage>=7.6.1", - "diff-cover>=9.1.1", - "pytest>=8.3.2", + "diff-cover>=9.2", + "pytest>=8.3.3", "pytest-asyncio>=0.24", "pytest-cov>=5", "pytest-mock>=3.14", "pytest-timeout>=2.3.1", - "virtualenv>=20.26.3", + "virtualenv>=20.26.4", ] optional-dependencies.typing = [ "typing-extensions>=4.12.2; python_version<'3.11'", @@ -120,6 +120,9 @@ ignore-words-list = "master" [tool.pyproject-fmt] max_supported_python = "3.13" +[tool.pytest.ini_options] +asyncio_default_fixture_loop_scope = "session" + [tool.coverage] html.show_contexts = true html.skip_covered = false diff --git a/tox.ini b/tox.ini index a393499..c82819c 100644 --- a/tox.ini +++ b/tox.ini @@ -60,7 +60,7 @@ skip_install = true deps = covdefaults>=2.3 coverage[toml]>=7.6.1 - diff-cover>=9.1.1 + diff-cover>=9.2 extras = parallel_show_output = true pass_env = @@ -90,15 +90,16 @@ commands = python -c 'print(r"documentation available under file://{toxworkdir}{/}docs_out{/}index.html")' [testenv:readme] -description = check that the long description is valid (need for PyPI) +description = check that the long description is valid skip_install = true deps = - build[uv]>=1.2.2 + check-wheel-contents>=0.6 twine>=5.1.1 -extras = + uv>=0.4.10 commands = - pyproject-build -o {envtmpdir} --installer uv --wheel --sdist . - twine check {envtmpdir}/* + uv build --sdist --wheel --out-dir {envtmpdir} . + twine check {envtmpdir}{/}* + check-wheel-contents --no-config {envtmpdir} [testenv:dev] description = generate a DEV environment