Add notify-failure job to cgo.yml for CGO failure tracking#28613
Add notify-failure job to cgo.yml for CGO failure tracking#28613
Conversation
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/0d7ecc2d-de95-4c42-babf-c30c875946ae Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
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-failurejob that runs after all existing CGO jobs (needs) and only onrefs/heads/main. - Use
actions/github-scriptto detect failedneedsjobs 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
| 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 }); |
There was a problem hiding this comment.
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.
| 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}`); |
|
|
||
| if (existingIssues.data.length > 0) { | ||
| core.info(`Existing CGO failure issue #${existingIssues.data[0].number} is still open. Skipping.`); |
There was a problem hiding this comment.
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.
| 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.`); |
Summary
Adds a
notify-failurejob to.github/workflows/cgo.ymlthat automatically creates a GitHub issue when any CGO job fails on themainbranch.Changes
notify-failurejob at the end ofcgo.ymlwith:if: always() && github.ref == 'refs/heads/main'— runs after all other jobs, only on the main branchneedslisting all 16 existing jobs so it runs lastpermissions: issues: writefor issue creationactions/github-scriptstep that:needscontextcgo-failurelabel — skips creation if one exists (deduplication)cookieandcgo-failureif they don't yet exist[CGO] Workflow failure on main - Run #Nwith:cookie(for agent investigation) +cgo-failure(for deduplication)