Skip to content

Commit ce0f332

Browse files
authored
Update codeql-analysis.yml
1 parent 74f7105 commit ce0f332

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,38 @@ jobs:
6060

6161
- name: Perform CodeQL Analysis
6262
uses: github/codeql-action/analyze@16df4fbc19aea13d921737861d6c622bf3cefe23 #v3.30.3
63+
64+
all-codeql-checks-pass:
65+
runs-on: ubuntu-latest
66+
needs: [analyze]
67+
if: always()
68+
steps:
69+
- name: Checkout to get workflow file
70+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0
71+
72+
- name: Check all jobs succeeded and none missing
73+
run: |
74+
# Check if all needed jobs succeeded
75+
results='${{ toJSON(needs) }}'
76+
if echo "$results" | jq -r '.[] | .result' | grep -v success; then
77+
echo "Some jobs failed"
78+
exit 1
79+
fi
80+
81+
# Extract all job names from workflow (excluding this gate job)
82+
all_jobs=$(yq eval '.jobs | keys | .[]' .github/workflows/codeql.yml | grep -v "all-codeql-checks-pass" | sort)
83+
84+
# Extract job names from needs array
85+
needed_jobs='${{ toJSON(needs) }}'
86+
needs_list=$(echo "$needed_jobs" | jq -r 'keys[]' | sort)
87+
88+
# Check if any jobs are missing from needs
89+
missing_jobs=$(comm -23 <(echo "$all_jobs") <(echo "$needs_list"))
90+
if [ -n "$missing_jobs" ]; then
91+
echo "ERROR: Jobs missing from needs array in all-codeql-checks-pass:"
92+
echo "$missing_jobs"
93+
echo "Please add these jobs to the needs array of all-codeql-checks-pass"
94+
exit 1
95+
fi
96+
97+
echo "All CodeQL checks passed and no jobs missing from gate!"

0 commit comments

Comments
 (0)