-
Notifications
You must be signed in to change notification settings - Fork 5
Fix PR Buildkite Detective for status/check_run failures #422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,8 +2,8 @@ | |||||||||||||||||
| # Edit gh-agent-workflows/pr-buildkite-detective/example.yml and run 'make compile' to regenerate. | ||||||||||||||||||
| name: Trigger PR Buildkite Detective | ||||||||||||||||||
| on: | ||||||||||||||||||
| workflow_run: | ||||||||||||||||||
| workflows: ["CI", "Build", "Test"] | ||||||||||||||||||
| status: | ||||||||||||||||||
| check_run: | ||||||||||||||||||
| types: [completed] | ||||||||||||||||||
|
|
||||||||||||||||||
| permissions: | ||||||||||||||||||
|
|
@@ -16,8 +16,8 @@ permissions: | |||||||||||||||||
| jobs: | ||||||||||||||||||
| run: | ||||||||||||||||||
| if: >- | ||||||||||||||||||
| github.event.workflow_run.conclusion == 'failure' && | ||||||||||||||||||
| toJSON(github.event.workflow_run.pull_requests) != '[]' | ||||||||||||||||||
| (github.event_name == 'status' && github.event.state == 'failure') || | ||||||||||||||||||
| (github.event_name == 'check_run' && github.event.check_run.conclusion == 'failure') | ||||||||||||||||||
|
Comment on lines
+19
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n .github/workflows/trigger-pr-buildkite-detective.ymlRepository: elastic/ai-github-actions Length of output: 1206 🏁 Script executed: # Find and read the downstream workflow
fd 'gh-aw-pr-buildkite-detective.lock.yml' --exec head -100 {}
echo "---- Search for Buildkite origin guards in all related files ----"
rg -n "context|app\.slug|buildkite" .github/workflows/ gh-agent-workflows/ | head -50Repository: elastic/ai-github-actions Length of output: 6752 🏁 Script executed: # Find the downstream workflow
find . -name "gh-aw-pr-buildkite-detective.lock.yml" -type f -exec cat -n {} \;
echo "---- Source example.yml ----"
cat -n gh-agent-workflows/pr-buildkite-detective/example.ymlRepository: elastic/ai-github-actions Length of output: 50381 🏁 Script executed: # Search for the pre_activation job and Buildkite origin checks
grep -n "pre_activation\|buildkite\|app\.slug\|status\.context" .github/workflows/gh-aw-pr-buildkite-detective.lock.yml | head -20
# Also check the source configuration
grep -rn "buildkite\|app\.slug\|status\.context" gh-agent-workflows/pr-buildkite-detective/Repository: elastic/ai-github-actions Length of output: 12962 🏁 Script executed: # Search for pre_activation job definition in trigger-pr-buildkite-detective.yml
sed -n '/^ pre_activation:/,/^ [a-z]/p' .github/workflows/trigger-pr-buildkite-detective.yml
# If not found, check if it's in a different location
grep -A 50 "pre_activation:" .github/workflows/trigger-pr-buildkite-detective.ymlRepository: elastic/ai-github-actions Length of output: 51 🏁 Script executed: # Read the full trigger workflow to see if there's a pre_activation job
cat .github/workflows/trigger-pr-buildkite-detective.ymlRepository: elastic/ai-github-actions Length of output: 1017 🏁 Script executed: # Extract the pre_activation job from the reusable workflow
grep -n "^ pre_activation:" .github/workflows/gh-aw-pr-buildkite-detective.lock.yml
# Get more context around it
sed -n '/^ pre_activation:/,/^ [a-zA-Z]/p' .github/workflows/gh-aw-pr-buildkite-detective.lock.yml | head -100Repository: elastic/ai-github-actions Length of output: 1085 Scope failure filter to Buildkite-originated events. At lines 19-20, this condition matches all failing Suggested condition update if: >-
- (github.event_name == 'status' && github.event.state == 'failure') ||
- (github.event_name == 'check_run' && github.event.check_run.conclusion == 'failure')
+ (github.event_name == 'status' &&
+ github.event.state == 'failure' &&
+ startsWith(github.event.context, 'buildkite/')) ||
+ (github.event_name == 'check_run' &&
+ github.event.check_run.conclusion == 'failure' &&
+ github.event.check_run.app.slug == 'buildkite')📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| uses: ./.github/workflows/gh-aw-pr-buildkite-detective.lock.yml | ||||||||||||||||||
| with: | ||||||||||||||||||
| buildkite-org: "elastic" | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
GitHub Actions expressions syntax operators && || ternary official documentation💡 Result:
!, comparison ops (< <= > >= == !=), logical&&(and) and||(or), plus grouping/index/property (( ),[ ],.). [1]cond ? a : b) support: GitHub Actions expression syntax does not include a ternary operator in the official operator list. [1] A long-running feature request explicitly asks for ternary/conditional support, indicating it’s not currently available. [2]${{ condition && 'trueValue' || 'falseValue' }}(works as long as'trueValue'is truthy). [1]Sources
[1] GitHub Docs — Evaluate expressions in workflows and actions (Operators table) (docs.github.com)
[2] GitHub actions/runner issue
#409— Conditional operator or function for expression syntax (github.com)Citations:
Reconsider the proposed alternative—ternary operators are not supported in GitHub Actions expressions.
The chained
&&and||operators in these expressions are officially documented and the standard workaround pattern for conditional logic in GitHub Actions. However, your underlying concerns about edge cases are valid:github.event.idwhen the event is'check_run'(where this property doesn't exist) relies on GitHub's handling of undefined properties.github.event.idexists but is falsy (0, empty string), the expression will incorrectly fall back togithub.event.check_run.id.The ternary operator (
? :) is not supported in GitHub Actions expressions—this is a long-running open feature request. Instead, consider:ifstatements to process each event type separately🧰 Tools
🪛 LanguageTool
[uncategorized] ~102-~102: The official name of this software platform is spelled with a capital “H”.
Context: ...hub.repository }} - Event Name: ${{ github.event_name }} - Event ID: ${{ githu...
(GITHUB)
[uncategorized] ~103-~103: The official name of this software platform is spelled with a capital “H”.
Context: ...ithub.event_name }} - Event ID: ${{ github.event_name == 'status' && github.event....
(GITHUB)
[uncategorized] ~103-~103: The official name of this software platform is spelled with a capital “H”.
Context: ...*: ${{ github.event_name == 'status' && github.event.id || github.event.check_run.id }...
(GITHUB)
[uncategorized] ~103-~103: The official name of this software platform is spelled with a capital “H”.
Context: ..._name == 'status' && github.event.id || github.event.check_run.id }} - **Failure State...
(GITHUB)
[uncategorized] ~104-~104: The official name of this software platform is spelled with a capital “H”.
Context: ...heck_run.id }} - Failure State: ${{ github.event_name == 'status' && github.event....
(GITHUB)
[uncategorized] ~104-~104: The official name of this software platform is spelled with a capital “H”.
Context: ...*: ${{ github.event_name == 'status' && github.event.state || github.event.check_run.c...
(GITHUB)
[uncategorized] ~104-~104: The official name of this software platform is spelled with a capital “H”.
Context: ...me == 'status' && github.event.state || github.event.check_run.conclusion }} - **Commi...
(GITHUB)
[uncategorized] ~105-~105: The official name of this software platform is spelled with a capital “H”.
Context: ...run.conclusion }} - Commit SHA: ${{ github.event_name == 'status' && github.event....
(GITHUB)
[uncategorized] ~105-~105: The official name of this software platform is spelled with a capital “H”.
Context: ...*: ${{ github.event_name == 'status' && github.event.sha || github.event.check_run.hea...
(GITHUB)
[uncategorized] ~105-~105: The official name of this software platform is spelled with a capital “H”.
Context: ...name == 'status' && github.event.sha || github.event.check_run.head_sha }} - **Buildki...
(GITHUB)
🤖 Prompt for AI Agents