Repository navigation
Conversation
The OpenJD release train (dependency bumps, test gates, fix agent, release notes) runs in AWS and holds no GitHub credential. This reusable workflow is how it reaches a repository: each run asks the train's gateway for actions, performs the GitHub writes with the job's GITHUB_TOKEN under fixed checks, reports back, and waits while the train works. A separate step dispatches downstream repositories' release trains with an optional token. Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
| self.assertEqual(rt.guarded_changes(self.work / ".git", self.base, sh(self.work, "rev-parse", "HEAD")), []) | ||
|
|
||
| def test_guarded_paths_symlinks_and_submodules_are_found(self) -> None: | ||
| tip = self.commit(".github/workflows/release.yml", ".gitmodules", link="link") |
The dispatch step took a single optional dispatch_token for every downstream repository. Replace it with two optional secrets, dispatch_token_openjd (OpenJobDescription repositories) and dispatch_token_aws_deadline (aws-deadline repositories), each meant to be a bot-owned fine-grained token with only Actions: read and write. The script picks the token by the target's owner, case-insensitively; a target owned by any other account is refused, and a target whose organization has no token is skipped with a notice and never gets the other organization's token. The allowlist checks (gateway list, caller's dispatch_repos, default branch, release_train.yml only) are unchanged. Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
A transient 503 from the runner's token service during the wait loop escaped as a traceback and failed the job. The request is now retried (3 attempts) and a token that still does not arrive is a GatewayError, which the wait loop retries like a failed gateway call. Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
| with os.fdopen(fd, "w") as f: | ||
| json.dump(payload, f) | ||
| try: | ||
| proc = subprocess.run(["aws", "lambda", "invoke", "--function-name", function, "--cli-binary-format", |
There was a problem hiding this comment.
Should fix: invoke raises only GatewayError for CLI failures, but subprocess.TimeoutExpired (the 120 s timeout), a json.JSONDecodeError on empty or garbled CLI output, and a missing out file all get through. The wait loop in converse only retries GatewayError, so one slow gateway call during a wait crashes the run with a traceback. The dispatch_file write after the loop then never happens, so fan-out targets collected earlier in the run are lost and the dispatch step prints "No downstream dispatches."
Wrap the subprocess call and both json.loads/read_text calls and re-raise as GatewayError(...). It is also worth writing the dispatch file in a finally.
| description: "Ref of tooling_repository to take the script from, matching the ref callers use for this workflow." | ||
| required: false | ||
| type: string | ||
| default: "mainline" |
There was a problem hiding this comment.
Should fix: The script that holds contents: write/actions: write is always checked out from tooling_ref, which defaults to the moving mainline branch. It does not follow the revision of this workflow that the caller pinned. A caller that pins reusable_release_train.yml@<sha> still runs whatever release_train.py is on mainline right now, so the pin does not cover the code that actually pushes, tags and dispatches. A script change on mainline also reaches every caller immediately, even if it doesn't match the pinned workflow.
One fix is to require callers to pass tooling_ref equal to their pinned ref (no default). Another is to have the gateway verify that tooling_ref matches job_workflow_sha.
There was a problem hiding this comment.
Addressed: The tooling_repository/tooling_ref inputs are removed; the script is now checked out from job.workflow_repository at job.workflow_sha, and a new step checks both values first and fails if either is empty or malformed.
| lines.append(f"- {note}") | ||
| if results: | ||
| lines += ["", "| action | result |", "| --- | --- |"] | ||
| kinds: dict[str, str] = {str(a.get("id")): str(a.get("kind")) for a in plan.get("actions", [])} |
There was a problem hiding this comment.
Nit: _summary builds its kind lookup only from conv.plan, the first plan, while results holds the results of every wait iteration. So every action handed out during a wait shows up as ? in the step summary. The lookup also calls a.get without the isinstance(a, dict) guard that execute/converse use. If the first plan contains a non-dict action, execute reports it as refused, but the summary then crashes with AttributeError after all the work is done.
Collect kinds in converse (it already computes them for each plan) and pass that map in.
|
Claude review · advisory Reviewed Open: 0 blocking · 2 should-fix · 1 nit. ❌ Address or reply to the open threads. Fix or reply to each thread; the next revision's review re-checks open threads and resolves those it agrees are handled. Resolving a thread yourself also closes it. Later revisions review only what changed. |
The release train runs on workflow_run when Release: Publish completes, and asked the gateway to record the release and name the downstream repositories whatever the Publish run's conclusion was, so a failed Publish still fanned out. On workflow_run the workflow now passes the triggering run's conclusion and URL to the script. Unless the conclusion is success, the run step asks the gateway nothing, emits a warning and a job-summary line naming the run and its conclusion, and exits 0; the dispatch step dispatches nothing. Other triggers are unchanged. The gateway has no notify phase, so no Slack warning is posted. Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
The release train's notes pass now uses the release-notes generator and reports its checks, so the comment no longer carries a per-line change table. Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
Every plan and wait request now carries the cron string of a schedule run (empty for other events) and the caller's RELEASE_TRAIN_WEEKLY repository variable (empty if unset). They are for the release train's planned weekly release check; the gateway does not act on them yet, so a Monday run behaves like the daily one. Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
The workflow's AWS role can be in a different account from the gateway function, and a bare function name resolves in the role's own account. Both steps now take the gateway from the caller's RELEASE_TRAIN_GATEWAY variable (a repository or organization variable holding the function's full ARN) and the credentials' region from RELEASE_TRAIN_REGION, falling back to the gateway_function and aws_region inputs. The script accepts a function name or a full Lambda ARN, invokes an ARN in the region it names, and refuses anything else before calling AWS. No account id is written in any workflow. Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
The train labels a PR needs-human when its fix agent could not finish the change, but the script only allowed agent-modified, so it refused those PR actions. Add needs-human to the allowed labels with a color and description for creating it when missing. Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
The tests used a fork test branch name as the repository's default branch. Use trunk instead; it still differs from mainline, so the tests keep showing that the script follows the repository's default branch. Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
crowecawcaw
left a comment
There was a problem hiding this comment.
This PR currently has GitHub workflows poll a Lambda function to know what to do next which feels overly complicated. It's basically building a new orchestration service in the Lambda Can we have a GitHub workflow drive the release across multiple repos instead?
Remove the find_release_pr, push_release_notes and comment_release_pr actions, their validation and tests, and the wait for a release PR after dispatching Release: Bump. Release notes stay with each repository's existing Release: Bump workflow. Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
…e branch A workflow_run run now reaches the train job only when the Release: Publish run it follows succeeded, ran for this repository's own commit, and ran on release_branch (a new input, default mainline, which is where every caller's Publish runs). Before, only the conclusion was checked, in the script, after the OIDC role was assumed; a same-named workflow from a fork or another branch got that far. Any other workflow_run run gets a skipped job with no permissions, no OIDC token and no AWS credential, which writes a notice and a summary line saying why. The head branch and repository it reports come from the triggering run, so they are passed through env and escaped. The script's own conclusion check stays as a second check. Other events are unchanged. Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
configure-aws-credentials now masks the role's account id (mask-aws-account-id: true). It runs before the two steps that print the gateway in their env, so a RELEASE_TRAIN_GATEWAY ARN in the role's account shows as *** there. Both script commands also mask a gateway ARN and its account id first, which covers later output and a gateway in another account from then on. Error text from the AWS CLI and from a gateway refusal has every 12-digit account id replaced before it is printed, because ::add-mask:: hides only the accounts the job registered. A bare gateway name keeps working and needs no mask. Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
The job checked out release_train.py from tooling_repository and tooling_ref, which a caller could override, while the AWS role's job_workflow_ref pin and the gateway's workflow check cover only this workflow file. The script now comes from job.workflow_repository at job.workflow_sha, the repository and commit of this workflow file, and the two inputs are removed. A step before the checkout fails the job if either value is empty or malformed (actions/checkout would otherwise fall back to the caller's repository) and logs the source. Callers that call this workflow from a fork get that fork's script without passing anything. Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
The workflow header still said the train writes release notes, and the contents: write comments said it creates tags and releases. People review and merge the train's PRs, release notes come from each repository's own generator, and the repository's own Release: Publish tags and releases. The train makes a prerelease tag only in rehearsal mode. Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
One workflow job can wait up to an hour across several handoffs. ensure_clone
fetched the default branch only on its first call, so a job that started
before the release PR was merged kept the old tip: the publish handoff then
refused to tag the merge commit ("not reachable from the default branch"),
and a push whose base was a newer default-branch commit failed bundle
verification.
ensure_clone now fetches the branch on every call, incrementally into the
same bare repository; only the init is done once. The other state kept across
actions was checked: _remote_head reads the remote on each push, PR state is
read from the API on each call, and ctx.pushed is only the tip this job just
pushed, used to wait for GitHub to report it.
Tests: tagging and pushing after the remote branch moves forward.
Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
Rehearsal mode let the train create a tag and a prerelease without a person merging anything. Remove the create_tag_and_prerelease action, the rehearsal title check and their tests. The script now runs only in live mode: any other RELEASE_TRAIN_MODE fails the job before GitHub or the gateway is asked. Release: Publish remains the only thing that tags and releases, after a person merges the release PR. Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
The run steps under test are bash on ubuntu-latest. On the Windows runner, bash resolves to the WSL launcher, which has no distribution installed, so these tests failed there and fail-fast cancelled the Linux and macOS jobs. Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
The test replaced the bundle's last byte with a zero byte, which left the bundle unchanged whenever that byte was already zero (about one run in 256), so the sha256 check passed and the test failed. It now flips every bit of the last byte. Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
The skipped job's run step lowercases with ${var,,}, a bash 4 feature that ubuntu-latest has and macOS's bash 3.2 lacks, so the notice tests failed on the macOS runner. The bash step tests now run only where bash passes that check, which also covers Windows.
Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
Fair point Stephen, I think the main reason we wanted with this was because we wanted orchestration lives in AWS rather than a GitHub workflow is the fix agent. When a bump breaks tests, we'll have an agent propose a fix. Everything it runs (installs, builds, tests) happens in a container with no cloud credentials and no network access, and its full transcript is stored write-once. That isolation is much harder to guarantee on a GitHub runner, and it's the part our security review focused on. Humans still review and merge every PR the train opens. Do you think this is still valid with your concerns ? |
| id-token: write # OIDC tokens for the AWS role and the gateway | ||
| steps: | ||
| # The script comes from exactly the repository and commit of this workflow file (the job context's | ||
| # workflow_repository and workflow_sha), so the AWS role's job_workflow_ref pin and the gateway's workflow |
There was a problem hiding this comment.
Important: this is only commit-pinned within a run. The current caller rollout uses @mainline, so every future central mainline commit would immediately receive write/OIDC permissions in every caller. Please pin each caller and the job_workflow_ref trust condition to the reviewed commit SHA, with an explicit rollout process, or document and approve the mutable central-ref trust model.
There was a problem hiding this comment.
The trust is on the mainline ref, not a pinned SHA. That's a deliberate choice, and it matches how the org's existing reusable release workflows (bump, release, publish) are already called: @mainline, with OIDC and secrets.
What makes that acceptable here:
- mainline on this repo requires a PR with code-owner review (stale approvals are dismissed on new pushes), blocks force pushes, and requires DCO, CI and CodeQL checks. A change only reaches the callers through a reviewed merge by the code owners.
- The AWS role's trust condition is narrow: job_workflow_ref must be exactly this workflow file on refs/heads/mainline, so a caller can't point the role at any other workflow or branch.
- Within a run, the script executes from job.workflow_sha, so a run can't pick up a commit that landed mid-run.
tldr; dont we do the same thing when we just run a manual release ?
There was a problem hiding this comment.
Thanks.. I agree, makes sense.. the trust model is the same as for manual release, the difference here is the blast radius as the workflow can be invoked across repositories. But I am ok keeping @mainline ref, just want to callout/document this decision.
There was a problem hiding this comment.
makes sense, and noted ! good callout
| # Set on workflow_run only: the triggering run's conclusion and URL (see skipped_trigger). | ||
| RT_TRIGGER_CONCLUSION: ${{ github.event.workflow_run.conclusion }} | ||
| RT_TRIGGER_RUN_URL: ${{ github.event.workflow_run.html_url }} | ||
| run: python3 workflow-tooling/.github/scripts/release_train.py dispatch |
There was a problem hiding this comment.
step-level secret scoping is not an isolation boundary here. The earlier step executes this workspace copy of release_train.py, and this step executes the same copy with cross-repository PATs, so earlier code can replace it before the tokens are exposed. Can we use a separate job with a fresh SHA-pinned checkout and pass only a strictly validated dispatch list, or remove the cross-repository tokens and rely on scheduled pickup.
There was a problem hiding this comment.
This makes sense, I can make this change for sure
There was a problem hiding this comment.
ok taking the feedback, heres what I made changes to:
trainkeeps its current permissions and holds no PATs. It only outputs a dispatch flag and the fan-out list.dispatch(needs: train,permissions: {}) is the only job that references the two PATs. It does a fresh checkout pinned tojob.workflow_sha, with no persisted credentials, and runsrelease_train.py dispatchfrom that copy.- Strict validation before anything is sent: exact keys and types; owner must be
OpenJobDescriptionoraws-deadline; strict repo, package and version formats; workflowrelease_train.ymlon the target's default branch; at most 20 targets, no duplicates. Targets must also appear in the caller's committeddispatch_reposinput. Anything invalid fails the job and nothing is dispatched.dispatch-reportrecords the outcomes with the gateway. It hasid-token: writeonly and no PATs, and validates the dispatch job's results the same way.- Job outputs reach the scripts through
env:only, never interpolated intorun:. If a masked value causes the runner to drop the fan-out list while the flag is set, the job fails loudly instead of skipping.
we already have precedence with OIDC and existing workflows, and as per the guide it says: "Use caution when integrating GenAI systems with GitHub CI/CD workflows and always require human approval for GenAI-initiated actions."' Which we still do. Bots don't approve anything, we still look at every review. Is this what you mean ? |
Step-level secret scoping is not an isolation boundary: every step of a job shares its filesystem, so an earlier step of the train job could replace the release-train script before the step holding the dispatch tokens ran it. The dispatch tokens now reach only a new dispatch job. It has no permissions, no OIDC token or AWS credential, and no action but the commit-pinned checkout of this workflow's own commit; it runs only `release_train.py dispatch`. The train job hands it the fan-out as job outputs (only the fields it reads), and the targets it may dispatch still come from the caller's dispatch_repos input. The dispatch command parses that output strictly (exact keys and types, owner OpenJobDescription or aws-deadline, a claim naming its repository with a lower-case package name and an X.Y.Z version, at most 20 targets) and fails the job, dispatching nothing, on anything else. Per-target checks (both allowlists, default branch, one token per organization) are unchanged. Recording the outcomes with the gateway needs the OIDC role, so a third job, dispatch-report, does that with no dispatch token, parsing the results as strictly. The train job's behaviour, permissions and the workflow_call interface are unchanged; callers need no change. Signed-off-by: Sean Tang <171081544+seant-aws@users.noreply.github.com>
| if not DISPATCH_TARGET_REPO.fullmatch(repo) or ".." in repo: | ||
| raise DispatchInputError(f"target {i}: the repository must be OpenJobDescription/<name> or " | ||
| "aws-deadline/<name> with a name of letters, digits, '.', '_' and '-'") | ||
| problem: str = _claim_problem(target["key"], repo) |
There was a problem hiding this comment.
Should fix: parse_dispatch_doc rejects the whole document when any single target fails a per-target check. The old per-target path accepted some of these targets and refused others one at a time. _claim_problem is also stricter than CLAIM_KEY, which _dispatch_one and parse_dispatch_results still use and which allows versions like 1.0.0rc1 and package names with ._:.
Failure: the gateway fans out one pre-release, one openjd_model-style name, or one repo outside the two orgs. The dispatch job then exits 1 and dispatches none of the valid targets. results is empty, so dispatch-report is skipped and the gateway never gets a dispatched phase for any claim.
Fix: keep strict structural checks (shape, keys, types, count) that fail the job. Route per-target content failures into a refused result, as _dispatch_one already does, or align the patterns with CLAIM_KEY.
There was a problem hiding this comment.
I think this goes against the feedback that Kavi asked for earlier, which is what the fix is related to
| _own_bot_pr(pr, ctx) | ||
| if pr["head"]["ref"] != action["branch"]: | ||
| raise Refused(f"PR #{action['number']} is from {pr['head']['ref']}, not {action['branch']}") | ||
| return _pr_out(pr) |
There was a problem hiding this comment.
Could we verify that pr["head"]["sha"] == action["tip"] before reporting the PR status? If someone force-pushes the bot/* branch, the train could treat a different commit as the expected merged PR and advance downstream
| _own_bot_pr(pr, ctx) | ||
| if pr["head"]["ref"] != action["branch"]: | ||
| raise Refused(f"PR #{action['number']} is from {pr['head']['ref']}, not {action['branch']}") | ||
| return _pr_out(pr) |
There was a problem hiding this comment.
nit: also pr["base"]["ref"] == ctx.default_branch
|
Few high level thoughts:
|
Fixes: N/A (new release automation; the callers are the draft PRs OpenJobDescription/openjd-model-for-python#385, OpenJobDescription/openjd-sessions-for-python#378, OpenJobDescription/openjd-cli#249 and aws-deadline/deadline-cloud-worker-agent#1132)
What was the problem/requirement? (What/Why)
The OpenJD release train re-releases openjd-model, openjd-sessions, openjd-cli and the worker agent when an upstream OpenJD package releases: it bumps the dependency, runs the tests, and proposes the change as a PR. The train runs in AWS and must not hold a GitHub credential, so each repository needs a workflow that makes the train's GitHub writes.
What was the solution? (How)
reusable_release_train.ymlplus.github/scripts/release_train.py. Each run asks the train's gateway (a Lambda function) what to do, validates every action, performs it with the job's ownGITHUB_TOKEN, and reports back. The only actions are: push a verified git bundle to abot/*branch (never a guarded path such as.github/), open or update that branch's PR, read a PR's state, comment on it, and dispatch the repository's ownRelease: Bump. After a release, a separate step dispatches the downstream repositories'release_train.yml.Trust model. The job reaches AWS with GitHub OIDC; the role can only invoke the gateway, and it trusts only the caller's default-branch subject. The gateway verifies a second OIDC token for the repository, ref, event and workflow. AWS never holds a GitHub credential: the job opens PRs with its own token, and only the dispatch step receives the per-organization dispatch tokens.
Human gates. Nothing merges automatically. A PR opened with
GITHUB_TOKENdoes not start its CI, so a maintainer approves the CI run, reviews and merges. The repository's ownRelease: Publishtags and releases after that merge; the train never tags or releases.Controls in this PR:
workflow_runguard: the train job runs only after a successfulRelease: Publishof the caller's own commit onrelease_branch. Any other run gets a notice job withpermissions: {}. The script checks the conclusion again.mask-aws-account-id, plus the script masks a gateway ARN and redacts account IDs from AWS errors).job.workflow_repositoryatjob.workflow_sha), so no caller can name another source.RELEASE_TRAIN_MODE=liveruns; any other value fails the job before GitHub or the gateway is asked. There is no tag or release action.What is the impact of this change?
None until a repository calls it and an admin enables it. Setup per caller:
RELEASE_TRAIN_ENABLED=true,RELEASE_TRAIN_MODE=live; optionalRELEASE_TRAIN_GATEWAY(the gateway's full ARN when it is in another account),RELEASE_TRAIN_REGION(defaultus-west-2) andRELEASE_TRAIN_WEEKLY.RELEASE_TRAIN_ROLE(the OIDC role ARN); optionalRELEASE_TRAIN_DISPATCH_TOKEN(OpenJobDescription) andRELEASE_TRAIN_DISPATCH_TOKEN_AWS_DEADLINE(aws-deadline), each a bot-owned fine-grained token with Actions read and write only.refs/heads/bot/**from the branch-creation rulesets.How was this change tested?
python -m unittest discover -s test -p "test_*.py": 191 tests pass. zizmor (--no-config) has no findings. actionlint reports only that it does not knowjob.workflow_repositoryandjob.workflow_sha, which are set in a reusable workflow's job. The workflow ran end to end on forks, including a release and its downstream dispatch.Was this change documented?
Yes, in the headers of the workflow and the script.
Is this a breaking change?
No.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.