diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index dc0e0ac..dbaa096 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -5,21 +5,8 @@ on: - main pull_request: jobs: - pre_job: - name: Path match check - runs-on: ubuntu-latest - # Map a step output to a job output - outputs: - should_skip: ${{ steps.skip_check.outputs.should_skip }} - steps: - - id: skip_check - uses: fkirc/skip-duplicate-actions@master - with: - github_token: ${{ github.token }} linting: name: All file linting - needs: pre_job - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 diff --git a/.github/workflows/pythontest.yml b/.github/workflows/pythontest.yml index 045ad8a..b4eba61 100644 --- a/.github/workflows/pythontest.yml +++ b/.github/workflows/pythontest.yml @@ -10,16 +10,23 @@ jobs: runs-on: ubuntu-latest # Map a step output to a job output outputs: - should_skip: ${{ steps.skip_check.outputs.should_skip }} + python: ${{ steps.filter.outputs.python }} steps: - - id: skip_check - uses: fkirc/skip-duplicate-actions@master + # paths-filter needs a checkout to diff push events + - uses: actions/checkout@v7 + - id: filter + uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3 with: - github_token: ${{ github.token }} - paths: '["**.py", ".github/workflows/pythontest.yml", "pyproject.toml", "uv.lock"]' + filters: | + python: + - '**.py' + - '.github/workflows/pythontest.yml' + - 'pyproject.toml' + - 'uv.lock' unit_test: name: Python unit tests needs: pre_job + if: ${{ needs.pre_job.outputs.python == 'true' }} runs-on: ubuntu-latest strategy: max-parallel: 5 @@ -27,21 +34,19 @@ jobs: python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] steps: - uses: actions/checkout@v7 - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} with: fetch-depth: 0 - name: Set up uv - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} uses: astral-sh/setup-uv@v7 with: enable-cache: true cache-python: true - name: Run tests - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} run: uv run --python ${{ matrix.python-version }} --group test pytest unit_test_eol_python: name: Python unit tests for EOL Python versions needs: pre_job + if: ${{ needs.pre_job.outputs.python == 'true' }} runs-on: ubuntu-latest strategy: max-parallel: 5 @@ -51,12 +56,23 @@ jobs: image: python:${{ matrix.python-version }}-buster steps: - uses: actions/checkout@v7 - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} - name: Install dependencies and run tests - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} env: PYTHONPATH: ${{ github.workspace }} run: | python -m pip install --upgrade pip pip install "pytest>=6.2.5,<8" "jsonschema==3.2.0" pytest + # Branch protection requires this; skipped matrix jobs report no per-version checks. + required_checks: + name: Python tests + needs: + - pre_job + - unit_test + - unit_test_eol_python + if: always() + runs-on: ubuntu-latest + steps: + - name: Fail if any needed job failed or was cancelled + if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') + run: exit 1