Skip to content

Add notify-failure job to cgo.yml for CGO failure tracking#28613

Merged
pelikhan merged 1 commit intomainfrom
copilot/add-cgo-failed-job-scanner
Apr 26, 2026
Merged

Add notify-failure job to cgo.yml for CGO failure tracking#28613
pelikhan merged 1 commit intomainfrom
copilot/add-cgo-failed-job-scanner

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 26, 2026

Summary

Adds a notify-failure job to .github/workflows/cgo.yml that automatically creates a GitHub issue when any CGO job fails on the main branch.

Changes

  • Added notify-failure job at the end of cgo.yml with:
    • if: always() && github.ref == 'refs/heads/main' — runs after all other jobs, only on the main branch
    • needs listing all 16 existing jobs so it runs last
    • permissions: issues: write for issue creation
    • Single actions/github-script step that:
      1. Collects all failed jobs from the needs context
      2. Skips if no jobs failed
      3. Checks for an existing open issue with cgo-failure label — skips creation if one exists (deduplication)
      4. Creates labels cookie and cgo-failure if they don't yet exist
      5. Creates an issue titled [CGO] Workflow failure on main - Run #N with:
        • Table of run metadata (run ID, commit SHA, expiry time)
        • List of failed job names
        • Expiration timestamp set to 4 hours from issue creation time
        • Labels: cookie (for agent investigation) + cgo-failure (for deduplication)

Copilot AI requested a review from pelikhan April 26, 2026 16:45
@pelikhan pelikhan marked this pull request as ready for review April 26, 2026 16:58
Copilot AI review requested due to automatic review settings April 26, 2026 16:58
@pelikhan pelikhan merged commit 9968781 into main Apr 26, 2026
20 checks passed
@pelikhan pelikhan deleted the copilot/add-cgo-failed-job-scanner branch April 26, 2026 16:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds automated failure tracking to the CGO GitHub Actions workflow by creating an issue on main when any upstream CGO job fails, with basic deduplication via a cgo-failure label.

Changes:

  • Add a notify-failure job that runs after all existing CGO jobs (needs) and only on refs/heads/main.
  • Use actions/github-script to detect failed needs jobs and create/deduplicate a labeled GitHub issue.
  • Ensure required labels (cookie, cgo-failure) exist before issue creation.
Show a summary per file
File Description
.github/workflows/cgo.yml Adds a post-workflow notification job that opens a deduplicated issue when CGO jobs fail on main.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 2

Comment thread .github/workflows/cgo.yml
await github.rest.issues.getLabel({ owner: context.repo.owner, repo: context.repo.repo, name: label });
} catch (e) {
if (e.status === 404) {
await github.rest.issues.createLabel({ owner: context.repo.owner, repo: context.repo.repo, name: label, color });
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

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

The getLabel error handling only creates labels on 404, but silently ignores any other API error (rate limit, permissions, transient failures). This can hide the root cause and lead to a later, harder-to-diagnose failure when creating the issue with missing labels. Re-throw or core.setFailed for non-404 errors so the workflow fails with a clear reason.

Suggested change
await github.rest.issues.createLabel({ owner: context.repo.owner, repo: context.repo.repo, name: label, color });
await github.rest.issues.createLabel({ owner: context.repo.owner, repo: context.repo.repo, name: label, color });
} else {
throw new Error(`Failed to verify label "${label}": ${e.message}`);

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/cgo.yml
Comment on lines +1736 to +1738

if (existingIssues.data.length > 0) {
core.info(`Existing CGO failure issue #${existingIssues.data[0].number} is still open. Skipping.`);
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

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

github.rest.issues.listForRepo returns both issues and pull requests. If a PR is ever labeled cgo-failure, this deduplication check will incorrectly suppress issue creation. Filter out items with the pull_request field (or use a search query that excludes PRs) before deciding to skip creating a new issue.

Suggested change
if (existingIssues.data.length > 0) {
core.info(`Existing CGO failure issue #${existingIssues.data[0].number} is still open. Skipping.`);
const existingOpenIssues = existingIssues.data.filter(item => !item.pull_request);
if (existingOpenIssues.length > 0) {
core.info(`Existing CGO failure issue #${existingOpenIssues[0].number} is still open. Skipping.`);

Copilot uses AI. Check for mistakes.
@github-actions github-actions Bot mentioned this pull request Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants