Skip to content

✨ Auto-open GitHub issue when Coverage Suite tests fail#4353

Merged
clubanderson merged 1 commit intomainfrom
fix/test-failure-issues
Apr 2, 2026
Merged

✨ Auto-open GitHub issue when Coverage Suite tests fail#4353
clubanderson merged 1 commit intomainfrom
fix/test-failure-issues

Conversation

@clubanderson
Copy link
Copy Markdown
Collaborator

Summary

  • Adds auto-issue creation when test shards fail in the Coverage Suite
  • Uses test-failure label to deduplicate — comments on existing open issue instead of creating duplicates
  • Coverage still merges and badge updates regardless — the issue is for visibility

How it works

  1. After all shards complete, if any failed → check for existing open test-failure issue
  2. If one exists → add a comment with the run link
  3. If none exists → create a new issue with run link and coverage %
  4. Badge and coverage merge happen independently (not blocked)

Test plan

  • Workflow syntax is valid
  • Next Coverage Suite run with failures creates an issue
  • Subsequent runs comment on existing issue instead of duplicating

Adds a step that creates a GitHub issue with the `test-failure` label
when any test shard fails. Deduplicates by commenting on an existing
open issue instead of creating a new one each run.

Coverage is still merged and the badge updated regardless — the issue
provides visibility without blocking coverage reporting.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Copilot AI review requested due to automatic review settings April 2, 2026 23:25
@kubestellar-prow
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Apr 2, 2026
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 2, 2026

Deploy Preview for kubestellarconsole canceled.

Name Link
🔨 Latest commit 24212bb
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/69cefaff3de4370007ddba24

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

👋 Hey @clubanderson — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@kubestellar-prow kubestellar-prow bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 2, 2026
@clubanderson clubanderson merged commit bf47450 into main Apr 2, 2026
15 of 16 checks passed
@kubestellar-prow kubestellar-prow bot deleted the fix/test-failure-issues branch April 2, 2026 23:26
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

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

This PR enhances the Coverage Suite GitHub Actions workflow to automatically surface test shard failures by creating (or updating) a dedicated GitHub issue, improving visibility while still allowing coverage merge + badge update to proceed.

Changes:

  • Add an “Open issue for test failures” step that runs when any test shard fails.
  • Deduplicate via a test-failure label: comment on an existing open issue instead of creating duplicates.
  • Include the workflow run link (and coverage %) in the created issue body.

Comment on lines +263 to +268
per_page: 1,
});

if (existing.data.length > 0) {
// Add a comment to the existing issue instead of opening a new one
const issue = existing.data[0];
Copy link

Copilot AI Apr 2, 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. With the current logic, if a PR is labeled test-failure, the workflow may comment on that PR (or treat it as the dedupe target) instead of an issue. Filter out items with pull_request set, or switch to search.issuesAndPullRequests with is:issue is:open label:test-failure so dedupe targets only issues.

Suggested change
per_page: 1,
});
if (existing.data.length > 0) {
// Add a comment to the existing issue instead of opening a new one
const issue = existing.data[0];
per_page: 100,
});
const issue = existing.data.find((item) => !item.pull_request);
if (issue) {
// Add a comment to the existing issue instead of opening a new one

Copilot uses AI. Check for mistakes.
Comment on lines +258 to +298
const existing = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
labels: ISSUE_LABEL,
state: 'open',
per_page: 1,
});

if (existing.data.length > 0) {
// Add a comment to the existing issue instead of opening a new one
const issue = existing.data[0];
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: `Coverage Suite run [#${context.runNumber}](${runUrl}) also had test failures. Please investigate.`,
});
console.log(`Commented on existing issue #${issue.number}`);
} else {
// Create a new issue
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `🐛 Test failures in Coverage Suite run #${context.runNumber}`,
body: [
`## Test Failures Detected`,
``,
`One or more test shards failed in the [Coverage Suite run #${context.runNumber}](${runUrl}).`,
``,
`Coverage was still merged and the badge updated (currently **${{ steps.cov.outputs.pct }}%**), but the failing tests need attention.`,
``,
`### Action needed`,
`1. Check the [run logs](${runUrl}) for failing test files`,
`2. Determine if failures are test updates needed or potential regressions`,
`3. Fix and close this issue`,
``,
`_Auto-generated by Coverage Suite workflow_`,
].join('\n'),
labels: [ISSUE_LABEL],
});
console.log('Created new test-failure issue');
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

This step has no error handling around the GitHub API calls. If listing/creating the issue fails (token permissions, transient API error, missing label, etc.), the step will fail and the following "Fail if any shard failed" step will be skipped (since the job stops on the first failed step). Consider wrapping the issue/comment logic in a try/catch and only logging a warning on failure so the workflow reaches the final explicit failure step consistently.

Suggested change
const existing = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
labels: ISSUE_LABEL,
state: 'open',
per_page: 1,
});
if (existing.data.length > 0) {
// Add a comment to the existing issue instead of opening a new one
const issue = existing.data[0];
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: `Coverage Suite run [#${context.runNumber}](${runUrl}) also had test failures. Please investigate.`,
});
console.log(`Commented on existing issue #${issue.number}`);
} else {
// Create a new issue
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `🐛 Test failures in Coverage Suite run #${context.runNumber}`,
body: [
`## Test Failures Detected`,
``,
`One or more test shards failed in the [Coverage Suite run #${context.runNumber}](${runUrl}).`,
``,
`Coverage was still merged and the badge updated (currently **${{ steps.cov.outputs.pct }}%**), but the failing tests need attention.`,
``,
`### Action needed`,
`1. Check the [run logs](${runUrl}) for failing test files`,
`2. Determine if failures are test updates needed or potential regressions`,
`3. Fix and close this issue`,
``,
`_Auto-generated by Coverage Suite workflow_`,
].join('\n'),
labels: [ISSUE_LABEL],
});
console.log('Created new test-failure issue');
try {
const existing = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
labels: ISSUE_LABEL,
state: 'open',
per_page: 1,
});
if (existing.data.length > 0) {
// Add a comment to the existing issue instead of opening a new one
const issue = existing.data[0];
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: `Coverage Suite run [#${context.runNumber}](${runUrl}) also had test failures. Please investigate.`,
});
console.log(`Commented on existing issue #${issue.number}`);
} else {
// Create a new issue
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `🐛 Test failures in Coverage Suite run #${context.runNumber}`,
body: [
`## Test Failures Detected`,
``,
`One or more test shards failed in the [Coverage Suite run #${context.runNumber}](${runUrl}).`,
``,
`Coverage was still merged and the badge updated (currently **${{ steps.cov.outputs.pct }}%**), but the failing tests need attention.`,
``,
`### Action needed`,
`1. Check the [run logs](${runUrl}) for failing test files`,
`2. Determine if failures are test updates needed or potential regressions`,
`3. Fix and close this issue`,
``,
`_Auto-generated by Coverage Suite workflow_`,
].join('\n'),
labels: [ISSUE_LABEL],
});
console.log('Created new test-failure issue');
}
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
core.warning(`Failed to create or update test-failure issue: ${message}`);

Copilot uses AI. Check for mistakes.
Comment on lines +248 to +253
- name: Open issue for test failures
if: needs.test-shard.result == 'failure'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GIST_TOKEN }}
script: |
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The script uses github-token: ${{ secrets.GIST_TOKEN }} for issue/comment operations. For least privilege, it’s safer to use the workflow GITHUB_TOKEN for repo issue APIs (with permissions: issues: write) and reserve the PAT/gist token only for the gist update. This also avoids coupling issue automation to whatever scopes the gist token happens to have.

Copilot uses AI. Check for mistakes.
@clubanderson
Copy link
Copy Markdown
Collaborator Author

🔄 Auto-Applying Copilot Code Review

Copilot code review found 2 code suggestion(s) and 1 general comment(s).

@copilot Please apply all of the following code review suggestions:

  • .github/workflows/coverage-hourly.yml (line 268): per_page: 100, }); const issue = existing.data.find((ite...
  • .github/workflows/coverage-hourly.yml (line 298): try { const existing = await github.rest.issues.listForRepo({ ...

Also address these general comments:

  • .github/workflows/coverage-hourly.yml (line 253): The script uses github-token: ${{ secrets.GIST_TOKEN }} for issue/comment operations. For least privilege, it’s safer

Push all fixes in a single commit. Run cd web && npm run build && npm run lint before committing.


Auto-generated by copilot-review-apply workflow.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

Post-merge build verification passed

Both Go and frontend builds compiled successfully against merge commit bf474501834fb91a2167c694a16fcdfd86a32b20.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants