44 push :
55 branches : ["main"]
66 paths-ignore :
7+ - ' docs/**'
78 - ' docker/cuda/**'
89 - ' docker/build.sh'
910 - ' tools/install/**'
1314 pull_request :
1415 branches : ["main"]
1516 paths-ignore :
17+ - ' docs/**'
1618 - ' docker/cuda/**'
1719 - ' docker/build.sh'
1820 - ' tools/install/**'
@@ -25,19 +27,51 @@ concurrency:
2527 cancel-in-progress : true
2628
2729jobs :
30+ # ---------------------------------------------------------------------------
31+ # Guard: skip tests when PR contains docker-related changes, because
32+ # build_image_cuda.yml will handle build + test for those PRs.
33+ # paths-ignore alone cannot guarantee mutual exclusivity when a PR touches
34+ # both docker files and non-docker files, so we need this job-level check.
35+ # ---------------------------------------------------------------------------
36+ check_docker_changes :
37+ runs-on : ubuntu-latest
38+ if : github.event_name == 'pull_request'
39+ outputs :
40+ has_docker_changes : ${{ steps.check.outputs.has_docker_changes }}
41+ steps :
42+ - name : Check for docker-related file changes
43+ id : check
44+ env :
45+ GH_TOKEN : ${{ github.token }}
46+ run : |
47+ CHANGED=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files --paginate --jq '.[].filename')
48+ if echo "$CHANGED" | grep -qE '^(docker/cuda/|docker/build\.sh$|tools/install/|requirements/|\.github/workflows/build_image_cuda\.yml$)'; then
49+ echo "has_docker_changes=true" >> $GITHUB_OUTPUT
50+ else
51+ echo "has_docker_changes=false" >> $GITHUB_OUTPUT
52+ fi
53+
2854 run_tests :
55+ needs : check_docker_changes
56+ # On push: always run (paths-ignore already filtered).
57+ # On PR: only run when no docker-related files changed.
58+ if : always() && (github.event_name == 'push' || needs.check_docker_changes.outputs.has_docker_changes != 'true')
2959 # Package manager and environment settings are read from .github/configs/cuda.yml
3060 uses : ./.github/workflows/all_tests_common.yml
3161 with :
3262 platform : cuda
3363
3464 all_tests :
35- needs : run_tests
65+ needs : [check_docker_changes, run_tests]
3666 runs-on : ubuntu-latest
3767 if : always()
3868 steps :
3969 - name : Verify workflow status
4070 run : |
71+ if [ "${{ needs.check_docker_changes.outputs.has_docker_changes }}" = "true" ]; then
72+ echo "⏭️ Skipped - docker changes detected, handled by build_image_cuda workflow"
73+ exit 0
74+ fi
4175 if [ "${{ needs.run_tests.result }}" != "success" ]; then
4276 echo "❌ Tests workflow failed"
4377 exit 1
0 commit comments