Skip to content

fix: INFRA-1076 attribute fleet deploys to the run owner (commit author signal) - #202

Open
andruwm wants to merge 1 commit into
masterfrom
infra-1076-deploy-attribution
Open

andruwm wants to merge 1 commit into
masterfrom
infra-1076-deploy-attribution

Conversation

@andruwm

@andruwm andruwm commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Clever Coding Standards Agreement

Ticket

INFRA-1076

About

Follow-up to #201, which shipped environment.DeployUser() but detected fleet merges the wrong way. Verified against a real fleet merge (ic-oneroster-api, migrate-ci-to-orbs):

author:    clever-fleet[bot] <316729001+clever-fleet[bot]@users.noreply.github.com>
committer: GitHub <noreply@github.com>
message trailer: Co-authored-by: andrew.marine <andrew.marine@clever.com>
CIRCLE_USERNAME= (empty)

GitHub's squash makes clever-fleet[bot] the commit author (not a message-body trailer) and demotes the real author — the run owner — to a Co-authored-by: trailer. #201 grepped the message body for a clever-fleet[bot] co-author (never present) and attributed to the bot, so it never fired.

New DeployUser() logic:

  • CIRCLE_USERNAME set → use it (normal human merge).
  • Empty and commit author is clever-fleet[bot] (a fleet merge) → attribute to the run owner email from the Co-authored-by: trailer; fall back to the clever-fleet[bot] service account when there is no usable co-author.
  • Empty and author is not the fleet bot → keep the existing hard-fail, so scheduled/API/other-bot triggers are never misattributed to fleet.

DeployUser() now returns a DeployActor{GithubUsername|Email}; deploy_publisher sets User.Email (run owner) or User.GithubUsername (bot/human) accordingly — Slingshot resolves either. All signals are read from git (%an/%ae, %(trailers:key=Co-authored-by)); no GitHub API or token needed.

Checklist

  • Increment the version number in VERSION — bumped to v1.15.0
  • Add release notes — in VERSION

Testing

  • go build / go vet ./internal/environment/ ./internal/platformevents/ pass.
  • New environment_test.go unit-tests the detection/parsing helpers (fleet-bot author vs human vs other-bot; run-owner extraction skipping bot co-authors; malformed lines).
  • Verified the exact git log --format strings against a commit mimicking the real fleet merge: %an/%ae → fleet-bot detected, %(trailers:key=Co-authored-by,valueonly)andrew.marine@clever.com, committer → GitHub (matches production).

Rollout

Standard deploy. Behavior only changes for empty-CIRCLE_USERNAME pipelines; human-triggered deploys are unchanged. The no-co-author fallback still relies on clever-fleet[bot] being registered in who-is-who (INFRA-1076 2a); the common owner-attributed case resolves the run owner directly and needs no bot entry.

Note: this supersedes #201's detection. #201 is already merged; this PR corrects it on top of master.

🤖 Generated with Claude Code

The previous approach detected fleet merges by a clever-fleet[bot]
Co-authored-by trailer in the commit message and attributed to the bot.
Both were wrong against real merges: GitHub's squash makes clever-fleet[bot]
the commit AUTHOR (not a message-body trailer) and demotes the real author
(the run owner) to the Co-authored-by trailer; CIRCLE_USERNAME is empty.

DeployUser now:
- uses CIRCLE_USERNAME when set (normal human merge);
- for an empty CIRCLE_USERNAME with a clever-fleet[bot] commit author (a fleet
  merge), attributes to the run owner's email from the Co-authored-by trailer,
  falling back to the clever-fleet[bot] service account when there is no usable
  co-author;
- otherwise keeps the existing hard-fail, so non-fleet triggers are never
  misattributed to fleet.

DeployUser returns a DeployActor (email or github username); deploy_publisher
sets User.Email or User.GithubUsername accordingly. Detection/parsing helpers
are unit-tested.
@andruwm
andruwm marked this pull request as ready for review September 18, 2026 04:41
@andruwm
andruwm requested a review from a team as a code owner September 18, 2026 04:41
@andruwm
andruwm requested review from dmartschenko and removed request for a team September 18, 2026 04:41

This branch has not been deployed

No deployments
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