Introducing Run Examples check in PRs #9
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: Run examples on modified PDL files | |
| on: [pull_request] | |
| jobs: | |
| tests: | |
| name: Execution tests | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 1 | |
| matrix: | |
| python-version: ['3.11', '3.12', '3.13'] | |
| steps: | |
| # Detect modified PDL files, includes Add, Modified, but not Deleted | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect all PDL files that were changed or added | |
| id: changed-pdl-files | |
| uses: tj-actions/changed-files@6cb76d07bee4c9772c6882c06c37837bf82a04d3 # v46 | |
| with: | |
| files: | | |
| **.pdl | |
| json: "true" | |
| escape_json: "false" | |
| - name: List PDL files that were modified or added and append to test_examples_run | |
| env: | |
| MODIFIED_PDL_FILES: ${{ steps.changed-pdl-files.outputs.all_changed_files }} | |
| run: echo "$MODIFIED_PDL_FILES" | |
| # Run tests if there are modified PDL files | |
| - name: Check if update results automatically by GitHub Actions Bot | |
| id: parse-run-examples-config | |
| shell: bash | |
| run: | | |
| value=$(yq '.update_results' tests/test_examples_run.yaml | tr '[:upper:]' '[:lower:]') | |
| echo "value=$value" | |
| echo "update_results=$value" >> $GITHUB_OUTPUT | |
| - uses: ./.github/actions/run-examples | |
| if: ${{ steps.changed-pdl-files.outputs.all_changed_files_count > 0 }} | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| runner-os: ${{ runner.os }} | |
| update-results: ${{ steps.parse-run-examples-config.outputs.update_results }} | |
| check: ${{ steps.changed-pdl-files.outputs.all_changed_files }} | |
| head-ref: ${{ github.head_ref }} | |
| # Patch config with update_results to false | |
| - name: Patch tests/test_examples_run.yaml with update_results to False, only for the last matrix version | |
| if: ${{ steps.parse-run-examples-config.outputs.update_results && matrix.python-version == '3.13' }} | |
| shell: bash | |
| run: | | |
| yq -i '.update_results = ('false')' tests/test_examples_run.yaml | |
| - name: Push the new run-examples yaml config | |
| if: ${{ steps.parse-run-examples-config.outputs.update_results && matrix.python-version == '3.13' }} | |
| shell: bash | |
| run: | | |
| git config --local user.name github-actions[bot] | |
| git config --local user.email 41898282+github-actions[bot]@users.noreply.github.com | |
| git status | |
| git pull | |
| git add tests/test_examples_run.yaml | |
| git diff --cached --quiet || git commit -s -m "github-actions[bot]: Run examples: reverting update_result to false on your behalf" | |
| git push | |