Skip to content

Commit cb62f71

Browse files
authored
Update codeql.yml
1 parent d464802 commit cb62f71

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

.github/workflows/codeql.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,38 @@ jobs:
9090
uses: github/codeql-action/analyze@16df4fbc19aea13d921737861d6c622bf3cefe23 #v2.23.0
9191
with:
9292
category: "/language:${{matrix.language}}"
93+
94+
all-codeql-checks-pass:
95+
runs-on: ubuntu-latest
96+
needs: [analyze]
97+
if: always()
98+
steps:
99+
- name: Checkout to get workflow file
100+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0
101+
102+
- name: Check all jobs succeeded and none missing
103+
run: |
104+
# Check if all needed jobs succeeded
105+
results='${{ toJSON(needs) }}'
106+
if echo "$results" | jq -r '.[] | .result' | grep -v success; then
107+
echo "Some jobs failed"
108+
exit 1
109+
fi
110+
111+
# Extract all job names from workflow (excluding this gate job)
112+
all_jobs=$(yq eval '.jobs | keys | .[]' .github/workflows/codeql.yml | grep -v "all-codeql-checks-pass" | sort)
113+
114+
# Extract job names from needs array
115+
needed_jobs='${{ toJSON(needs) }}'
116+
needs_list=$(echo "$needed_jobs" | jq -r 'keys[]' | sort)
117+
118+
# Check if any jobs are missing from needs
119+
missing_jobs=$(comm -23 <(echo "$all_jobs") <(echo "$needs_list"))
120+
if [ -n "$missing_jobs" ]; then
121+
echo "ERROR: Jobs missing from needs array in all-codeql-checks-pass:"
122+
echo "$missing_jobs"
123+
echo "Please add these jobs to the needs array of all-codeql-checks-pass"
124+
exit 1
125+
fi
126+
127+
echo "All CodeQL checks passed and no jobs missing from gate!"

0 commit comments

Comments
 (0)