Skip to content

fix(ci): find PR by author instead of branch name for downstream triggers#451

Merged
github-actions[bot] merged 4 commits intodevfrom
opencode/shiny-otter
Apr 11, 2026
Merged

fix(ci): find PR by author instead of branch name for downstream triggers#451
github-actions[bot] merged 4 commits intodevfrom
opencode/shiny-otter

Conversation

@MichaelFisher1997
Copy link
Copy Markdown
Collaborator

Problem

The Trigger downstream workflows step in opencode-test-writer.yml was searching for PRs by exact branch name (test/MODULE), but the opencode action auto-creates branches with names like opencode/schedule-XXX. This caused the lookup to always return "No PR found" and downstream build/review workflows were never triggered.

Additionally, the opencode action doesn't add the automated-test label to PRs it creates, so label-based filtering also failed.

Fix

Splits the trigger step into two:

  1. Find and label created PR — queries for the most recent open PR authored by the PAT user, then adds the automated-test label
  2. Trigger downstream workflows — uses the discovered PR number to trigger build.yml and opencode-pr.yml

This was the root cause of PR #450 getting no build or review triggered.

…gers

The opencode action auto-creates branches with names like
opencode/schedule-XXX, not test/MODULE. The old trigger step searched
for PRs by branch name which never matched. Now finds the PR by PAT
author, labels it, then triggers build and review workflows.
@github-actions github-actions bot added documentation Improvements or additions to documentation ci labels Apr 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📋 Summary

This PR fixes a CI workflow bug where downstream build.yml and opencode-pr.yml workflows were never being triggered for automated test PRs. The issue was that the workflow searched for PRs by exact branch name (test/MODULE) and by automated-test label, but opencode auto-creates branches with names like opencode/schedule-XXX and doesn't add labels automatically.

Linked Issues: Mentions PR #450 as the root cause (no linked issue number).

Scope: This is a single-file change to .github/workflows/opencode-test-writer.yml, splitting one step into two for proper PR discovery and labeling.


🔴 Critical Issues (Must Fix - Blocks Merge)

None identified.

All previously reported critical issues have been resolved. (No previous automated reviews exist for this PR.)


⚠️ High Priority Issues (Should Fix)

None identified.


💡 Medium Priority Issues (Nice to Fix)

[MEDIUM] .github/workflows/opencode-test-writer.yml:231 - Race condition with sleep 5
Confidence: Medium
Description: The step uses sleep 5 before querying for the PR. This is a fragile workaround for a potential race condition where the PR may not be created yet. GitHub API latency can exceed 5 seconds under load.
Impact: The "Find and label created PR" step could still fail to find the PR if GitHub is slow, causing downstream workflows to never trigger.
Suggested Fix: Consider replacing sleep 5 with a polling loop that retries the PR query a few times with exponential backoff, or at least increase to sleep 10 and add a comment explaining why.


ℹ️ Low Priority Suggestions (Optional)

[LOW] .github/workflows/opencode-test-writer.yml:237 - Query returns 10 PRs but sorts by createdAt desc
Confidence: Low
Description: The --limit 10 combined with sorting by createdAt in reverse order should reliably find the most recent PR, but if the PAT user has many open PRs (10+), older ones could be missed. Unlikely in practice since the PAT is likely dedicated to this automation.
Impact: None - extremely unlikely scenario.


📊 SOLID Principles Score

N/A - This PR modifies YAML GitHub Actions configuration, not software code. SOLID principles do not apply to workflow files.

Principle Score Notes
Single Responsibility N/A YAML configuration
Open/Closed N/A
Liskov Substitution N/A
Interface Segregation N/A
Dependency Inversion N/A
Average N/A

🎯 Final Assessment

Overall Confidence Score: 87%

How to interpret:

  • 61-80%: Minor concerns, mostly ready with some fixes
  • 81-100%: High confidence, ready to merge or with trivial fixes

Confidence Breakdown:

  • Code Quality: 95% - The workflow changes are syntactically correct YAML with proper GitHub Actions expressions and outputs
  • Completeness: 85% - Fixes the described problem, but the sleep 5 race condition is a minor gap
  • Risk Level: 90% - Very low risk; only affects CI workflow, no application code changes
  • Test Coverage: N/A - No application code to test; manual verification via the fix's own execution is the test

Merge Readiness:

  • All critical issues resolved
  • SOLID average score >= 6.0 (N/A - workflow YAML)
  • Overall confidence >= 60%
  • No security concerns (uses secrets properly, limited scope)
  • Tests present and passing (N/A - CI fix; will be validated on merge)

Verdict:

MERGE - The fix correctly addresses the root cause by querying PRs by author instead of branch name, and properly labels the PR for downstream workflow triggering. The sleep 5 race condition is a minor concern that can be addressed in a follow-up if it proves problematic.


{
  "reviewed_sha": "4c8902d608f0515b635c6d9a5abb5b6062d151a8",
  "critical_issues": 0,
  "high_priority_issues": 0,
  "medium_priority_issues": 1,
  "overall_confidence_score": 87,
  "recommendation": "MERGE"
}

New%20session%20-%202026-04-11T14%3A13%3A02.035Z
opencode session  |  github run

Replace fragile sleep 5 with up to 5 retries at increasing intervals
(3s, 6s, 9s, 12s, 15s) to handle GitHub API latency.
@github-actions
Copy link
Copy Markdown
Contributor

📋 Summary

PR #451 fixes a CI workflow bug in .github/workflows/opencode-test-writer.yml where downstream build.yml and opencode-pr.yml workflows were never being triggered for automated test PRs. The fix splits one step into two: (1) find and label the PR by author lookup with retry logic, then (2) trigger downstream workflows using the discovered PR number.

Linked Issues: Mentions PR #450 as the root cause but does not link with "Closes #450".


🔴 Critical Issues (Must Fix - Blocks Merge)

None identified.

All previously reported critical issues have been resolved. (No previous automated reviews for this PR.)


⚠️ High Priority Issues (Should Fix)

None identified.


💡 Medium Priority Issues (Nice to Fix)

[MEDIUM] .github/workflows/opencode-test-writer.yml:237 - Exponential backoff sleep 3/6/9/12/15 may still miss PRs under heavy load
Confidence: Medium
Description: The polling loop with exponential backoff (3s, 6s, 9s, 12s, 15s = max 45s wait) is a significant improvement over the original sleep 5, but GitHub API latency under sustained load or during incidents could still exceed this window.
Impact: "Find and label created PR" step could still fail to find the PR, though with lower probability than before.
Suggested Fix: Consider increasing max attempts to 6-8, or adding a comment that explains the retry budget and when to adjust it.


ℹ️ Low Priority Suggestions (Optional)

[LOW] .github/workflows/opencode-test-writer.yml:237 - --limit 10 may miss oldest PR if PAT has many open PRs
Confidence: Low
Description: Same as previous review - if the PAT user has more than 10 open PRs, the createdAt sort should still surface the newest, but the --limit 10 combined with reverse | .[0] means only the most recent 10 are considered.
Impact: Extremely unlikely to cause issues in practice.


📊 SOLID Principles Score

N/A - This PR modifies YAML GitHub Actions configuration, not software code. SOLID principles do not apply to workflow files.

Principle Score Notes
Single Responsibility N/A YAML configuration
Open/Closed N/A
Liskov Substitution N/A
Interface Segregation N/A
Dependency Inversion N/A
Average N/A

🎯 Final Assessment

Overall Confidence Score: 90%

How to interpret:

  • 81-100%: High confidence, ready to merge or with trivial fixes

Confidence Breakdown:

  • Code Quality: 95% - Syntactically correct YAML, proper GitHub Actions expressions, correct use of --jq filters and $GITHUB_OUTPUT
  • Completeness: 88% - Fixes the core problem (PR lookup by author + labeling); retry loop addresses the previous race condition
  • Risk Level: 95% - Very low risk; only affects CI, no application code
  • Test Coverage: N/A - CI workflow; validated on merge

Merge Readiness:

  • All critical issues resolved
  • SOLID average score >= 6.0 (N/A - workflow YAML)
  • Overall confidence >= 60%
  • No security concerns
  • Tests present and passing (N/A - CI fix)

Verdict:

MERGE - The fix properly addresses the root cause by querying PRs by author instead of branch name, adds proper retry logic with exponential backoff, and correctly labels the PR for downstream workflow triggering.

{
  "reviewed_sha": "1faf6954320b8fc104cf7a07db169f8578a173ea",
  "critical_issues": 0,
  "high_priority_issues": 0,
  "medium_priority_issues": 1,
  "overall_confidence_score": 90,
  "recommendation": "MERGE"
}

New%20session%20-%202026-04-11T14%3A34%3A47.280Z
opencode session  |  github run

@github-actions
Copy link
Copy Markdown
Contributor

📋 Summary

PR #451 fixes a CI workflow bug where downstream build.yml and opencode-pr.yml workflows were never being triggered for automated test PRs created by the opencode action. The fix splits the original single step into two: (1) find and label the PR by author lookup with 8-attempt retry loop and exponential backoff, then (2) trigger downstream workflows using the discovered PR number.

Linked Issues: Mentions PR #450 as root cause but does not link with "Closes #450".


🔴 Critical Issues (Must Fix - Blocks Merge)

None identified.

All previously reported critical issues have been resolved. (No critical issues were ever reported for this PR.)


⚠️ High Priority Issues (Should Fix)

None identified.


💡 Medium Priority Issues (Nice to Fix)

[MEDIUM] .github/workflows/opencode-test-writer.yml:240-245 - Filter by --base dev only, but check-existing step also queries across default branch
Confidence: Low
Description: The find-pr step filters PRs by --base dev, but the check-existing step at line 157 uses ${{ github.event.repository.default_branch }} which resolves to dev on this repo. Since opencode always targets dev as base, this is consistent, but the dual use of hardcoded dev vs variable reference is slightly confusing.
Impact: Minor maintainability concern only.
Suggested Fix: Consider extracting dev to an output variable in select-module step for consistency.


ℹ️ Low Priority Suggestions (Optional)

[LOW] .github/workflows/opencode-test-writer.yml:237 - Retry loop uses hardcoded 8 attempts
Confidence: Low
Description: While the comment explains the retry budget (~108s max wait), the loop uses for i in 1 2 3 4 5 6 7 8 instead of a configurable variable. If the retry budget needs adjustment in the future, every instance must be updated manually.
Impact: None - already documented in comment.

[LOW] .github/workflows/opencode-test-writer.yml:252 - Label addition could silently fail
Confidence: Low
Description: If gh pr edit fails (e.g., label already exists or API error), the step continues without error but the label won't be added. The step will still output pr_number and downstream workflows will trigger.
Impact: Downstream workflows trigger but PR may not have the automated-test label, causing future runs to re-use check-existing label lookup and potentially find this PR again.


📊 SOLID Principles Score

N/A - This PR modifies YAML GitHub Actions configuration, not software code. SOLID principles do not apply to workflow files.

Principle Score Notes
Single Responsibility N/A YAML configuration
Open/Closed N/A
Liskov Substitution N/A
Interface Segregation N/A
Dependency Inversion N/A
Average N/A

🎯 Final Assessment

Overall Confidence Score: 93%

How to interpret:

  • 81-100%: High confidence, ready to merge or with trivial fixes

Confidence Breakdown:

  • Code Quality: 95% - Syntactically correct YAML, proper GitHub Actions expressions, correct --jq filters and $GITHUB_OUTPUT
  • Completeness: 92% - Fixes the core problem (PR lookup by author instead of branch name); retry loop with exponential backoff addresses previous race condition concerns
  • Risk Level: 95% - Very low risk; only affects CI, no application code
  • Test Coverage: N/A - CI workflow; validated on merge

Merge Readiness:

  • All critical issues resolved
  • SOLID average score >= 6.0 (N/A - workflow YAML)
  • Overall confidence >= 60%
  • No security concerns
  • Tests present and passing (N/A - CI fix)

Verdict:

MERGE - The fix correctly addresses the root cause by querying PRs by author instead of branch name, adds robust retry logic with exponential backoff (8 attempts, ~108s max wait), and properly labels the PR for downstream workflow triggering. All medium priority concerns from previous reviews have been adequately addressed.


{
  "reviewed_sha": "d31a00353f5f66aa4f3fe14d4726f59efc6c3b8e",
  "critical_issues": 0,
  "high_priority_issues": 0,
  "medium_priority_issues": 1,
  "overall_confidence_score": 93,
  "recommendation": "MERGE"
}

New%20session%20-%202026-04-11T14%3A40%3A08.665Z
opencode session  |  github run

…e retries

- Add base_branch output to select-module step, replace all hardcoded
  dev and github.event.repository.default_branch references
- Extract MAX_RETRIES variable for single-point adjustment
- Guard gh pr edit failure with warning annotation
@github-actions
Copy link
Copy Markdown
Contributor

Based on the provided context and the diff, let me analyze the current state of PR #451.

Previous Automated Reviews Analysis:

The previous reviews identified:

  1. Medium (First review): sleep 5 race condition → Fixed by polling loop with exponential backoff (8 attempts, 3s increments)
  2. Medium (Second review): Retry loop may still miss PRs under heavy load → Fixed by using 8 retries with exponential backoff
  3. Medium (Third review): --base dev hardcoded vs variable reference → Partially addressed with new base_branch output variable
  4. Low (Third review): Hardcoded 8 attempts → Still present but documented with comment
  5. Low (Third review): Label addition could silently fail → Fixed with warning message

The current diff (sha f7a8eba3d6231004466554e659cfd8c07e9e53d5) shows:

  • sleep 5 replaced with for i in $(seq 1 "$MAX_RETRIES") + sleep $((i * 3)) (exponential backoff)
  • 8 attempts with backoff: 3s, 6s, 9s, 12s, 15s, 18s, 21s, 24s = max 72s wait
  • gh pr edit now has || echo "::warning::Failed to add automated-test label..."
  • base_branch variable introduced for consistency

📋 Summary

This PR fixes a CI workflow bug in .github/workflows/opencode-test-writer.yml where downstream build.yml and opencode-pr.yml workflows were never being triggered for automated test PRs. The fix splits the original single step into two: (1) find and label the PR by author lookup with 8-attempt retry loop and exponential backoff, then (2) trigger downstream workflows using the discovered PR number.

Linked Issues: Mentions PR #450 as root cause but does not link with "Closes #450".

🔴 Critical Issues (Must Fix - Blocks Merge)

None identified.

All previously reported critical issues have been resolved. (No critical issues were ever reported for this PR.)


⚠️ High Priority Issues (Should Fix)

None identified.


💡 Medium Priority Issues (Nice to Fix)

None identified.

[FIXED] Previous issue: Exponential backoff retry loop (was sleep 5 race condition, then 5-attempt loop) - Now has 8 retries with exponential backoff (3s per attempt, max 72s wait).

[FIXED] Previous issue: Label addition could silently fail - Now emits a warning if gh pr edit fails.


ℹ️ Low Priority Suggestions (Optional)

[LOW] .github/workflows/opencode-test-writer.yml:237 - MAX_RETRIES=8 is still hardcoded but now has a descriptive comment explaining the retry budget. Acceptable.

[LOW] .github/workflows/opencode-test-writer.yml:267 - Hardcoded OpenStaticFish/ZigCraft repo in API call could use a variable but is consistent with other parts of the workflow.


📊 SOLID Principles Score

N/A - This PR modifies YAML GitHub Actions configuration, not software code.


🎯 Final Assessment

Overall Confidence Score: 95%

Confidence Breakdown:

  • Code Quality: 95% - Syntactically correct YAML, proper GitHub Actions expressions, correct --jq filters
  • Completeness: 95% - Fixes the core problem (PR lookup by author + labeling); retry loop addresses race condition concerns
  • Risk Level: 95% - Very low risk; only affects CI, no application code
  • Test Coverage: N/A - CI workflow

Merge Readiness:

  • All critical issues resolved
  • Overall confidence >= 60%
  • No security concerns
  • Tests present and passing (N/A - CI fix)

Verdict:

MERGE - The fix correctly addresses the root cause by querying PRs by author instead of branch name, adds robust retry logic with exponential backoff, and properly labels the PR for downstream workflow triggering. All previously reported medium priority issues have been adequately addressed.

{
  "reviewed_sha": "f7a8eba3d6231004466554e659cfd8c07e9e53d5",
  "critical_issues": 0,
  "high_priority_issues": 0,
  "medium_priority_issues": 0,
  "overall_confidence_score": 95,
  "recommendation": "MERGE"
}

New%20session%20-%202026-04-11T14%3A57%3A43.175Z
opencode session  |  github run

@github-actions github-actions bot merged commit 71c96e4 into dev Apr 11, 2026
9 of 10 checks passed
@MichaelFisher1997 MichaelFisher1997 deleted the opencode/shiny-otter branch April 11, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant