Skip to content

fix(backstage-template-execution): ignore concurrency-cancelled duplicates in actions-runs gate - #67

Merged
patrick-hermann-sva merged 1 commit into
mainfrom
fix/merge-gate-cancelled-duplicates
Oct 20, 2026
Merged

patrick-hermann-sva merged 1 commit into
mainfrom
fix/merge-gate-cancelled-duplicates

Conversation

@patrick-hermann-sva

Copy link
Copy Markdown
Contributor

Why

The Actions-runs fallback from #65 refused a real merge: stuttgart-things/stuttgart-things#3889, head 5cbeb476f. The worker logged pr head checks source=actions-runs total=14 distinct=5 notGreen=1.

On PR open, GitHub started several workflows twice. Every copy had the same run_started_at (19:52:56Z) and run_attempt 1. Each workflow's concurrency group cancelled one copy, and the other ended success or skipped. Example: "PR Packer Build with Dagger" came back cancelled, cancelled, skipped, skipped. Because the start time and attempt were equal, the newest-per-workflow_id pick depended on the API's list order. It landed on a cancelled copy and refused the merge.

What (fallback path only)

  1. Per workflow_id, a completed/cancelled run is ignored when the same workflow has at least one non-cancelled run for the SHA, because a concurrency run superseded it. If all runs of a workflow are cancelled, the gate still reports name (cancelled) and refuses.
  2. Of the runs that remain, the newest is picked by run_started_at (or created_at if that is missing), then run_attempt, then run id. The id is assigned in increasing order, so the pick no longer depends on list order.
  3. The code comments cite this case.

The check-runs path is unchanged. It probably has the same tie problem, since duplicated workflows produce same-named cancelled job check runs with equal started_at. Fixing it would change that path's behaviour, so it is left for a separate decision.

Tests

go build ./..., go vet ./..., go test ./..., gofmt -l (clean) in workflows/backstage-template-execution. New table test TestUnfinishedChecksFallbackCancelledDuplicates:

  • the #3889 shape, in API order and reversed → green
  • all runs of a workflow cancelled → refused
  • equal timestamps resolved by id, in both list orders
  • an in-progress copy outranks its cancelled duplicate

Three of these cases fail against the code on main and pass with this change.

🤖 Generated with Claude Code

https://claude.ai/code/session_016TtmNGbCHXQGtqnrT926ZN

…cates in actions-runs gate

On PR open GitHub may start a workflow twice with identical
run_started_at and run_attempt; the concurrency group cancels one copy.
The newest-per-workflow pick was then arbitrary and could land on the
cancelled copy, refusing a green head (stuttgart-things#3889).

In the Actions-runs fallback, drop cancelled runs when the same workflow
has a non-cancelled run on the SHA (all-cancelled still refuses), and
break remaining ties by run id so the pick is deterministic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016TtmNGbCHXQGtqnrT926ZN
@patrick-hermann-sva
patrick-hermann-sva merged commit 6e9fc1e into main Oct 20, 2026
8 checks passed
@patrick-hermann-sva
patrick-hermann-sva deleted the fix/merge-gate-cancelled-duplicates branch October 20, 2026 20:14

This branch was successfully deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant