1111 tags-ignore :
1212 - v*
1313 pull_request :
14+ types : [opened, synchronize, reopened, labeled]
1415 workflow_dispatch :
1516
1617permissions :
@@ -24,20 +25,18 @@ jobs:
2425 outputs :
2526 skip : ${{ steps.check.outputs.skip }}
2627 steps :
27- - name : Check if PR exists
28+ - name : Check if PR exists for this branch (skip push if PR exists)
2829 id : check
2930 env :
3031 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
31- HEAD_REF : ${{ github.head_ref }}
32+ HEAD_REF : ${{ github.ref_name }}
3233 run : |
34+ # On push events, base_ref is empty; skip if a PR already exists for this branch
3335 if [ -z "${{ github.base_ref }}" ]; then
3436 prs=$(gh pr list \
3537 --repo "$GITHUB_REPOSITORY" \
36- --json baseRefName,headRefName \
37- --jq '
38- map(select(.baseRefName == "${{ github.base_ref }}" and .headRefName == "$HEAD_REF}"))
39- | length
40- ')
38+ --json headRefName \
39+ --jq "[.[] | select(.headRefName == env.HEAD_REF)] | length")
4140 if ((prs > 0)); then
4241 echo "skip=true" >> "$GITHUB_OUTPUT"
4342 fi
@@ -116,19 +115,49 @@ jobs:
116115 # This ensures javadoc validation matches the exact conditions used during publishing
117116 ./gradlew :ddprof-lib:javadoc --no-daemon --parallel --build-cache --no-watch-fs
118117
118+ compute-configurations :
119+ runs-on : ubuntu-latest
120+ needs : check-for-pr
121+ if : needs.check-for-pr.outputs.skip != 'true'
122+ outputs :
123+ configurations : ${{ steps.compute.outputs.configurations }}
124+ steps :
125+ - name : Debounce label events
126+ if : github.event.action == 'labeled'
127+ run : |
128+ echo "Waiting 30s to allow adding multiple labels..."
129+ sleep 30
130+ - name : Compute test configurations from PR labels
131+ id : compute
132+ env :
133+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
134+ run : |
135+ # Always include debug
136+ configs='["debug"'
137+
138+ # For PRs, check labels; for push/workflow_dispatch, use debug only
139+ if [ "${{ github.event_name }}" = "pull_request" ]; then
140+ labels=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} --jq '.labels[].name' 2>/dev/null) || labels=""
141+
142+ if echo "$labels" | grep -Fq "test:release"; then
143+ configs="$configs"',"release"'
144+ fi
145+ if echo "$labels" | grep -Fq "test:asan"; then
146+ configs="$configs"',"asan"'
147+ fi
148+ if echo "$labels" | grep -Fq "test:tsan"; then
149+ configs="$configs"',"tsan"'
150+ fi
151+ fi
152+
153+ configs="$configs]"
154+ echo "configurations=$configs" >> $GITHUB_OUTPUT
155+ echo "Test configurations: $configs"
156+
119157 test-matrix :
120- needs : check-formatting
158+ needs : [ check-for-pr, check- formatting, compute-configurations]
121159 if : needs.check-for-pr.outputs.skip != 'true'
122160 uses : ./.github/workflows/test_workflow.yml
123161 with :
124- configuration : ' ["debug"] '
162+ configuration : ${{ needs.compute-configurations.outputs.configurations }}
125163
126- gh-release :
127- if : startsWith(github.event.ref, 'refs/heads/release/')
128- runs-on : ubuntu-latest
129- needs : [test-matrix]
130- steps :
131- - name : Create Github Release
132- uses : ./.github/workflows/gh_release.yml@gh-release
133- with :
134- release_branch : ${GITHUB_REF_NAME}
0 commit comments