Files
opencode-power-pack/tests/github-packages.test.mjs
Wayner Barrios 689c148ddf Publish verified release artifacts without rerunning lifecycle scripts
Rely on the required release CI before uploading to GitHub Packages so the immutable version 0.5.0 tag can be mirrored without inheriting registry configuration inside package tests.
2026-08-17 14:11:17 -05:00

41 lines
1.6 KiB
JavaScript

import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
import test from "node:test";
import { fileURLToPath } from "node:url";
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const WORKFLOW = fs.readFileSync(
path.join(ROOT, ".github", "workflows", "publish-github-package.yml"),
"utf8",
);
const README = fs.readFileSync(path.join(ROOT, "README.md"), "utf8");
test("GitHub Packages workflow publishes an exact release tag with least privilege", () => {
assert.match(WORKFLOW, /release:\n\s+types: \[published\]/);
assert.match(WORKFLOW, /workflow_dispatch:/);
assert.match(WORKFLOW, /contents: read\n\s+packages: write/);
assert.match(WORKFLOW, /ref: \$\{\{ env\.RELEASE_REF \}\}/);
assert.match(WORKFLOW, /Release ref .* does not match package version/);
assert.match(WORKFLOW, /registry-url: "https:\/\/npm\.pkg\.github\.com"/);
assert.match(WORKFLOW, /scope: "@waybarrios"/);
assert.match(
WORKFLOW,
/npm publish --ignore-scripts --registry=https:\/\/npm\.pkg\.github\.com --access public/,
);
assert.match(WORKFLOW, /NODE_AUTH_TOKEN: \$\{\{ secrets\.GITHUB_TOKEN \}\}/);
});
test("README distinguishes npmjs installation from the GitHub Packages mirror", () => {
assert.match(README, /### GitHub Packages mirror/);
assert.match(
README,
/npm login --scope=@waybarrios --auth-type=legacy --registry=https:\/\/npm\.pkg\.github\.com/,
);
assert.match(
README,
/npm install --global @waybarrios\/opencode-power-pack --registry=https:\/\/npm\.pkg\.github\.com/,
);
assert.match(README, /personal access token \(classic\).*`read:packages`/);
});