@@ -165,11 +165,27 @@ check_permission "/pulls/" pull-requests "the PR reads"
165165# A missing context script has to fail loudly somewhere, and it cannot be the context step: that
166166# one is continue-on-error, so `bash <missing file>` exits 127 into a green run. The prompt
167167# document gets this for free -- `cat` on a missing file fails its step -- and the script needs an
168- # explicit check to match. It must sit in a step without continue-on-error, or it proves nothing.
169- if ! grep -q " gather-review-context.sh is missing\|! -f \"\$ script\" " " $WORKFLOW_FILE " ; then
170- echo " FAIL nothing in $WORKFLOW_FILE checks that the context script arrived from the"
171- echo " cross-repo checkout. A bad sparse-checkout pattern would exit 127 inside a"
172- echo " continue-on-error step and leave the run green with an empty context."
168+ # explicit check to match.
169+ #
170+ # Scoped to the step, not grepped over the file, because where the check sits is the whole property
171+ # being asserted: the same `-f` test moved into the context step would satisfy a file-wide grep and
172+ # prove nothing. So pull the one step and require both halves -- that it tests for the script, and
173+ # that it is not continue-on-error.
174+ precondition_step=$( awk ' /^ - name: Verify the context step.s preconditions$/ { found = 1; next }
175+ found && /^ - / { exit }
176+ found { print }' " $WORKFLOW_FILE " )
177+ if [ -z " $precondition_step " ]; then
178+ echo " FAIL no 'Verify the context step's preconditions' step in $WORKFLOW_FILE ; a missing"
179+ echo " context script would exit 127 inside a continue-on-error step and leave the run"
180+ echo " green with an empty context"
181+ failures=$(( failures + 1 ))
182+ elif ! printf ' %s\n' " $precondition_step " | grep -q -- ' -f .*gather-review-context\.sh\|script=.*gather-review-context\.sh' ; then
183+ echo " FAIL the precondition step does not test for the context script:"
184+ printf ' %s\n' " $precondition_step " | sed ' s/^/ /'
185+ failures=$(( failures + 1 ))
186+ elif printf ' %s\n' " $precondition_step " | grep -q ' continue-on-error' ; then
187+ echo " FAIL the precondition step is continue-on-error, so the check it makes cannot fail the"
188+ echo " job and proves nothing"
173189 failures=$(( failures + 1 ))
174190else
175191 echo " ok a missing context script fails the job rather than emptying the context"
0 commit comments