From 075ff97a6422b325617e10b60e3fd2618e042697 Mon Sep 17 00:00:00 2001 From: Neriya Cohen <42520786+neriyaco@users.noreply.github.com> Date: Sun, 15 Mar 2026 12:38:00 +0200 Subject: [PATCH] Enhance CI workflow with change checks and result validation Add a check for changes in Python files before running tests and include a step to verify test results. --- .github/workflows/python-test.yml | 37 +++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 19e9289..9e9b692 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -1,26 +1,37 @@ name: Test Python Package - on: pull_request: branches: - main - dev/\d+\.\d+\.\d+ types: [opened, reopened, synchronize] - paths: - - 'src/pydom/**/*.py' permissions: contents: read + pull-requests: read jobs: - test: + check-changes: runs-on: ubuntu-latest + outputs: + python: ${{ steps.filter.outputs.python }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v4 + id: filter + with: + filters: | + python: + - 'src/pydom/**/*.py' + test: + needs: check-changes + if: needs.check-changes.outputs.python == 'true' + runs-on: ubuntu-latest strategy: fail-fast: false matrix: python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] - steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -32,14 +43,26 @@ jobs: python -m pip install --upgrade pip pip install -r requirements.txt pip install -r tests/requirements.txt - - name: Run tests working-directory: ${{ github.workspace }} run: | python -m unittest discover -s tests -p 'test_*.py' -t ${{ github.workspace }} - - name: Run build test working-directory: ${{ github.workspace }} run: | python -m pip install build python -m build + + tests-passed: + runs-on: ubuntu-latest + needs: [check-changes, test] + if: always() + steps: + - name: Check result + run: | + if [[ "${{ needs.test.result }}" == "success" || "${{ needs.test.result }}" == "skipped" ]]; then + echo "All good - tests passed or were not required." + else + echo "Tests failed." + exit 1 + fi