-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(bin): stop reporting cancelled or zero-check CI as green #2415
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
Open
localxcrm
wants to merge
6
commits into
kunchenguid:main
Choose a base branch
from
localxcrm:fm/fm-nomistakes-cancelled-as-green
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5f19b90
fix(bin): stop treating cancelled or empty CI as green
localxcrm 3a96144
no-mistakes(review): sync CI marker patterns and fail coarse complete…
localxcrm f7040c7
no-mistakes(review): reject outcomeless completed run and unblock ver…
localxcrm 9eb7125
no-mistakes(test): verify cancelled checks-passed guard; watcher flak…
localxcrm 3c32b24
no-mistakes(document): document scored CI verdict and outcomeless run…
localxcrm 8ae5680
no-mistakes: apply CI fixes
localxcrm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| #!/usr/bin/env bash | ||
| # Shared CI-ready scoring for a set of check conclusions. | ||
| # | ||
| # ONE owner of the rule that a green verdict is valid only when at least one | ||
| # check completed with success AND none are pending, failed, cancelled, | ||
| # skipped, or never-run. Zero checks is a distinct non-success state, never | ||
| # passed. Used by current-state reporting so a cancelled-only or empty check | ||
| # set cannot be read as checks-passed. | ||
| # | ||
| # Public interface: fm_ci_ready_verdict [conclusion...] | ||
| # Reads conclusions from the arguments, or from stdin (one per line) when | ||
| # none are given. Blank lines are ignored. | ||
| # Prints exactly one of: passed | empty | not-passed | ||
| # Sourced by callers; also runnable as a command so tests drive the same | ||
| # public function through an executable interface. | ||
|
|
||
| fm_ci_verdict_trim() { | ||
| local s=${1:-} | ||
| s="${s#"${s%%[![:space:]]*}"}" | ||
| s="${s%"${s##*[![:space:]]}"}" | ||
| printf '%s' "$s" | ||
| } | ||
|
|
||
| # 0 if $1 is a completed success conclusion. | ||
| fm_ci_verdict_is_success() { | ||
| case "$1" in | ||
| SUCCESS|success) return 0 ;; | ||
| *) return 1 ;; | ||
| esac | ||
| } | ||
|
|
||
| fm_ci_ready_verdict() { | ||
| local raw conclusion saw_success=0 | ||
| if [ "$#" -eq 0 ]; then | ||
| while IFS= read -r raw || [ -n "$raw" ]; do | ||
| set -- "$@" "$raw" | ||
| done | ||
| fi | ||
| for raw in "$@"; do | ||
| conclusion=$(fm_ci_verdict_trim "$raw") | ||
| [ -n "$conclusion" ] || continue | ||
| if fm_ci_verdict_is_success "$conclusion"; then | ||
| saw_success=1 | ||
| continue | ||
| fi | ||
| printf 'not-passed' | ||
| return 0 | ||
| done | ||
| if [ "$saw_success" = 1 ]; then | ||
| printf 'passed' | ||
| else | ||
| printf 'empty' | ||
| fi | ||
| } | ||
|
|
||
| if [ "${BASH_SOURCE[0]}" = "$0" ]; then | ||
| set -u | ||
| fm_ci_ready_verdict "$@" | ||
| printf '\n' | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| #!/usr/bin/env bash | ||
| # Behavior tests for bin/fm-ci-verdict-lib.sh - the CI-ready scoring rule. | ||
| # | ||
| # A green verdict is valid only when at least one check completed with success | ||
| # AND none are pending, failed, cancelled, skipped, or never-run. These cases | ||
| # drive the public command, never the implementation source: | ||
| # (a) cancelled-only conclusions are not passed | ||
| # (b) zero checks is empty, not passed | ||
| # (c) a genuinely all-success set is passed | ||
| # (d) mixed success-plus-non-success is not passed | ||
| set -u | ||
|
|
||
| # shellcheck source=tests/lib.sh | ||
| . "$(dirname "${BASH_SOURCE[0]}")/lib.sh" | ||
|
|
||
| VERDICT="$ROOT/bin/fm-ci-verdict-lib.sh" | ||
|
|
||
| score() { | ||
| "$VERDICT" "$@" < /dev/null | ||
| } | ||
|
|
||
| test_cancelled_only_is_not_passed() { | ||
| local out | ||
| out=$(score CANCELLED) | ||
| [ "$out" = not-passed ] || fail "cancelled-only scored as '$out', want not-passed" | ||
| out=$(score CANCELED) | ||
| [ "$out" = not-passed ] || fail "canceled-only scored as '$out', want not-passed" | ||
| out=$(score SUCCESS CANCELLED) | ||
| [ "$out" = not-passed ] || fail "success+cancelled scored as '$out', want not-passed" | ||
| [ "$out" != passed ] || fail "cancelled conclusions must never score as passed" | ||
| pass "cancelled-only and mixed-cancelled conclusions are not passed" | ||
| } | ||
|
|
||
| test_zero_checks_is_not_passed() { | ||
| local out | ||
| out=$(score) | ||
| [ "$out" = empty ] || fail "zero checks scored as '$out', want empty" | ||
| [ "$out" != passed ] || fail "zero checks must never score as passed" | ||
| out=$(printf '\n\n' | "$VERDICT") | ||
| [ "$out" = empty ] || fail "blank-only input scored as '$out', want empty" | ||
| [ "$out" != passed ] || fail "blank-only input must never score as passed" | ||
| pass "zero checks is empty, not passed" | ||
| } | ||
|
|
||
| test_all_success_is_passed() { | ||
| local out | ||
| out=$(score SUCCESS) | ||
| [ "$out" = passed ] || fail "one success scored as '$out', want passed" | ||
| out=$(score SUCCESS SUCCESS SUCCESS) | ||
| [ "$out" = passed ] || fail "all-success scored as '$out', want passed" | ||
| pass "a genuinely all-success set is passed" | ||
| } | ||
|
|
||
| test_skipped_pending_failed_never_run_are_not_passed() { | ||
| local out word | ||
| for word in SKIPPED NEUTRAL FAILURE ERROR TIMED_OUT ACTION_REQUIRED \ | ||
| STARTUP_FAILURE STALE QUEUED PENDING IN_PROGRESS WAITING REQUESTED \ | ||
| NEVER never-run; do | ||
| out=$(score "$word") | ||
| [ "$out" = not-passed ] || fail "$word scored as '$out', want not-passed" | ||
| [ "$out" != passed ] || fail "$word must never score as passed" | ||
| out=$(score SUCCESS "$word") | ||
| [ "$out" = not-passed ] || fail "success+$word scored as '$out', want not-passed" | ||
| done | ||
| pass "skipped, pending, failed, and never-run conclusions are not passed" | ||
| } | ||
|
|
||
| test_cancelled_only_is_not_passed | ||
| test_zero_checks_is_not_passed | ||
| test_all_success_is_passed | ||
| test_skipped_pending_failed_never_run_are_not_passed | ||
|
|
||
| echo "all fm-ci-verdict-lib tests passed" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Captain, for repos using no-mistakes' trusted
no_ci: truemode, the upstream skill sayschecks-passedis valid when that declaration covers a zero-check repo (source), and this branch even selectsrepository declares no CI; mapping it to an empty conclusion makesfm_ci_ready_verdictreturnempty/not-ready, so a legitimatechecks-passedrun is reportedblocked(or staysworkingin the CI monitor) and the PR is never surfaced as ready. Please distinguish the trusted declaration from a genericno CI checks reportedline and score it as the accepted success case.Useful? React with 👍 / 👎.