summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLuke Parker <[email protected]>2026-04-25 10:32:41 +1000
committerGitHub <[email protected]>2026-04-25 10:32:41 +1000
commit386091b79a76ebc49ce2eba9628a2f93ce0061ee (patch)
treed34a1eb24c22afc10b6c6459ec68f4b62d145237
parent1e4b7b5451dc924515444c006f6babbb9f24bc85 (diff)
downloadopencode-386091b79a76ebc49ce2eba9628a2f93ce0061ee.tar.gz
opencode-386091b79a76ebc49ce2eba9628a2f93ce0061ee.zip
fix: validate beta before pushing (#24230)
-rwxr-xr-xscript/beta.ts101
1 files changed, 60 insertions, 41 deletions
diff --git a/script/beta.ts b/script/beta.ts
index 7c558d1e7..bed777e84 100755
--- a/script/beta.ts
+++ b/script/beta.ts
@@ -81,6 +81,39 @@ async function build() {
}
}
+async function validate() {
+ if (!(await typecheck())) return false
+ if (!(await build())) return false
+ return true
+}
+
+async function commitSmokeChanges() {
+ const out = await $`git status --porcelain`.text()
+ if (!out.trim()) {
+ console.log("Smoke check passed")
+ return true
+ }
+
+ try {
+ await $`git add -A`
+ await $`git commit -m "Fix beta integration"`
+ } catch (err) {
+ console.log(`Failed to commit smoke fixes: ${err}`)
+ return false
+ }
+
+ if (!(await validate())) return false
+
+ const left = await $`git status --porcelain`.text()
+ if (!left.trim()) {
+ console.log("Smoke check passed")
+ return true
+ }
+
+ console.log(`Smoke check left uncommitted changes:\n${left}`)
+ return false
+}
+
async function install() {
console.log(" Regenerating bun.lock...")
@@ -143,11 +176,15 @@ async function fix(pr: PR, files: string[], prs: PR[], applied: number[], idx: n
}
async function smoke(prs: PR[], applied: number[]) {
- console.log("\nRunning final smoke check with opencode...")
+ console.log("\nRunning final smoke check...")
+
+ if (await validate()) return commitSmokeChanges()
+
+ console.log("\nTrying to fix final smoke check with opencode...")
const done = lines(prs.filter((x) => applied.includes(x.number)))
const prompt = [
- "The beta merge batch is complete.",
+ "The beta merge batch is complete, but the deterministic final smoke check failed.",
`Merged PRs on HEAD:\n${done}`,
"Run `bun typecheck` at the repo root.",
"Run `./script/build.ts --single` in `packages/opencode`.",
@@ -162,38 +199,8 @@ async function smoke(prs: PR[], applied: number[]) {
return false
}
- if (!(await typecheck())) {
- return false
- }
-
- if (!(await build())) {
- return false
- }
-
- const out = await $`git status --porcelain`.text()
- if (!out.trim()) {
- console.log("Smoke check passed")
- return true
- }
-
- try {
- await $`git add -A`
- await $`git commit -m "Fix beta integration"`
- } catch (err) {
- console.log(`Failed to commit smoke fixes: ${err}`)
- return false
- }
-
- if (!(await typecheck())) {
- return false
- }
-
- if (!(await build())) {
- return false
- }
-
- console.log("Smoke check passed")
- return true
+ if (!(await validate())) return false
+ return commitSmokeChanges()
}
async function main() {
@@ -294,17 +301,13 @@ async function main() {
throw new Error(`${failed.length} PR(s) failed to merge`)
}
- if (applied.length > 0) {
- console.log("\nSkipping final smoke check")
- }
-
console.log("\nChecking if beta branch has changes...")
await $`git fetch origin beta`
- const localTree = await $`git rev-parse beta^{tree}`.text()
+ const localTree = (await $`git rev-parse beta^{tree}`.text()).trim()
const remoteTrees = (await $`git log origin/dev..origin/beta --format=%T`.text()).split("\n")
- const matchIdx = remoteTrees.indexOf(localTree.trim())
+ const matchIdx = remoteTrees.indexOf(localTree)
if (matchIdx !== -1) {
if (matchIdx !== 0) {
console.log(`Beta branch contains this sync, but additional commits exist after it. Leaving beta branch as is.`)
@@ -314,7 +317,23 @@ async function main() {
return
}
- console.log("Force pushing beta branch...")
+ if (!(await smoke(prs, applied))) throw new Error("Final smoke check failed")
+
+ await $`git fetch origin beta`
+
+ const validatedTree = (await $`git rev-parse beta^{tree}`.text()).trim()
+ const remoteTreesAfterSmoke = (await $`git log origin/dev..origin/beta --format=%T`.text()).split("\n")
+ const matchIdxAfterSmoke = remoteTreesAfterSmoke.indexOf(validatedTree)
+ if (matchIdxAfterSmoke !== -1) {
+ if (matchIdxAfterSmoke !== 0) {
+ console.log(`Beta branch contains this validated sync, but additional commits exist after it. Leaving beta branch as is.`)
+ } else {
+ console.log("Validated beta branch now matches remote contents, no push needed")
+ }
+ return
+ }
+
+ console.log("Force pushing validated beta branch...")
await $`git push origin beta --force --no-verify`
console.log("Successfully synced beta branch")