mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-11-17 21:11:54 +00:00
fix(ci): OpenCode plugin publish jobs detect plugin changes again (#20373)
The bump step runs inside the plugin folder, where git resolved the repo-root pathspec to a folder that does not exist, so every release logged 'no plugin changes'. Compare '-- .' instead, and bump @omniroute/opencode-plugin to 0.2.2 for the changes that predate v3.8.53. Merged by owner decision before the gates finished.
This commit is contained in:
committed by
GitHub
parent
8c60cc2d6e
commit
e9c9f1dd84
12
.github/workflows/npm-publish.yml
vendored
12
.github/workflows/npm-publish.yml
vendored
@@ -537,8 +537,10 @@ jobs:
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 3) Check if plugin dir actually changed since that tag
|
||||
if git diff --quiet "$PREV_TAG" -- "@omniroute/opencode-plugin/"; then
|
||||
# 3) Check if plugin dir actually changed since that tag. The step runs inside the
|
||||
# plugin folder and git resolves pathspecs against the current directory, so the
|
||||
# folder is "." here (the repo-root path matched nothing and no change was ever seen).
|
||||
if git diff --quiet "$PREV_TAG" -- .; then
|
||||
echo "⏭️ No plugin changes since $PREV_TAG — nothing to publish."
|
||||
echo "bumped=false" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
@@ -627,8 +629,10 @@ jobs:
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 3) Check if plugin-v2 dir actually changed since that tag
|
||||
if git diff --quiet "$PREV_TAG" -- "@omniroute/opencode-plugin-v2/"; then
|
||||
# 3) Check if plugin-v2 dir actually changed since that tag. The step runs inside the
|
||||
# plugin folder and git resolves pathspecs against the current directory, so the
|
||||
# folder is "." here (the repo-root path matched nothing and no change was ever seen).
|
||||
if git diff --quiet "$PREV_TAG" -- .; then
|
||||
echo "⏭️ No plugin-v2 changes since $PREV_TAG — nothing to publish."
|
||||
echo "bumped=false" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
|
||||
4
@omniroute/opencode-plugin/package-lock.json
generated
4
@omniroute/opencode-plugin/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@omniroute/opencode-plugin",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@omniroute/opencode-plugin",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"zod": "^4.6.7"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@omniroute/opencode-plugin",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.2",
|
||||
"description": "OpenCode plugin for the OmniRoute AI Gateway. Drives dynamic model discovery, /connect auth flow, and multi-instance OmniRoute providers via the official @opencode-ai/plugin contract.",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
1
changelog.d/fixes/20373-npm-plugin-autobump-path.md
Normal file
1
changelog.d/fixes/20373-npm-plugin-autobump-path.md
Normal file
@@ -0,0 +1 @@
|
||||
- **fix(ci):** the OpenCode plugin publish jobs detect plugin changes again (the bump step compared a repo-root path from inside the plugin folder and never saw a change), so `@omniroute/opencode-plugin` 0.2.2 and `@omniroute/opencode-plugin-v2` 0.1.1 ship the code that changed since July and October ([#20373](https://github.com/cheaper-inference/OmniRoute/pull/20373))
|
||||
133
tests/unit/build/npm-publish-plugin-autobump.test.mjs
Normal file
133
tests/unit/build/npm-publish-plugin-autobump.test.mjs
Normal file
@@ -0,0 +1,133 @@
|
||||
// The OpenCode plugins are published by npm-publish.yml, which bumps a plugin's patch version
|
||||
// when its folder changed since the previous release tag. The bump step runs with
|
||||
// `working-directory: @omniroute/<plugin>`, and git resolves a pathspec against the current
|
||||
// directory: `git diff <tag> -- "@omniroute/<plugin>/"` looked for
|
||||
// @omniroute/<plugin>/@omniroute/<plugin>/, always found nothing, and every release logged
|
||||
// "No plugin changes since <tag> — nothing to publish". @omniroute/opencode-plugin-v2 changed
|
||||
// 18 files between v3.8.52 and v3.8.53 and stayed at 0.1.0 on npm.
|
||||
//
|
||||
// This test runs the real step script from the workflow inside a throwaway git repository.
|
||||
import assert from "node:assert/strict";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import test from "node:test";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import YAML from "yaml";
|
||||
|
||||
const root = fileURLToPath(new URL("../../../", import.meta.url));
|
||||
const workflow = YAML.parse(readFileSync(join(root, ".github/workflows/npm-publish.yml"), "utf8"));
|
||||
|
||||
const PLUGIN_JOBS = {
|
||||
"publish-opencode-plugin": "@omniroute/opencode-plugin",
|
||||
"publish-opencode-plugin-v2": "@omniroute/opencode-plugin-v2",
|
||||
};
|
||||
|
||||
function bumpStep(jobName) {
|
||||
const step = workflow.jobs[jobName].steps.find((s) => s.id === "bump");
|
||||
assert.ok(step, `${jobName} has a step with id "bump"`);
|
||||
return step;
|
||||
}
|
||||
|
||||
function git(cwd, ...args) {
|
||||
const res = spawnSync("git", args, { cwd, encoding: "utf8" });
|
||||
assert.equal(res.status, 0, `git ${args.join(" ")}: ${res.stderr}`);
|
||||
return res.stdout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a repo with tags v1.0.0 (previous release) and v1.0.1 (current), where the plugin
|
||||
* folder changed between them only when `pluginChanged` is true, then runs the bump step in
|
||||
* the plugin folder with a fake `npm` that reports the current version as already published.
|
||||
*/
|
||||
function runBump(jobName, { pluginChanged }) {
|
||||
const pkgDir = PLUGIN_JOBS[jobName];
|
||||
const dir = mkdtempSync(join(tmpdir(), "npm-plugin-bump-"));
|
||||
try {
|
||||
const repo = join(dir, "repo");
|
||||
const bin = join(dir, "bin");
|
||||
mkdirSync(join(repo, pkgDir), { recursive: true });
|
||||
mkdirSync(bin);
|
||||
git(repo, "init", "-q");
|
||||
git(repo, "config", "user.email", "test@example.com");
|
||||
git(repo, "config", "user.name", "test");
|
||||
git(repo, "config", "commit.gpgsign", "false");
|
||||
writeFileSync(
|
||||
join(repo, pkgDir, "package.json"),
|
||||
`${JSON.stringify({ name: pkgDir, version: "0.1.0" }, null, 2)}\n`
|
||||
);
|
||||
writeFileSync(join(repo, pkgDir, "index.js"), "export const v = 1;\n");
|
||||
writeFileSync(join(repo, "README.md"), "root\n");
|
||||
git(repo, "add", "-A");
|
||||
git(repo, "commit", "-q", "-m", "previous release");
|
||||
git(repo, "tag", "v1.0.0");
|
||||
if (pluginChanged) {
|
||||
writeFileSync(join(repo, pkgDir, "index.js"), "export const v = 2;\n");
|
||||
} else {
|
||||
writeFileSync(join(repo, "README.md"), "root changed, plugin untouched\n");
|
||||
}
|
||||
git(repo, "add", "-A");
|
||||
git(repo, "commit", "-q", "-m", "current release");
|
||||
git(repo, "tag", "v1.0.1");
|
||||
|
||||
// Fake npm: `npm view <name>@<v> version` says it is published; `npm version patch` bumps.
|
||||
const fakeNpm = join(bin, "npm");
|
||||
writeFileSync(
|
||||
fakeNpm,
|
||||
[
|
||||
"#!/usr/bin/env node",
|
||||
'const fs = require("node:fs");',
|
||||
"const [cmd, spec] = process.argv.slice(2);",
|
||||
'if (cmd === "view") { console.log(spec.slice(spec.lastIndexOf("@") + 1)); process.exit(0); }',
|
||||
'if (cmd === "version") {',
|
||||
' const p = JSON.parse(fs.readFileSync("package.json", "utf8"));',
|
||||
' const [a, b, c] = p.version.split(".").map(Number);',
|
||||
" p.version = `${a}.${b}.${c + 1}`;",
|
||||
' fs.writeFileSync("package.json", JSON.stringify(p, null, 2) + "\\n");',
|
||||
" process.exit(0);",
|
||||
"}",
|
||||
"process.exit(1);",
|
||||
].join("\n")
|
||||
);
|
||||
chmodSync(fakeNpm, 0o755);
|
||||
|
||||
const step = bumpStep(jobName);
|
||||
const output = join(dir, "github_output");
|
||||
writeFileSync(output, "");
|
||||
const res = spawnSync("bash", ["-e", "-c", step.run], {
|
||||
cwd: join(repo, step["working-directory"]),
|
||||
encoding: "utf8",
|
||||
env: {
|
||||
PATH: `${bin}:${process.env.PATH}`,
|
||||
HOME: dir,
|
||||
GITHUB_OUTPUT: output,
|
||||
CURRENT_TAG: "v1.0.1",
|
||||
},
|
||||
});
|
||||
assert.equal(res.status, 0, `bump step failed: ${res.stdout}\n${res.stderr}`);
|
||||
const version = JSON.parse(readFileSync(join(repo, pkgDir, "package.json"), "utf8")).version;
|
||||
return { stdout: res.stdout, output: readFileSync(output, "utf8"), version };
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
|
||||
for (const [jobName, pkgDir] of Object.entries(PLUGIN_JOBS)) {
|
||||
test(`${jobName}: bump step runs inside ${pkgDir}`, () => {
|
||||
assert.equal(bumpStep(jobName)["working-directory"], pkgDir);
|
||||
});
|
||||
|
||||
test(`${jobName}: a change in the plugin folder since the previous tag bumps the patch version`, () => {
|
||||
const result = runBump(jobName, { pluginChanged: true });
|
||||
assert.match(result.output, /^bumped=true$/m, result.stdout);
|
||||
assert.equal(result.version, "0.1.1");
|
||||
});
|
||||
|
||||
test(`${jobName}: a release that leaves the plugin folder untouched does not bump`, () => {
|
||||
const result = runBump(jobName, { pluginChanged: false });
|
||||
assert.match(result.output, /^bumped=false$/m, result.stdout);
|
||||
assert.equal(result.version, "0.1.0");
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user