8000 feat(ci): alert repository owners via GitHub issue on nightly test failure by janzak-dev · Pull Request #884 · google/xmc · GitHub
[go: up one dir, main page]

Skip to content

feat(ci): alert repository owners via GitHub issue on nightly test failure - #884

Merged
janzak-dev merged 10 commits into
mainfrom
feat/nightly-failure-owners-alert
Sep 15, 2026
Merged

janzak-dev merged 10 commits into
mainfrom
feat/nightly-failure-owners-alert

Conversation

@janzak-dev
@janzak-dev janzak-dev commented Sep 15, 2026 •
Copy link
Copy Markdown
Collaborator

Summary

Adds an automated failure reporting and alerting mechanism to the nightly test suite workflow (nightly-test-suite.yml). When any nightly workflow job fails, GitHub Actions automatically resolves active repository owners from OWNERS (excluding any absent members listed in ABSENCE.md), searches for open nightly-failure issues to prevent notification spam, and either creates a new issue or posts a recurring failure comment pinging all active owners.

Motivation & Context

Nightly test suite runs (such as the demo workload verification against the xmc-nightly deployment) run asynchronously on a cron schedule. When infrastructure or reconciliation failures occur (e.g. WorkUnits stuck in STARTING or cluster timeouts), there was previously no proactive notification mechanism alerting repository maintainers. Maintainers had to manually inspect GitHub Actions run history to discover breakages.

Key Changes

  • Alerting Script (.github/scripts/nightly-failure-alert.js):
    • Pure parsing functions parseUsernames and filterActiveOwners to extract candidate usernames from OWNERS and filter out members from ABSENCE.md (case-insensitive).
    • Pure markdown formatting functions formatFailureIssueBody and formatRecurringCommentBody producing structured tables with commit SHA, workflow run link, Experiment XID, and @owner mentions.
    • Idempotent GitHub REST API orchestrator: checks for existing open issues labeled nightly-failure to append a recurrence comment instead of creating duplicate issues.
  • Unit Tests (.github/scripts/nightly-failure-alert.test.js):
    • 11 unit test assertions verifying username parsing, markdown bullet cleaning, absence filtering, comment/issue markdown formatting, and mock GitHub API interactions with generic placeholder fixtures.
  • Workflow Update (.github/workflows/nightly-test-suite.yml):
    • Added Job 3 report-nightly-failure (3. Report Failure & Alert OWNERS) configured with if: always() && (needs.trigger-demo-workload.result == 'failure' || needs.validate-workload-results.result == 'failure') and permissions: issues: write.

Example Alert Issue

  • Example Issue: See google/xmc#885 for an example of the created alert issue and recurring failure comment.

Assumptions

None — requirements were fully specified.

Verification & Testing

  • Unit Tests:
    • Executed node --test .github/scripts/nightly-failure-alert.test.js (11/11 tests passing).
    • Executed node --test .github/scripts/*.test.js (141/141 total repository script tests passing).
  • Pre-Commit Checks:
    • Ran ./.githooks/pre-commit (Buildifier, gofmt, golangci-lint, determinism check, and addlicense all passed cleanly).
  • Diff Sizing Check:
    • Ran ./tools/analyze_diff_size.py --base-ref origin/main... (within thresholds, no split required).

Related Issues / Bugs

N/A

TAG=agy
CONV=acf882de-1561-404c-ba2e-ae0940451165

…ilure

Add automated alerting step in nightly test suite workflow that:
- Reads OWNERS and ABSENCE.md to resolve active owners
- Comments on existing open 'nightly-failure' issue or creates a new issue
- Mentions active owners with failure metadata and logs link

TAG=agy
CONV=acf882de-1561-404c-ba2e-ae0940451165
@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new GitHub Actions script nightly-failure-alert.js and its corresponding test suite to automate alerting on nightly test failures. The script parses owners and absences, formats markdown alerts, and manages GitHub issues. Feedback on the implementation includes ensuring that pull requests are filtered out when querying for existing issues, safely handling cases where NEEDS_CONTEXT parses to null, and wrapping test executions in try...finally blocks to guarantee cleanup of temporary directories and environment variables.

TAG=agy
CONV=acf882de-1561-404c-ba2e-ae0940451165
TAG=agy
CONV=acf882de-1561-404c-ba2e-ae0940451165
TAG=agy
CONV=acf882de-1561-404c-ba2e-ae0940451165
TAG=agy
CONV=acf882de-1561-404c-ba2e-ae0940451165
TAG=agy
CONV=acf882de-1561-404c-ba2e-ae0940451165
…tests

- Safely access needsContext properties with optional chaining
- Filter out pull requests when querying existing open nightly-failure issues
- Wrap unit test orchestrator logic in try...finally for deterministic cleanup

TAG=agy
CONV=acf882de-1561-404c-ba2e-ae0940451165
…ctions

Enforce single responsibility principle and 20-30 line function limit:
- Extract resolveActiveOwners, lookupAssociatedPullRequest, findExistingNightlyFailureIssue, postOrUpdateAlertIssue, and parseNeedsContext
- Keep main run orchestrator concise and linear

TAG=agy
CONV=acf882de-1561-404c-ba2e-ae0940451165
Add dedicated test suites for all decomposed functions in nightly-failure-alert.js:
- resolveActiveOwners: file reading & missing file handling
- lookupAssociatedPullRequest: PR resolution, empty results, and rate limit error safety
- findExistingNightlyFailureIssue: PR exclusion filtering and network error handling
- postOrUpdateAlertIssue: comment creation vs new issue creation
- parseNeedsContext: valid JSON parsing and invalid JSON fallback

TAG=agy
CONV=acf882de-1561-404c-ba2e-ae0940451165
@janzak-dev
janzak-dev marked this pull request as ready for review September 15, 2026 10:08
@janzak-dev janzak-dev added the priority::2-high top of mind. should not wait. label Sep 15, 2026
andrzejfudro
andrzejfudro previously approved these changes Sep 15, 2026
@janzak-dev
janzak-dev added this pull request to the merge queue Sep 15, 2026
Merged via the queue into main with commit 8cd9c5e Sep 15, 2026
11 checks passed
@janzak-dev
janzak-dev deleted the feat/nightly-failure-owners-alert branch September 15, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority::2-high top of mind. should not wait.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0