-
Notifications
You must be signed in to change notification settings - Fork 0
fix(review): fail loudly when the context script is missing #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -162,6 +162,35 @@ check_permission "statusCheckRollup" statuses "the StatusContext half of the CI | |
| check_permission "/compare/" contents "the since-last-review comparison" | ||
| check_permission "/pulls/" pull-requests "the PR reads" | ||
|
|
||
| # A missing context script has to fail loudly somewhere, and it cannot be the context step: that | ||
| # one is continue-on-error, so `bash <missing file>` exits 127 into a green run. The prompt | ||
| # document gets this for free -- `cat` on a missing file fails its step -- and the script needs an | ||
| # explicit check to match. | ||
| # | ||
| # Scoped to the step, not grepped over the file, because where the check sits is the whole property | ||
| # being asserted: the same `-f` test moved into the context step would satisfy a file-wide grep and | ||
| # prove nothing. So pull the one step and require both halves -- that it tests for the script, and | ||
| # that it is not continue-on-error. | ||
| precondition_step=$(awk '/^ - name: Verify the context step.s preconditions$/ { found = 1; next } | ||
| found && /^ - / { exit } | ||
| found { print }' "$WORKFLOW_FILE") | ||
|
Comment on lines
+174
to
+176
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. super nit: the extraction runs past the step into the next step's comment block (not blocking).
That block happens not to contain the string found && /^ (- |#)/ { exit } |
||
| if [ -z "$precondition_step" ]; then | ||
| echo "FAIL no 'Verify the context step's preconditions' step in $WORKFLOW_FILE; a missing" | ||
| echo " context script would exit 127 inside a continue-on-error step and leave the run" | ||
| echo " green with an empty context" | ||
| failures=$((failures + 1)) | ||
| elif ! printf '%s\n' "$precondition_step" | grep -q -- '-f .*gather-review-context\.sh\|script=.*gather-review-context\.sh'; then | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: the "tests for the script" half still isn't what passes here (not blocking). Against the current step, the first alternative never matches — the Same reason the variable-name coupling isn't quite gone either: Requiring both halves independently rather than either-of-two would match the claim: elif ! printf '%s\n' "$precondition_step" | grep -q 'gather-review-context\.sh' \
|| ! printf '%s\n' "$precondition_step" | grep -q -- '-f'; then |
||
| echo "FAIL the precondition step does not test for the context script:" | ||
| printf '%s\n' "$precondition_step" | sed 's/^/ /' | ||
| failures=$((failures + 1)) | ||
| elif printf '%s\n' "$precondition_step" | grep -q 'continue-on-error'; then | ||
| echo "FAIL the precondition step is continue-on-error, so the check it makes cannot fail the" | ||
| echo " job and proves nothing" | ||
| failures=$((failures + 1)) | ||
| else | ||
| echo "ok a missing context script fails the job rather than emptying the context" | ||
| fi | ||
|
|
||
| # The context step is continue-on-error, so everything it can fail at -- a checkout that does not | ||
| # deliver the script, a bad path, a rename that stops matching the sparse pattern -- leaves the run | ||
| # green with pr_context, threads and review_cycle all unset. Ungated, the review step then runs on | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.