Skip to content

Commit

Permalink
Improve the CI
Browse files Browse the repository at this point in the history
Signed-off-by: Bernát Gábor <[email protected]>
  • Loading branch information
gaborbernat committed Sep 17, 2024
1 parent 4e98731 commit 68c4218
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 90 deletions.
97 changes: 44 additions & 53 deletions .github/workflows/check.yml → .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,64 +20,50 @@ jobs:
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"
- "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
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
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
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-uv
- name: Install Python
run: uv python install --python-preference only-managed ${{ matrix.py }}
- 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
run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.py }}
- name: Run test suite
run: tox run --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
- 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}")
os.rename(f".tox/.coverage.${{ matrix.py }}}", f".tox/.coverage.${{ matrix.py }}-{sys.platform}")
shell: python
- if: ${{ !startsWith(matrix.py, 'pypy')}}
name: Upload coverage data
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
include-hidden-files: true
Expand All @@ -93,29 +79,28 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
python-version: "3.12"
- name: Install tox
run: python -m pip install tox-uv build[uv]
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-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
run: tox -e coverage --skip-pkg-install
- name: Upload HTML report
uses: actions/upload-artifact@v4
with:
Expand All @@ -142,13 +127,19 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
python-version: "3.12"
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: python -m pip install tox
run: uv tool install --python-preference only-managed --python 3.13 tox-uv
- name: Setup test suite
run: tox -vv --notest -e ${{ matrix.tox_env }}
run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.tox_env }}
- name: Run test suite
run: tox --skip-pkg-install -e ${{ matrix.tox_env }}
run: tox run --skip-pkg-install
48 changes: 48 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
attestations: true
27 changes: 0 additions & 27 deletions .github/workflows/release.yml

This file was deleted.

11 changes: 7 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
Expand Down Expand Up @@ -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 = "function"

[tool.coverage]
html.show_contexts = true
html.skip_covered = false
Expand Down
13 changes: 7 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 68c4218

Please sign in to comment.