Skip to content
Merged
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
49 changes: 49 additions & 0 deletions .github/scripts/promotion-worker-routing-contract.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ const allBranchWorkflow = readFileSync(
new URL("../workflows/all-branch.yml", import.meta.url),
"utf8",
);
const developPromotionWorkflow = readFileSync(
new URL("../workflows/promote-develop-to-main.yml", import.meta.url),
"utf8",
);
const featurePromotionWorkflow = readFileSync(
new URL("../workflows/promote-features-to-main.yml", import.meta.url),
"utf8",
);
const mainDevelopSyncWorkflow = readFileSync(
new URL("../workflows/sync-main-into-develop.yml", import.meta.url),
"utf8",
);
const action = readFileSync(
new URL("../actions/rebase-conflict-round/action.yml", import.meta.url),
"utf8",
Expand All @@ -42,6 +54,13 @@ assert.match(workflow, /^name: Lopu PR manager$/m);
assert.match(workflow, /manage_rebases:/);
assert.match(workflow, /uses: \.\/\.github\/workflows\/rebase-pr-stacks\.yml/);
assert.match(workflow, /name: Lopu scans rebases and stack cascades/);
assert.match(workflow, /maintain_develop_promotion:/);
assert.match(workflow, /maintain_feature_promotions:/);
assert.match(workflow, /maintain_main_develop_sync:/);
assert.match(workflow, /uses: \.\/\.github\/workflows\/promote-develop-to-main\.yml/);
assert.match(workflow, /uses: \.\/\.github\/workflows\/promote-features-to-main\.yml/);
assert.match(workflow, /uses: \.\/\.github\/workflows\/sync-main-into-develop\.yml/);
assert.match(workflow, /github\.event\.schedule == '43 \*\/6 \* \* \*'/);
assert.match(workflow, /review_detect:/);
assert.match(workflow, /review_handoff:/);
assert.match(workflow, /review:\s+name: Lopu reviews selected PRs/);
Expand Down Expand Up @@ -82,6 +101,36 @@ assert.equal(
"the rebase and stack worker shares the durable single-Lopu queue",
);

for (const [label, source] of [
["develop promotion", developPromotionWorkflow],
["feature promotion", featurePromotionWorkflow],
["main/develop synchronization", mainDevelopSyncWorkflow],
]) {
assert.match(source, /^ workflow_call:$/m, `${label} remains an internal reusable component`);
assert.doesNotMatch(
source,
/^ (?:push|pull_request|pull_request_target|schedule|workflow_dispatch|repository_dispatch):/m,
`${label} must not compete with the public Lopu workflow`,
);
assert.match(source, /^\s+cancel-in-progress: false$/m, `${label} never cancels in-flight work`);
}
assert.match(developPromotionWorkflow, /^name: Lopu internal develop promotion$/m);
assert.match(featurePromotionWorkflow, /^name: Lopu internal feature promotion$/m);
assert.match(
featurePromotionWorkflow,
/route:[\s\S]*inputs\.source_branch == ''[\s\S]*inputs\.target_branch == ''[\s\S]*inputs\.require_path_prefix == ''/,
"custom promotion authority stays on the reviewed GitHub runner",
);
assert.match(featurePromotionWorkflow, /promote:\s+needs: route\s+if: >-\s+always\(\)/);
assert.match(mainDevelopSyncWorkflow, /^name: Lopu internal main\/develop synchronization$/m);
for (const input of ["source_branch", "target_branch", "require_path_prefix"]) {
assert.equal(
featurePromotionWorkflow.match(new RegExp(`^ ${input}:$`, "gm"))?.length,
1,
`feature promotion ${input}: is exposed only through workflow_call`,
);
}

assert.match(allBranchWorkflow, /^name: Lopu all-branch integration$/m);
assert.equal(
[...allBranchWorkflow.matchAll(durableFleetQueue)].length,
Expand Down
50 changes: 49 additions & 1 deletion .github/scripts/workflow-control-plane-contract.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -767,11 +767,27 @@ export function assertControlPlaneContract() {
assert.match(source, /control_dispatch_id:/, `${name}: carries the Thingtime dispatch id`);
assert.match(source, /needs: route/, `${name}: implementation waits for provider selection`);
assert.match(source, /needs\.route\.outputs\.execute == 'true'/, `${name}: implementation obeys provider selection`);
assert.match(source, /runs-on: \$\{\{ needs\.route\.outputs\.runner_label \|\| 'ubuntu-latest' \}\}/, `${name}: uses only the validated runner label`);
if (name === "promote-features-to-main.yml") {
assert.match(source, /always\(\)/, `${name}: custom lane may continue after the provider route is deliberately skipped`);
assert.match(
source,
/inputs\.source_branch != ''[\s\S]*'ubuntu-latest'[\s\S]*needs\.route\.outputs\.runner_label/,
`${name}: custom branch\/path authority remains on GitHub while standing work uses only the validated runner label`,
);
} else {
assert.match(source, /runs-on: \$\{\{ needs\.route\.outputs\.runner_label \|\| 'ubuntu-latest' \}\}/, `${name}: uses only the validated runner label`);
}
assert.doesNotMatch(source, /runs-on:.*inputs\.runner_label/, `${name}: never schedules directly from caller metadata`);
}

const promotions = readWorkflow("promote-features-to-main.yml");
assert.match(promotions, /^name: Lopu internal feature promotion$/m);
assert.match(promotions, /^ workflow_call:$/m);
assert.doesNotMatch(
promotions,
/^ (?:push|pull_request|pull_request_target|schedule|workflow_dispatch|repository_dispatch):/m,
"feature promotion is reachable only through Lopu",
);
assert.match(promotions, /ref: github-actions/);
assert.match(promotions, /workflow-control\/\.github\/scripts\/promote-features-to-main\.mjs/);
assert.doesNotMatch(
Expand Down Expand Up @@ -806,9 +822,25 @@ export function assertControlPlaneContract() {
);

const omnibus = readWorkflow("promote-develop-to-main.yml");
assert.match(omnibus, /^name: Lopu internal develop promotion$/m);
assert.match(omnibus, /^ workflow_call:$/m);
assert.doesNotMatch(
omnibus,
/^ (?:push|pull_request|pull_request_target|schedule|workflow_dispatch|repository_dispatch):/m,
"standing promotion is reachable only through Lopu",
);
assert.match(omnibus, /ref: github-actions/);
assert.match(omnibus, /workflow-control\/\.github\/scripts\/promotion-pr-changelog\.mjs/);

const mainDevelopSync = readWorkflow("sync-main-into-develop.yml");
assert.match(mainDevelopSync, /^name: Lopu internal main\/develop synchronization$/m);
assert.match(mainDevelopSync, /^ workflow_call:$/m);
assert.doesNotMatch(
mainDevelopSync,
/^ (?:push|pull_request|pull_request_target|schedule|workflow_dispatch|repository_dispatch):/m,
"main/develop synchronization is reachable only through Lopu",
);

const rebase = readWorkflow("rebase-pr-stacks.yml");
assert.match(rebase, /ref: github-actions/);
assert.match(rebase, /origin\/github-actions/);
Expand Down Expand Up @@ -854,7 +886,23 @@ export function assertControlPlaneContract() {
assert.match(resolver, /internal_worker: >-/);
assert.match(resolver, /routing_proof:\$routing_proof/);
assert.match(resolver, /routing_proof_issued_at:\$routing_proof_issued_at/);
assert.match(resolver, /maintain_develop_promotion:/);
assert.match(resolver, /maintain_feature_promotions:/);
assert.match(resolver, /maintain_main_develop_sync:/);
assert.match(resolver, /github\.event\.schedule == '43 \*\/6 \* \* \*'/);
assert.match(resolver, /^\s+queue: max$/m);
assert.match(
resolver,
/name: Check out PR head[\s\S]*fetch-depth: 0[\s\S]*filter: blob:none[\s\S]*persist-credentials: false/u,
"resolver checkout keeps exact history while lazily fetching historical blobs",
);
for (const input of [
"maintenance_operation",
"promotion_dry_run",
"promotion_lookback",
"promotion_source_branch",
"promotion_target_branch",
"promotion_path_prefix",
"promotion_source_pr",
"promotion_plan_b64",
"routing_proof",
Expand Down
25 changes: 3 additions & 22 deletions .github/workflows/promote-develop-to-main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Keep a standing promotion PR open from develop into main, with a live
# changelog of what merging it would ship.
#
# On every push to develop (or manual dispatch),
# When the public Lopu manager receives a develop push (or an explicit owner
# maintenance request),
# .github/scripts/promotion-pr-changelog.mjs:
# - opens the promotion PR (base main, head develop) when develop is ahead of
# main and none is open — the body already contains the changelog section;
Expand Down Expand Up @@ -33,7 +34,7 @@
# immediately. Description edits and changelog comments stay on
# GITHUB_TOKEN.

name: Promote develop to main
name: Lopu internal develop promotion

on:
workflow_call:
Expand All @@ -53,26 +54,6 @@ on:
required: false
default: ""
type: string
push:
branches: [develop]
workflow_dispatch:
inputs:
execution_provider:
description: "Internal: hosted compute selected by Thingtime CI Control"
required: false
default: "github-actions"
type: choice
options: [github-actions, vercel-sandbox]
runner_label:
description: "Internal: unique Vercel Sandbox self-hosted runner label"
required: false
default: ""
type: string
control_dispatch_id:
description: "Internal: Thingtime ci-dispatch id used for cross-run observability"
required: false
default: ""
type: string

permissions:
contents: read
Expand Down
73 changes: 30 additions & 43 deletions .github/workflows/promote-features-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@
# - Lopu also handles promotion conflicts and historical source context as part
# of its whole-repository review.
#
# This implementation lives on protected `github-actions`. Thin product-branch
# listeners invoke it with `workflow_call`; its own schedule/dispatch also run
# from the protected control plane.
# This implementation lives on protected `github-actions` and is callable only
# from the public Lopu manager. Push, schedule, and manual entry events belong
# to that one manager so a develop update creates one coherent repository run
# rather than several competing workflow runs.
#
# Token notes (same trade-off documented in sync-main-into-develop.yml):
# - Since GitHub's June 2026 behavior change, GITHUB_TOKEN-authored opened,
Expand All @@ -62,7 +63,7 @@
# directly. SYNC_BRANCHES_PAT and CONFLICT_RESOLVER_PAT are honoured as
# fallbacks when they carry the same required scope.

name: Promote features to main
name: Lopu internal feature promotion

on:
workflow_call:
Expand All @@ -75,42 +76,9 @@ on:
description: "How many recently merged develop PRs to scan (max 100)"
type: string
default: "50"
execution_provider:
description: "Internal: hosted compute selected by Thingtime CI Control"
required: false
default: "github-actions"
type: string
runner_label:
description: "Internal: unique Vercel Sandbox self-hosted runner label"
required: false
default: ""
type: string
control_dispatch_id:
description: "Internal: Thingtime ci-dispatch id used for cross-run observability"
required: false
default: ""
type: string
push:
branches: [develop]
schedule:
- cron: "43 */6 * * *"
workflow_dispatch:
inputs:
dry_run:
description: "Plan only — no branches, PRs, comments, closes, or retargets"
type: boolean
default: false
lookback:
description: "How many recently merged develop PRs to scan (max 100)"
required: false
default: "50"
# The reverse lane (owner request, 2026-08-12): one source, one target,
# per dispatch. Defaults preserve the standing develop → main lane for
# every push/schedule/listener run; a manual dispatch may promote
# main-only CI work onto the control plane with
# source_branch=main target_branch=github-actions
# require_path_prefix=.github/ — the prefix guard keeps app-wide PRs
# (e.g. a merged develop → main promotion) out of a CI-scoped lane.
# per invocation. The public Lopu workflow exposes these only when its
# explicit feature-promotion maintenance operation is selected.
source_branch:
description: "Branch whose merged PRs are promoted (default develop)"
required: false
Expand All @@ -130,8 +98,7 @@ on:
description: "Internal: hosted compute selected by Thingtime CI Control"
required: false
default: "github-actions"
type: choice
options: [github-actions, vercel-sandbox]
type: string
runner_label:
description: "Internal: unique Vercel Sandbox self-hosted runner label"
required: false
Expand All @@ -155,6 +122,15 @@ concurrency:

jobs:
route:
# CI Control's public provider contract intentionally carries only the
# standing develop→main lane. An explicit reverse/custom lane contains
# additional branch/path authority, so keep that owner-requested operation
# on the reviewed GitHub runner instead of silently dropping its inputs
# while offloading compute.
if: >-
inputs.source_branch == ''
&& inputs.target_branch == ''
&& inputs.require_path_prefix == ''
uses: ./.github/workflows/ci-provider-router.yml
with:
workflow: promote-features
Expand All @@ -167,8 +143,19 @@ jobs:

promote:
needs: route
if: needs.route.outputs.execute == 'true'
runs-on: ${{ needs.route.outputs.runner_label || 'ubuntu-latest' }}
if: >-
always()
&& ((inputs.source_branch != ''
|| inputs.target_branch != ''
|| inputs.require_path_prefix != '')
|| needs.route.outputs.execute == 'true')
runs-on: >-
${{ (inputs.source_branch != ''
|| inputs.target_branch != ''
|| inputs.require_path_prefix != '')
&& 'ubuntu-latest'
|| needs.route.outputs.runner_label
|| 'ubuntu-latest' }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
Expand Down
Loading
Loading