11name : Affected Go Tests
22
33on :
4- workflow_run :
5- workflows : ["build"]
6- types : [completed]
4+ pull_request :
5+ types : [opened, reopened, synchronize, ready_for_review]
76
87permissions :
98 contents : read
109
1110jobs :
1211 test-affected :
13- # Only run if the build-test workflow succeeded and it's not a draft PR
14- if : |
15- github.event.workflow_run.conclusion == 'success' &&
16- github.event.workflow_run.event == 'pull_request' &&
17- github.event.workflow_run.pull_requests[0].draft == false
12+ if : github.event.pull_request.draft == false
1813 runs-on : ubuntu-latest
1914 timeout-minutes : 30
2015 steps :
2116 - name : Checkout
2217 uses : actions/checkout@v4
2318 with :
24- # Check out the PR merge commit
25- ref : ${{ github.event.workflow_run.head_sha }}
2619 fetch-depth : 0
2720
2821 - name : Setup Go
@@ -46,30 +39,20 @@ jobs:
4639 go test -c -o /dev/null "$pkg" || exit 1
4740 done < <(go list ./...)
4841
49- - name : Get PR Base SHA
42+ - name : Compute base ref
5043 id : pr-info
51- env :
52- GH_TOKEN : ${{ github.token }}
5344 run : |
54- # Get the PR number from the workflow run
55- PR_NUMBER="${{ github.event.workflow_run.pull_requests[0].number }}"
56- echo "PR Number: ${PR_NUMBER}"
57-
58- # Get the base SHA for this PR
59- BASE_SHA=$(gh pr view ${PR_NUMBER} --json baseRefOid -q .baseRefOid)
60- echo "BASE_SHA=${BASE_SHA}" >> "$GITHUB_OUTPUT"
61- echo "Base SHA: ${BASE_SHA}"
45+ echo "BASE_REF=origin/${{ github.base_ref }}" >> "$GITHUB_OUTPUT"
46+ echo "Base ref: origin/${{ github.base_ref }}"
6247
6348 # 2) Detect relevant unit packages and e2e tests
6449 - name : Compute affected packages
6550 id : affected
66- env :
67- BASE_SHA : ${{ steps.pr-info.outputs.BASE_SHA }}
6851 run : |
6952 set -euo pipefail
70- echo "Base SHA : ${BASE_SHA }"
53+ echo "Base: ${{ steps.pr-info.outputs.BASE_REF } }"
7154 # Generate affected package list to a file for reuse in subsequent steps
72- go run ./scripts/affected-packages.go -base "${BASE_SHA }" > /tmp/affected.txt
55+ go run ./scripts/affected-packages.go -base "${{ steps.pr-info.outputs.BASE_REF } }" > /tmp/affected.txt
7356 echo "Affected packages:" || true
7457 if [ -s /tmp/affected.txt ]; then
7558 cat /tmp/affected.txt
8568
8669 - name : Compute affected e2e tests
8770 id : affected_e2e
88- env :
89- BASE_SHA : ${{ steps.pr-info.outputs.BASE_SHA }}
9071 run : |
9172 set -euo pipefail
92- go run ./scripts/affected-packages.go -mode=suites -base "${BASE_SHA }" > /tmp/affected-e2e.txt
73+ go run ./scripts/affected-packages.go -mode=suites -base "${{ steps.pr-info.outputs.BASE_REF } }" > /tmp/affected-e2e.txt
9374 awk -F: '$1=="preflight"{print $2}' /tmp/affected-e2e.txt > /tmp/preflight-tests.txt
9475 awk -F: '$1=="support-bundle"{print $2}' /tmp/affected-e2e.txt > /tmp/support-tests.txt
9576 if [ -s /tmp/preflight-tests.txt ] || [ -s /tmp/support-tests.txt ]; then
0 commit comments