Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(ci): report cancelled nightly gate failures (#825)

Danny Ward03c3c62a8739
diff --git a/.github/workflows/nightly-alert.yml b/.github/workflows/nightly-alert.yml
index eba810c07b..f998d3adf1 100644
--- a/.github/workflows/nightly-alert.yml
+++ b/.github/workflows/nightly-alert.yml
@@ -52,7 +52,8 @@ jobs:
(github.event_name == 'workflow_run' &&
github.event.workflow_run.head_repository.full_name == github.repository &&
github.event.workflow_run.head_branch == 'main' &&
- contains(fromJSON('["success","failure"]'), github.event.workflow_run.conclusion) &&
+ contains(fromJSON('["success","failure","cancelled","timed_out"]'),
+ github.event.workflow_run.conclusion) &&
(github.event.workflow_run.event == 'schedule' ||
github.event.workflow_run.name == 'macOS main sweep'))
runs-on: ubuntu-latest
@@ -87,9 +88,28 @@ jobs:
about="The whole suite on macOS is red on main"
fi
case "$conclusion" in
- (success|failure) ;;
+ (success|failure|cancelled|timed_out) ;;
(*) echo "The $what ended as '$conclusion': nothing to record." | tee -a "$GITHUB_STEP_SUMMARY"; exit 0 ;;
esac
+ jobs_url="repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/jobs?per_page=100&filter=latest"
+ if [ "$label" = "nightly-ci" ] && [ "$conclusion" = "cancelled" ]; then
+ gate_conclusion="$(gh api "$jobs_url" --paginate \
+ --jq '.jobs[] | select(.name == "CI gate") | .conclusion' | head -n 1)"
+ if [ "$gate_conclusion" != "failure" ]; then
+ message="The nightly CI run ended cancelled without a failed CI gate: nothing to record."
+ echo "$message" | tee -a "$GITHUB_STEP_SUMMARY"
+ exit 0
+ fi
+ fi
+ if [ "$label" = "macos-main" ] && [ "$conclusion" = "cancelled" ]; then
+ failed_macos_job="$(gh api "$jobs_url" --paginate \
+ --jq '.jobs[] | select(.conclusion == "failure") | .name' | head -n 1)"
+ if [ -z "$failed_macos_job" ]; then
+ message="The macOS sweep ended cancelled without a failed job: nothing to record."
+ echo "$message" | tee -a "$GITHUB_STEP_SUMMARY"
+ exit 0
+ fi
+ fi
write() { if [ "$DRY_RUN" = "true" ]; then echo "dry run, not executed: gh $*"; else gh "$@"; fi; }
# The label lists issues without the search index, which lags behind
# a freshly created issue and would invite a duplicate.
@@ -110,7 +130,6 @@ jobs:
echo
echo "Failed jobs:"
echo
- jobs_url="repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/jobs?per_page=100&filter=latest"
failed="$(gh api "$jobs_url" --paginate --jq '.jobs[]
| select(.name != "CI gate" and (.conclusion == "failure" or .conclusion == "cancelled" or .conclusion == "timed_out"))
| "- [\(.name)](\(.html_url)) (\(.conclusion))"')"
diff --git a/tests/unit/ci/test_pipeline_audit.py b/tests/unit/ci/test_pipeline_audit.py
index c5bfc5d660..f45e0ee7e1 100644
--- a/tests/unit/ci/test_pipeline_audit.py
+++ b/tests/unit/ci/test_pipeline_audit.py
@@ -473,16 +473,28 @@ def test_a_red_nightly_reaches_someone_and_only_a_nightly_on_main_can_write_issu
assert alert["permissions"] == {}
job = alert["jobs"]["alert"]
assert job["permissions"] == {"actions": "read", "issues": "write"}
+ condition = " ".join(job["if"].split())
for clause in (
"github.event.workflow_run.event == 'schedule'",
"github.event.workflow_run.head_repository.full_name == github.repository",
"github.event.workflow_run.head_branch == 'main'",
+ (
+ 'contains(fromJSON(\'["success","failure","cancelled","timed_out"]\'), '
+ "github.event.workflow_run.conclusion)"
+ ),
):
- assert clause in job["if"], clause
+ assert clause in condition, clause
# No pull-request code runs next to the issue token.
assert all("uses" not in step for step in job["steps"])
script = job["steps"][0]["run"]
assert "label=nightly-ci" in script and "write issue close" in script
+ assert "(success|failure|cancelled|timed_out) ;;" in script
+ assert '[ "$label" = "nightly-ci" ] && [ "$conclusion" = "cancelled" ]' in script
+ assert 'select(.name == "CI gate") | .conclusion' in script
+ assert '[ "$gate_conclusion" != "failure" ]' in script
+ assert '[ "$label" = "macos-main" ] && [ "$conclusion" = "cancelled" ]' in script
+ assert '.jobs[] | select(.conclusion == "failure") | .name' in script
+ assert 'macOS sweep ended cancelled without a failed job' in script
assert '--label "$label"' in script
# A check by hand runs from main only, vets the run it is given like the
# event, and writes nothing unless the dry run is switched off.