Streamline check_for_changes logic #2
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: test_controller | |
| on: | |
| pull_request: | |
| push: | |
| jobs: | |
| # This job checks if there are any changes to important code files. Specifically | |
| # - Code/** | |
| # - tests/** | |
| # - .github/** | |
| # If there are any changes, the job will set the run_full_tests output to true. | |
| # If there are no changes, the job will set the run_full_tests output to false. | |
| check_for_changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| run_full_tests: ${{ steps.set-outputs.outputs.run_full_tests }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dorny/paths-filter@v3 | |
| id: filter | |
| with: | |
| filters: | | |
| relevant: | |
| - 'Code/**' | |
| - 'tests/**' | |
| - '.github/**' | |
| - name: Set output | |
| id: set-outputs | |
| run: | | |
| if [ "${{ steps.filter.outputs.relevant }}" = "true" ]; then | |
| echo "run_full_tests=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "run_full_tests=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| # Dummy job that always passes when no code/tests changed | |
| test: | |
| needs: check_for_changes | |
| if: ${{ needs.check_for_changes.outputs.run_full_tests == 'false' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: No relevant changes | |
| run: echo "✅ Docs-only change, skipping tests." | |
| # Call Ubuntu reusable workflow | |
| test-ubuntu: | |
| needs: check_for_changes | |
| if: ${{ needs.check_for_changes.outputs.run_full_tests == 'true' }} | |
| uses: ./.github/workflows/test_ubuntu.yml | |
| # Call macOS reusable workflow | |
| test-macos: | |
| needs: check_for_changes | |
| if: ${{ needs.check_for_changes.outputs.run_full_tests == 'true' }} | |
| uses: ./.github/workflows/test_macos.yml |