Skip to content

Commit 7654ce7

Browse files
committed
fix(ci): correct env-var count after version define removal
1 parent 10cf305 commit 7654ce7

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

‎config/env-var-count-budget.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Distinct OPENCLAW_* names in production source under src, packages, and extensions.
22
# Ratchet: lower this number when cleanup removes names; never raise it without owner approval.
33
# Worker bundle installation no longer injects OPENCLAW_STATE_DIR into a remote npm process.
4-
# The retired compile-time version define no longer contributes OPENCLAW_VERSION.
5-
501
4+
# OPENCLAW_VERSION remains a supported runtime override after compile-time define retirement.
5+
502

‎scripts/check-env-var-count.mts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ export function main(argv: string[] = process.argv.slice(2), root = process.cwd(
125125
: fs.readFileSync(path.join(root, BUDGET_PATH), "utf8");
126126
const budget = parseBudget(budgetSource);
127127
const baseBudget = readBaseBudget(root, baseRef);
128-
const approvedGrowth = baseBudget === 502 && budget === 503;
128+
const approvedGrowth =
129+
(baseBudget === 501 && budget === 502) || (baseBudget === 502 && budget === 503);
129130
if (baseBudget !== null && budget > baseBudget && !approvedGrowth) {
130131
throw new Error(`OPENCLAW_* budget grew from ${baseBudget} to ${budget}`);
131132
}

‎test/scripts/check-env-var-count.test.ts‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,16 @@ describe("check-env-var-count", () => {
156156
expect(() => main(["--base", "HEAD"], root)).toThrow(/exceeds budget|over budget/u);
157157
});
158158

159-
it("allows only the owner-approved 502 to 503 budget increase", () => {
159+
it.each([
160+
[501, 502],
161+
[502, 503],
162+
])("allows only the owner-approved %i to %i budget increase", (baseBudget, nextBudget) => {
160163
const root = tempDirs.make("openclaw-env-count-approved-grow-");
161164
fs.mkdirSync(path.join(root, "config"), { recursive: true });
162165
fs.mkdirSync(path.join(root, "src"), { recursive: true });
163-
const names = Array.from({ length: 504 }, (_, index) => `OPENCLAW_TEST_${index}`);
164-
fs.writeFileSync(path.join(root, "config/env-var-count-budget.txt"), "502\n");
165-
fs.writeFileSync(path.join(root, "src/runtime.ts"), names.slice(0, 502).join("\n"));
166+
const names = Array.from({ length: nextBudget + 1 }, (_, index) => `OPENCLAW_TEST_${index}`);
167+
fs.writeFileSync(path.join(root, "config/env-var-count-budget.txt"), `${baseBudget}\n`);
168+
fs.writeFileSync(path.join(root, "src/runtime.ts"), names.slice(0, baseBudget).join("\n"));
166169
execFileSync("git", ["init"], { cwd: root, stdio: "ignore" });
167170
execFileSync("git", ["add", "."], { cwd: root, stdio: "ignore" });
168171
execFileSync(
@@ -171,12 +174,12 @@ describe("check-env-var-count", () => {
171174
{ cwd: root, stdio: "ignore" },
172175
);
173176

174-
fs.writeFileSync(path.join(root, "src/runtime.ts"), names.slice(0, 503).join("\n"));
175-
fs.writeFileSync(path.join(root, "config/env-var-count-budget.txt"), "503\n");
177+
fs.writeFileSync(path.join(root, "src/runtime.ts"), names.slice(0, nextBudget).join("\n"));
178+
fs.writeFileSync(path.join(root, "config/env-var-count-budget.txt"), `${nextBudget}\n`);
176179
expect(() => main(["--base", "HEAD"], root)).not.toThrow();
177180

178181
fs.writeFileSync(path.join(root, "src/runtime.ts"), names.join("\n"));
179-
fs.writeFileSync(path.join(root, "config/env-var-count-budget.txt"), "504\n");
182+
fs.writeFileSync(path.join(root, "config/env-var-count-budget.txt"), `${nextBudget + 1}\n`);
180183
expect(() => main(["--base", "HEAD"], root)).toThrow(/budget grew/u);
181184
});
182185

0 commit comments

Comments
 (0)