Skip to content

github-actions: report flaky tests as GH issues#49778

Open
v1v wants to merge 1 commit intoelastic:mainfrom
v1v:feature/support-flaky-test-report
Open

github-actions: report flaky tests as GH issues#49778
v1v wants to merge 1 commit intoelastic:mainfrom
v1v:feature/support-flaky-test-report

Conversation

@v1v
Copy link
Copy Markdown
Member

@v1v v1v commented Mar 30, 2026

Proposed commit message

Automate the BK Test Result reporting to GH issues.

Then agentic workflows can triage and plan accordingly

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works. Where relevant, I have used the stresstest.sh script to run them under stress conditions and race detector to verify their stability.
  • I have added an entry in ./changelog/fragments using the changelog tool.

Disruptive User Impact

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Requires elastic/oblt-actions#536

Use cases

Screenshots

Logs

@v1v v1v self-assigned this Mar 30, 2026
@v1v v1v requested a review from a team as a code owner March 30, 2026 13:24
@v1v v1v added backport-skip Skip notification from the automated backport with mergify skip-changelog labels Mar 30, 2026
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Mar 30, 2026
@botelastic
Copy link
Copy Markdown

botelastic bot commented Mar 30, 2026

This pull request doesn't have a Team:<team> label.

@github-actions
Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

Introduces a new GitHub Actions workflow file (buildkite-test-flaky.yml) that executes on a scheduled basis on weekdays at 11:00 UTC and supports manual triggering. The workflow runs a single job on ubuntu-latest that checks out the repository, generates a GitHub token using elastic/oblt-actions, and invokes the elastic/oblt-actions/buildkite/flaky-report action. The action is configured to analyze test results from a one-day window for the beats test suite, create or update issues labeled for flaky tests, and limit concurrent issues to a maximum of five.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/buildkite-test-flaky.yml (1)

26-26: Consider if max-issues: '5' is sufficient.

With daily execution and a 1-day analysis window, limiting to 5 concurrent issues may be restrictive if multiple tests are flaky. Consider whether this threshold aligns with expected flaky test frequency.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/buildkite-test-flaky.yml at line 26, The current GitHub
Action configuration sets max-issues: '5' which may be too low for daily runs
with a 1-day analysis window; update the max-issues setting (the max-issues: '5'
entry) to a higher or configurable value that matches expected flaky test volume
(e.g., increase the numeric limit, make it an environment/variable, or remove
the hard cap) so the workflow can surface all relevant flaky-test issues instead
of being limited to five.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/buildkite-test-flaky.yml:
- Around line 7-8: Workflow lacks the required GitHub permission for issue
management which causes authorization failures when the flaky-report action
creates/updates issues; update the permissions mapping to include issues: write
alongside contents: read so the action can create/update issues. Edit the
permissions block (the top-level permissions key) and add an entry "issues:
write" (or change permissions to "contents: read" and "issues: write") so the
flaky-report action has write access; ensure no other permission scopes are
unnecessarily broadened and keep the action name "flaky-report" in mind when
verifying the fix.

---

Nitpick comments:
In @.github/workflows/buildkite-test-flaky.yml:
- Line 26: The current GitHub Action configuration sets max-issues: '5' which
may be too low for daily runs with a 1-day analysis window; update the
max-issues setting (the max-issues: '5' entry) to a higher or configurable value
that matches expected flaky test volume (e.g., increase the numeric limit, make
it an environment/variable, or remove the hard cap) so the workflow can surface
all relevant flaky-test issues instead of being limited to five.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 62ad4081-b814-4075-b052-319079aabc0c

📥 Commits

Reviewing files that changed from the base of the PR and between e92763f and 0021883.

📒 Files selected for processing (1)
  • .github/workflows/buildkite-test-flaky.yml

Comment on lines +7 to +8
permissions:
contents: read
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Mar 30, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Missing issues: write permission.

The workflow creates/updates GitHub issues but only has contents: read permission. This will cause authorization failures when the flaky-report action attempts to create or update issues.

🔐 Proposed fix
 permissions:
   contents: read
+  issues: write
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
permissions:
contents: read
permissions:
contents: read
issues: write
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/buildkite-test-flaky.yml around lines 7 - 8, Workflow
lacks the required GitHub permission for issue management which causes
authorization failures when the flaky-report action creates/updates issues;
update the permissions mapping to include issues: write alongside contents: read
so the action can create/update issues. Edit the permissions block (the
top-level permissions key) and add an entry "issues: write" (or change
permissions to "contents: read" and "issues: write") so the flaky-report action
has write access; ensure no other permission scopes are unnecessarily broadened
and keep the action name "flaky-report" in mind when verifying the fix.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's incorrect, we use elastic/oblt-actions/github/create-token@v1 to get the ephemeral github tokens, that's used as an output

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@v1v, you're right — my mistake. The elastic/oblt-actions/github/create-token@v1 action generates an ephemeral GitHub App token with its own scopes/permissions, and that token's output is what's passed to flaky-report for issue management. The workflow-level permissions block only governs the default GITHUB_TOKEN, which isn't used for the issue operations here. No change needed.


✏️ Learnings added
Learnt from: v1v
Repo: elastic/beats PR: 49778
File: .github/workflows/buildkite-test-flaky.yml:7-8
Timestamp: 2026-03-30T17:42:57.640Z
Learning: In elastic/beats (and related elastic repos), workflows that use `elastic/oblt-actions/github/create-tokenv1` to generate an ephemeral GitHub App token do NOT need `issues: write` (or other elevated permissions) in the workflow-level `permissions` block. The ephemeral token carries its own permissions and is passed as a step output to downstream actions (e.g., `elastic/oblt-actions/buildkite/flaky-report`) for operations like creating/updating GitHub issues. The workflow-level `permissions` block only governs the default `GITHUB_TOKEN`.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: andrewkroh
Repo: elastic/beats PR: 0
File: :0-0
Timestamp: 2026-03-19T14:51:00.057Z
Learning: In the elastic/beats repository, always check that a PR includes a changelog fragment file in the `changelog/fragments/` directory. This applies to any PR that introduces features, bug fixes, or enhancements. The fragment is a YAML file created via `elastic-agent-changelog-tool new "Brief description"` and must contain:
- `kind`: type of change (e.g., `bug-fix`, `enhancement`, `feature`)
- `summary`: short user-facing description
- `component`: affected component (e.g., `filebeat`, `metricbeat`, `libbeat`)
- `issue`: (optional) URL to the related GitHub issue

The tool is installed with: `go install github.com/elastic/elastic-agent-changelog-toollatest`

Reference: docs/extend/index.md line 22.

github-label: "flaky-test"
github-repo: ${{ github.repository }}
github-token: ${{ steps.fetch-token.outputs.token }}
max-issues: '5'
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

report up to 5 unique Test Flakies that happened in the last day.

@v1v v1v requested a review from mauri870 March 30, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-skip Skip notification from the automated backport with mergify needs_team Indicates that the issue/PR needs a Team:* label skip-changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant