From bc09d14e89e7999041157880c93fc6bb01adb3a0 Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Mon, 4 Nov 2024 07:15:30 -0600 Subject: [PATCH 1/2] Rename YAML files --- .github/{dependabot.yml => dependabot.yaml} | 0 .github/workflows/{test.yml => test.yaml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/{dependabot.yml => dependabot.yaml} (100%) rename .github/workflows/{test.yml => test.yaml} (100%) diff --git a/.github/dependabot.yml b/.github/dependabot.yaml similarity index 100% rename from .github/dependabot.yml rename to .github/dependabot.yaml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yaml similarity index 100% rename from .github/workflows/test.yml rename to .github/workflows/test.yaml From 819fb62c152e25944e64316738566c2e45ef6738 Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Tue, 5 Nov 2024 07:06:42 -0600 Subject: [PATCH 2/2] Migrate to the reusable tox workflow --- .github/workflows/test.yaml | 200 ++++++++++-------------------------- 1 file changed, 57 insertions(+), 143 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 20fbe52d..392cd66a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,4 +1,4 @@ -name: "🔬 Test" +name: "🧪 Test" on: pull_request: @@ -11,159 +11,73 @@ on: jobs: test: + name: "${{ matrix.name }}" strategy: fail-fast: false matrix: - # macOS and Windows tests target only the upper and lower CPython versions. - interpreter: - - "CPython" - os: - - name: "macOS" - runner: "macos-latest" - - name: "Windows" - interpreters: "CPython" - runner: "windows-latest" - cpythons: - # The goal is to ensure that each individual runner - # is paired with all Python versions simultaneously. - # This nested-list syntax accomplishes that goal. - - - "3.9" - - "3.12" - # These last two keys are placeholders to ensure consistency in matrix values. - cpython-beta: - - "" - pypys: - - [] - - # The Linux runner tests all CPython and PyPy versions. - # To reduce clock time, CPython and PyPy are tested separately. include: - # CPython - - interpreter: "CPython" - os: - name: "Linux (CPython)" - runner: "ubuntu-latest" + - name: "Linux (CPython)" + runner: "ubuntu-latest" cpythons: - "3.9" - "3.10" - "3.11" - "3.12" - cpython-beta: "3.13" - pypys: [] - # PyPy - - interpreter: "PyPy" - os: - name: "Linux (PyPy)" - runner: "ubuntu-latest" - cpythons: [] - cpython-beta: "" + - "3.13" + tox-factors: + - "chardet" + cache-key-hash-files: + - "pyproject.toml" + - "requirements/*/requirements.txt" + + - name: "Linux (PyPy)" + runner: "ubuntu-latest" pypys: - "3.9" - "3.10" - # NOTE: Tox only offers "best effort" support for PyPy. - # To prevent installing tox on a PyPy interpreter, - # a CPython version must be added to the end of the PyPy list. - tox-python: "3.12" - - name: "${{ matrix.os.name }}" - runs-on: "${{ matrix.os.runner }}" - - steps: - - name: "Checkout the repo" - uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" # v4.2.2 - - - name: "Setup Python" - id: "setup-python" - uses: "actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b" # v5.3.0 - with: - python-version: "${{ - matrix.interpreter == 'PyPy' - && format('pypy-{0}\n{1}', join(matrix.pypys, '\npypy-'), matrix.tox-python) - || format('{0}\n{1}', matrix.cpython-beta, join(matrix.cpythons, '\n')) - }}" - allow-prereleases: true - - - name: "Detect Pythons" - uses: "kurtmckee/detect-pythons@38187a5464f266e93e5c1467699f7be2bf521d2e" # v1.1.0 - - - name: "Restore cache" - id: "restore-cache" - uses: "actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a" # v4.1.2 - with: - # The cache key includes the following to ensure it busts correctly: - # - # * All Python versions (detected by kurtmckee/detect-pythons, above) - # This ensures that .venv/ symlinks to Python interpreters work. - # * The tox configuration (tox.ini) - # * The pytest configuration (pyproject.toml) - # - key: "test-os=${{ runner.os }}-interpreter=${{ matrix.interpreter }}-hash=${{ hashFiles('.python-identifiers', 'tox.ini', 'pyproject.toml') }}" - path: | - .tox/ - .venv/ - - - name: "Determine venv path" - shell: "bash" - run: | - echo 'venv-path=.venv/${{ runner.os == 'Windows' && 'Scripts' || 'bin' }}' >> "$GITHUB_ENV" - - - name: "Create virtual environment" - if: "steps.restore-cache.outputs.cache-hit == false" - run: | - python -m venv .venv - ${{ env.venv-path }}/python -m pip install --upgrade pip setuptools wheel - ${{ env.venv-path }}/python -m pip install tox - - - name: "Run tests (CPython interpreters)" - if: "matrix.interpreter == 'CPython'" - run: "${{ env.venv-path }}/tox run -e py${{ join(matrix.cpythons, '-chardet,py') }}-chardet${{ matrix.cpython-beta != '' && format(',py{0}-chardet', matrix.cpython-beta) || '' }}" - - - name: "Run tests (PyPy interpreters)" - if: "matrix.interpreter == 'PyPy'" - run: "${{ env.venv-path }}/tox run -e pypy${{ join(matrix.pypys, '-chardet,pypy') }}-chardet" - - lint: - name: "Lint" - runs-on: "ubuntu-latest" + tox-factors: + - "chardet" + cache-key-hash-files: + - "pyproject.toml" + - "requirements/*/requirements.txt" - steps: - - name: "Checkout the repo" - uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" # v4.2.2 - - - name: "Setup Python" - id: "setup-python" - uses: "actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b" # v5.3.0 - with: - python-version: "3.12" - - - name: "Detect Pythons" - uses: "kurtmckee/detect-pythons@38187a5464f266e93e5c1467699f7be2bf521d2e" # v1.1.0 - - - name: "Restore cache" - id: "restore-cache" - uses: "actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a" # v4.1.2 - with: - # The cache key includes the following to ensure it busts correctly: - # - # * All Python versions (detected by kurtmckee/detect-pythons, above) - # This ensures that .venv/ symlinks to Python interpreters work. - # * The tox config (tox.ini) - # * The mypy config (pyproject.toml) - # * The Sphinx config (docs/conf.py) - # * The exact dependencies used during testing (requirements/*.txt) - # - key: "lint-hash=${{ hashFiles('.python-identifiers', 'tox.ini', 'pyproject.toml', 'docs/conf.py', 'requirements/*.txt') }}" - path: | - .mypy_cache/ - .tox/ - .venv/ - - - name: "Create virtual environment" - if: "steps.restore-cache.outputs.cache-hit == false" - run: | - python -m venv .venv - .venv/bin/python -m pip install --upgrade pip setuptools wheel - .venv/bin/python -m pip install tox + # macOS and Windows tests target only the upper and lower CPython versions. + - name: "macOS" + runner: "macos-latest" + cpythons: + - "3.9" + - "3.13" + tox-factors: + - "chardet" + cache-key-hash-files: + - "pyproject.toml" + - "requirements/*/requirements.txt" - - name: "Lint" - run: ".venv/bin/tox run -e docs,mypy" + - name: "Windows" + runner: "windows-latest" + cpythons: + - "3.9" + - "3.13" + tox-factors: + - "chardet" + cache-key-hash-files: + - "pyproject.toml" + - "requirements/*/requirements.txt" + + - name: "Quality" + runner: "ubuntu-latest" + cpythons: + - "3.12" + tox-environments: + - "docs" + - "mypy" + cache-paths: + - ".mypy_cache/" + cache-key-hash-files: + - "docs/conf.py" + - "pyproject.toml" + - "requirements/*/requirements.txt" + + uses: "kurtmckee/github-workflows/.github/workflows/tox.yaml@2f156c58bf4ceebc623014b407f5711899e41235" # v1.0 + with: + config: "${{ toJSON(matrix) }}"