Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/rollup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Roll up stacks

on:
workflow_dispatch:
inputs:
operation:
description: Create, resume, refresh source snapshots, or cancel a rollup
type: choice
options: [create, resume, refresh, cancel]
default: create
pull_requests:
description: 'Create: stack-tip PR numbers, e.g. 1571,1591 (dependencies included)'
type: string
rollup:
description: 'Resume/refresh/cancel: the existing rollup PR number'
type: string
base:
description: 'Create: destination branch'
type: choice
options: [master, develop]
default: master
queue:
description: 'Create: request merging once all conflicts are resolved'
type: boolean
default: false
pull_request_target:
types: [synchronize, closed, converted_to_draft]

# Claiming/restoring source holds and refreshing integration branches must not
# race another rollup. Never cancel an operation halfway through publication.
concurrency:
group: github-rollup-management
cancel-in-progress: false

permissions: {}

jobs:
rollup:
if: >-
(github.event_name == 'workflow_dispatch' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)) ||
(github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name == github.repository &&
((startsWith(github.head_ref, 'rollup/') && github.event.action != 'converted_to_draft') || contains(github.event.pull_request.labels.*.name, 'rollup:source')))
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Create rollup app token
id: token
uses: actions/create-github-app-token@v3
with:
app-id: ${{ vars.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
permission-contents: write
permission-pull-requests: write
permission-issues: write
permission-workflows: write

# Execute only the trusted default-branch controller. The controller
# reads source commits as git data in a disposable separate checkout.
- uses: actions/checkout@v7
with:
ref: ${{ github.event.repository.default_branch }}
persist-credentials: false

- uses: actions/setup-node@v7
with:
node-version: 24

- name: Configure git authentication
env:
GH_TOKEN: ${{ steps.token.outputs.token }}
run: gh auth setup-git

- name: Manage rollup
env:
GH_TOKEN: ${{ steps.token.outputs.token }}
ROLLUP_OPERATION: ${{ inputs.operation }}
ROLLUP_TIPS: ${{ inputs.pull_requests }}
ROLLUP_NUMBER: ${{ inputs.rollup }}
ROLLUP_BASE: ${{ inputs.base }}
ROLLUP_QUEUE: ${{ inputs.queue }}
run: node scripts/github-rollup.mjs
4 changes: 4 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ scopes:
- scripts/check-mergify-batch.test.mjs
- scripts/check-mergify-queue-title.mjs
- scripts/check-mergify-queue-title.test.mjs
- scripts/rollup-plan.mjs
- scripts/rollup-plan.test.mjs
Comment on lines +28 to +29

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep the rollup runtime in a shared queue scope

These exclusions assign rollup-plan.mjs solely to the pr-policy scope, but github-rollup.mjs, which remains in core, imports that module directly. Parallel changes to the controller and its plan API can therefore be validated and merged independently without any batch ever testing their combined tree, potentially breaking the trusted rollup workflow; keep the shared runtime module and its consumers in a common scope, or make them participate in both scopes.

Useful? React with 👍 / 👎.

pr-policy:
include:
- .github/workflows/pr-title.yml
Expand All @@ -36,6 +38,8 @@ scopes:
- scripts/check-mergify-batch.test.mjs
- scripts/check-mergify-queue-title.mjs
- scripts/check-mergify-queue-title.test.mjs
- scripts/rollup-plan.mjs
- scripts/rollup-plan.test.mjs
capacities:
core: 2
pr-policy: 1
Expand Down
5 changes: 5 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ endpoint.
`master` (no stable-lane release check or release-impact check); the merge
queue validates them in full.

The GitHub **Roll up stacks** workflow is the integration exception: it owns
synthetic `rollup/*` branches and publishes an aggregate PR while preserving
source commits. Use that workflow for rollup creation, refresh and cancellation;
do not rewrite the original stack branches or close their PRs manually.

## Adding tests

When adding tests, consider adding them to `crates/celox-test-suite` so
Expand Down
45 changes: 45 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,51 @@ chain on the stack root, bottom-up. Queueing the top member queues every member
below it. The batch validator resolves each member's root through the same
marker chain, so a stack branch without it is still refused.

### Roll up conflicting stacks from GitHub

Use **Actions → Roll up stacks → Run workflow** on `master`. Choose `create`,
enter the **tip PR numbers** of the stacks (for example `1571,1591`), and select
`master` or `develop` as the destination. The workflow follows the `Depends-On`
chains, deduplicates shared predecessors, and creates one rollup PR. Fork PRs,
drafts, dependency cycles and chains targeting another destination are rejected.
The existing Release App credentials are used, including workflow-write access
when the selected changes include workflow files.

The workflow pins each source head, preserves the original commits, and adds
`rollup:source` and `release:hold` to its sources. Their branches are never
rewritten. Another managed rollup cannot claim the same sources. The rollup's
title is derived from the highest release impact of all included commits,
including sources still waiting on conflict resolution. `Release-As` commits
must use the release workflow instead.

When two sources conflict, the rollup stays draft and links a **resolution PR**.
Open that PR and use GitHub's **Resolve conflicts** button, then commit the
resolution. This edits a copy of the source branch. The workflow automatically
resumes the rollup; repeat for any further conflicts. If the rollup itself
conflicts with its destination, use **Resolve conflicts** on the main rollup
PR. GitHub's editor supports simple text conflicts; for conflicts it cannot
edit, resolve and push only the indicated rollup/resolution branch locally.

Once every source is integrated, the workflow marks the rollup ready for review.
Add `merge-ready` to queue it, or select the **queue** checkbox when creating it
to request queueing automatically when conflict resolution completes. The normal
combined-tree queue checks still apply. Source updates or conversion to draft
stop an active rollup; queue validation also checks the pins and commit ancestry.

To recover an interrupted run, select `resume` and enter the **rollup PR number**.
To incorporate new source heads, select `refresh` with that number. Refresh
rebuilds the integration from the new snapshots; previous conflict resolutions
are not reused across changed snapshots. If stack membership changes, cancel
and create a new rollup. Sources merged as part of the rollup retain their
history; the rollup also carries closing references for source PR cleanup.

To abandon it, select `cancel` with the rollup PR number, or close the rollup
PR. The controller closes its resolution PRs, removes `rollup:source`, and
restores only the holds it added. Holds present before the rollup stay in place.
The same cleanup runs after a successful merge. Source PRs are never closed by
the cancellation operation. Controller results and recovery errors appear in
the Actions run summary.

Lydite tests use the independent change-selected and daily cadence described
below, including on Mergify queue draft PRs.
The `Queue validation` merge condition requires the selected checks in `ci.yml` to pass;
Expand Down
2 changes: 2 additions & 0 deletions scripts/check-mergify-batch.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { readFileSync } from "node:fs";
import { pathToFileURL } from "node:url";
import { isConventionalPrTitle } from "./check-pr-title.mjs";
import { validateRollupSources } from "./rollup-plan.mjs";
import {
githubJson,
loadPullRequestCommits,
Expand Down Expand Up @@ -140,6 +141,7 @@ export async function validateBatch(
if (errors.length)
throw new Error(`#${sourceNumber}: ${errors.join("; ")}`);
}
await validateRollupSources(repository, source, api);
}
return numbers;
}
Expand Down
19 changes: 19 additions & 0 deletions scripts/check-mergify-batch.test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import assert from "node:assert/strict";
import test from "node:test";
import { renderBody } from "./rollup-plan.mjs";
import {
batchPullRequestNumbers,
stackDependency,
Expand Down Expand Up @@ -72,6 +73,24 @@ test("validates every source PR against policy from the exact batch tree", async
assert.ok(f.calls.includes("/repos/o/r/pulls/13"));
});

test("queue batches reject stale rollup source snapshots", async () => {
const f = fixture();
const pinned = "d".repeat(40);
f.input.metadata = { pull_requests: [{ number: 12 }] };
Object.assign(f.source, { number: 12, head: { sha: sourceSha, ref: "rollup/123", repo: { full_name: "o/r" } },
body: renderBody({ repository: "o/r", id: "123", base: "master", baseSha,
tips: [34], queue: true, sources: [{ number: 34, sha: pinned, heldBefore: false }] }, "Ready") });
let head = pinned;
const api = async (path) => {
if (path === "/repos/o/r/pulls/34") return { state: "open", head: { sha: head, repo: { full_name: "o/r" } } };
if (path === `/repos/o/r/compare/${pinned}...${sourceSha}`) return { status: "ahead" };
return f.api(path);
};
assert.deepEqual(await validateBatch(f.input, api, f.commits, f.policy), [12]);
head = "e".repeat(40);
await assert.rejects(validateBatch(f.input, api, f.commits, f.policy), /source #34 changed/);
});

test("rejects spoofed batch authors, forks, stale heads, and non-drafts", async () => {
for (const mutate of [
(f) => (f.batch.user.login = "someone"),
Expand Down
Loading
Loading