Skip to content

Commit e93a268

Browse files
fix: make GS Scorecard label-triggered but required for merging to main (#468)
## Summary - GSSA now only executes when the `execute_gs_scorecard` label is applied (no longer auto-runs on PRs to main) - For PRs targeting `main`, GSSA must have completed (pass or fail) before the PR can merge -- if skipped, `pre-publish` blocks with a clear error annotation and step summary message - Push to `main` continues to auto-run GSSA - Push to `develop`/`release/*`, schedule, and dispatch no longer run GSSA ## Changes ### `setup-workflow` job - Removed `execute_gs_scorecard` from `TESTS_TO_CONSIDER_FOR_EXECUTION` (no longer auto-enabled by branch/event logic) - Added explicit GSSA control after the `esac`: enables only when label is present (any PR) or on push to main ### `pre-publish` job - Added `run-gs-scorecard` to the `needs` list - Added a check: if the event is a PR to `main` and GSSA result is `skipped`, outputs `::error::` annotation, writes to `$GITHUB_STEP_SUMMARY`, and sets `run-publish=false` - Modified the existing jq filter to exclude `run-gs-scorecard` via `del(.["run-gs-scorecard"])` so GSSA failure doesn't block other checks ## Test results Tested on [splunk/splunk-add-on-for-ibm-websphere-application-server PR #388](splunk/splunk-add-on-for-ibm-websphere-application-server#388): | Test | Workflow Run | Result | |---|---|---| | PR to main **without** label — GSSA should be skipped, pre-publish should block | [Run #22358328636](https://github.com/splunk/splunk-add-on-for-ibm-websphere-application-server/actions/runs/22358328636) | PASS — GSSA skipped, pre-publish set `run-publish=false` with error annotation | | PR to main **with** `execute_gs_scorecard` label — GSSA should run, pre-publish should proceed | [Run #22370270246](https://github.com/splunk/splunk-add-on-for-ibm-websphere-application-server/actions/runs/22370270246) | PASS — GSSA ran (failed), pre-publish succeeded (result ignored) | JIRA: [ADDON-85652](https://splunk.atlassian.net/browse/ADDON-85652)
1 parent 8af1eaf commit e93a268

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

.github/workflows/reusable-build-test-release.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,6 @@ jobs:
256256
echo "spl2::true"
257257
fi
258258
259-
# GS Scorecard is always available
260-
TESTS_TO_CONSIDER_FOR_EXECUTION+=("execute_gs_scorecard")
261-
echo "gs_scorecard::true"
262-
263259
found_unit_test=false
264260
for test_name in "${TESTS_TO_CONSIDER_FOR_EXECUTION[@]}"; do
265261
if [[ "$test_name" == "execute_unit" ]]; then
@@ -328,6 +324,14 @@ jobs:
328324
echo "No tests were labeled for execution!"
329325
;;
330326
esac
327+
328+
# GS Scorecard: runs when label is present (any PR) or on push to main
329+
# Required (must not be skipped) for merging PRs to main -- enforced in pre-publish
330+
if [[ "${{ github.event_name }}" == "pull_request" ]] && [[ "$labels" =~ execute_gs_scorecard ]]; then
331+
EXECUTION_FLAGS["execute_gs_scorecard"]="true"
332+
elif [[ "${{ github.event_name }}" == "push" ]] && [[ "${{ github.ref_name }}" == "main" ]]; then
333+
EXECUTION_FLAGS["execute_gs_scorecard"]="true"
334+
fi
331335
fi
332336
echo "Tests to be executed:"
333337
for test_type in "${TESTSET[@]}"; do
@@ -2917,6 +2921,7 @@ jobs:
29172921
- run-ucc-modinput-tests
29182922
- run-ui-tests
29192923
- validate-pr-title
2924+
- run-gs-scorecard
29202925
runs-on: ubuntu-latest
29212926
env:
29222927
NEEDS: ${{ toJson(needs) }}
@@ -2925,7 +2930,19 @@ jobs:
29252930
id: check
29262931
shell: bash
29272932
run: |
2928-
RUN_PUBLISH=$(echo "$NEEDS" | jq ".[] | select( ( .result != \"skipped\" ) and .result != \"success\" ) | length == 0")
2933+
# GS Scorecard: must have run for PRs to main (result doesn't matter, but skipped = blocked)
2934+
GS_RESULT=$(echo "$NEEDS" | jq -r '.["run-gs-scorecard"].result')
2935+
if [[ "${{ github.event_name }}" == "pull_request" ]] && [[ "${{ github.base_ref }}" == "main" ]] && [[ "$GS_RESULT" == "skipped" ]]; then
2936+
echo "::error::GS Scorecard is required for PRs to main. Add the 'execute_gs_scorecard' label and re-run the workflow."
2937+
echo "## GS Scorecard Required" >> "$GITHUB_STEP_SUMMARY"
2938+
echo "Add the \`execute_gs_scorecard\` label to this PR and re-run the workflow. GS Scorecard must complete before merging to main (result does not need to pass)." >> "$GITHUB_STEP_SUMMARY"
2939+
echo "run-publish=false" >> "$GITHUB_OUTPUT"
2940+
echo "Publish conditions are not met."
2941+
exit 1
2942+
fi
2943+
2944+
# Exclude run-gs-scorecard from the general check since it has its own handling above
2945+
RUN_PUBLISH=$(echo "$NEEDS" | jq 'del(.["run-gs-scorecard"]) | .[] | select((.result != "skipped") and .result != "success") | length == 0')
29292946
if [[ "$RUN_PUBLISH" != *'false'* ]] && [[ "${{ needs.check-docs-changes.outputs.docs-only }}" == 'false' ]]
29302947
then
29312948
echo "run-publish=true" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)