Skip to content

Commit 597fa20

Browse files
authored
Update pr-build.yml
1 parent ce0f332 commit 597fa20

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

.github/workflows/pr-build.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,37 @@ jobs:
219219
working-directory: lambda-layer
220220
run: ./build-layer.sh
221221

222+
all-pr-checks-pass:
223+
runs-on: ubuntu-latest
224+
needs: [changelog-check, testpatch, build, build-lambda]
225+
if: always()
226+
steps:
227+
- name: Checkout to get workflow file
228+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0
229+
230+
- name: Check all jobs succeeded and none missing
231+
run: |
232+
# Check if all needed jobs succeeded
233+
results='${{ toJSON(needs) }}'
234+
if echo "$results" | jq -r '.[] | .result' | grep -v success; then
235+
echo "Some jobs failed"
236+
exit 1
237+
fi
238+
239+
# Extract all job names from workflow (excluding this gate job)
240+
all_jobs=$(yq eval '.jobs | keys | .[]' .github/workflows/pr-build.yml | grep -v "all-pr-checks-pass" | sort)
241+
242+
# Extract job names from needs array
243+
needed_jobs='${{ toJSON(needs) }}'
244+
needs_list=$(echo "$needed_jobs" | jq -r 'keys[]' | sort)
245+
246+
# Check if any jobs are missing from needs
247+
missing_jobs=$(comm -23 <(echo "$all_jobs") <(echo "$needs_list"))
248+
if [ -n "$missing_jobs" ]; then
249+
echo "ERROR: Jobs missing from needs array in all-pr-checks-pass:"
250+
echo "$missing_jobs"
251+
echo "Please add these jobs to the needs array of all-pr-checks-pass"
252+
exit 1
253+
fi
254+
255+
echo "All checks passed and no jobs missing from gate!"

0 commit comments

Comments
 (0)