@rightkit/ci 0.0.0-stage → 0.2.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +177 -2
- package/adopt.mjs +96 -0
- package/checkout.mjs +93 -0
- package/checkout.test.mjs +91 -0
- package/cli/right-git.mjs +218 -0
- package/cli.test.mjs +68 -0
- package/drift.mjs +201 -0
- package/drift.test.mjs +203 -0
- package/guard-coverage.test.mjs +236 -0
- package/install.mjs +81 -0
- package/manifest.mjs +1862 -0
- package/manifest.schema.json +286 -0
- package/manifest.test.mjs +487 -0
- package/ownership-registration.mjs +33 -0
- package/ownership-registration.test.mjs +20 -0
- package/pack-smoke.test.mjs +55 -0
- package/package.json +38 -4
- package/pnpm-lock-patch.test.mjs +161 -0
- package/policy/visibility-gate.mjs +168 -0
- package/render.mjs +69 -0
- package/render.test.mjs +1722 -0
- package/rightkit-ownership.json +15 -0
- package/sync.mjs +180 -0
- package/sync.test.mjs +147 -0
- package/templates/ci.yml +50 -0
- package/templates/package-smoke.yml +38 -0
- package/templates/profiles/rust-hybrid/ci.yml +127 -0
- package/templates/profiles/rust-hybrid/regenerate.yml +96 -0
- package/templates/profiles/rust-hybrid/release-candidate.yml +193 -0
- package/templates/publish-npm.yml +72 -0
- package/templates/publish-package-managers.yml +158 -0
- package/templates/qualification.yml +94 -0
- package/templates/regenerate.yml +80 -0
- package/templates/release-candidate.yml +57 -0
- package/test-support.mjs +34 -0
- package/uninstall.mjs +36 -0
- package/uninstall.test.mjs +89 -0
- package/visibility-gate.test.mjs +141 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"package": "@rightkit/ci",
|
|
3
|
+
"capabilities": [
|
|
4
|
+
{
|
|
5
|
+
"capability": "github-workflows",
|
|
6
|
+
"summary": "Public-repo-only GitHub Actions workflow layer: templates, visibility gate, sync/drift/adopt/uninstall for right-git.; declaration-only detection (no precise implementation fingerprint)",
|
|
7
|
+
"fingerprints": [],
|
|
8
|
+
"detection": "declaration-only",
|
|
9
|
+
"policyNotes": [
|
|
10
|
+
"Package contract retained; dependency declarations do not verify integration.",
|
|
11
|
+
"No precise implementation fingerprint; declaration-only inventory, never enforced ownership or verified integration."
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
package/sync.mjs
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// Render templates for a target repo's manifest and install them into
|
|
2
|
+
// <repo>/.github/workflows/, showing a diff before applying (DESIGN.md §4).
|
|
3
|
+
// Refuses private/internal/unknown-visibility repos — no override (I1).
|
|
4
|
+
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { assertPublic } from "./policy/visibility-gate.mjs";
|
|
9
|
+
import { loadManifest, LANE_FILENAMES, buildRenderContext } from "./manifest.mjs";
|
|
10
|
+
import { applyCheckoutOptions } from "./checkout.mjs";
|
|
11
|
+
import { renderTemplate, MANAGED_MARKER } from "./render.mjs";
|
|
12
|
+
|
|
13
|
+
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)));
|
|
14
|
+
const TEMPLATES_DIR = path.join(packageRoot, "templates");
|
|
15
|
+
const WORKFLOWS_SUBDIR = path.join(".github", "workflows");
|
|
16
|
+
const PUBLISHED_NPM_VERSION = /^\d+\.\d+\.\d+$/;
|
|
17
|
+
|
|
18
|
+
function releaseChainDependencyError(repoPath, manifest) {
|
|
19
|
+
if (!manifest.candidate?.releaseChain) return null;
|
|
20
|
+
let pkg;
|
|
21
|
+
try {
|
|
22
|
+
pkg = JSON.parse(fs.readFileSync(path.join(repoPath, "package.json"), "utf8"));
|
|
23
|
+
} catch {
|
|
24
|
+
return "release-candidate releaseChain requires a readable package.json with direct devDependency @rightkit/release";
|
|
25
|
+
}
|
|
26
|
+
const version = pkg.devDependencies?.["@rightkit/release"];
|
|
27
|
+
if (typeof version !== "string" || !PUBLISHED_NPM_VERSION.test(version)) {
|
|
28
|
+
return "release-candidate releaseChain requires direct devDependency @rightkit/release pinned to a published npm version";
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Render every lane declared in the manifest. Returns { lane, filename, content }[]. */
|
|
34
|
+
export function renderLanes(manifest, repoPath) {
|
|
35
|
+
return manifest.lanes.map((lane) => {
|
|
36
|
+
const context = buildRenderContext(manifest, repoPath, lane);
|
|
37
|
+
const filename = LANE_FILENAMES[lane];
|
|
38
|
+
const templatePath = manifest.profile === "rust-hybrid"
|
|
39
|
+
? path.join(TEMPLATES_DIR, "profiles", "rust-hybrid", filename)
|
|
40
|
+
: path.join(TEMPLATES_DIR, filename);
|
|
41
|
+
const templateText = fs.readFileSync(templatePath, "utf8");
|
|
42
|
+
return { lane, filename, content: applyCheckoutOptions(renderTemplate(templateText, context), manifest) };
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** List files in <repo>/.github/workflows that carry the right-git managed marker. */
|
|
47
|
+
export function listManagedFiles(repoPath) {
|
|
48
|
+
const dir = path.join(repoPath, WORKFLOWS_SUBDIR);
|
|
49
|
+
let entries;
|
|
50
|
+
try {
|
|
51
|
+
entries = fs.readdirSync(dir);
|
|
52
|
+
} catch {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
return entries.filter((name) => {
|
|
56
|
+
if (!name.endsWith(".yml") && !name.endsWith(".yaml")) return false;
|
|
57
|
+
try {
|
|
58
|
+
const content = fs.readFileSync(path.join(dir, name), "utf8");
|
|
59
|
+
return content.startsWith(MANAGED_MARKER);
|
|
60
|
+
} catch {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Minimal line-based diff: common prefix/suffix trimmed, middle shown as -/+ . */
|
|
67
|
+
export function lineDiff(oldText, newText) {
|
|
68
|
+
const oldLines = oldText == null ? [] : oldText.split("\n");
|
|
69
|
+
const newLines = newText.split("\n");
|
|
70
|
+
let start = 0;
|
|
71
|
+
while (start < oldLines.length && start < newLines.length && oldLines[start] === newLines[start]) start++;
|
|
72
|
+
let oldEnd = oldLines.length;
|
|
73
|
+
let newEnd = newLines.length;
|
|
74
|
+
while (oldEnd > start && newEnd > start && oldLines[oldEnd - 1] === newLines[newEnd - 1]) {
|
|
75
|
+
oldEnd--;
|
|
76
|
+
newEnd--;
|
|
77
|
+
}
|
|
78
|
+
const out = [];
|
|
79
|
+
for (let i = start; i < oldEnd; i++) out.push(`-${oldLines[i]}`);
|
|
80
|
+
for (let i = start; i < newEnd; i++) out.push(`+${newLines[i]}`);
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Compute the sync plan without writing anything: visibility check, manifest
|
|
86
|
+
* load, per-lane render, diff against what's on disk, plus removal of any
|
|
87
|
+
* managed file whose lane fell out of the manifest.
|
|
88
|
+
* Returns a typed result — never throws.
|
|
89
|
+
*/
|
|
90
|
+
export async function planSync(repoPath, deps = {}, manifestOverride = null) {
|
|
91
|
+
const visibility = await assertPublic(repoPath, deps);
|
|
92
|
+
if (!visibility.allowed) {
|
|
93
|
+
return { ok: false, stage: "visibility", errors: [visibility.reason], changes: [] };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const loaded = manifestOverride === null
|
|
97
|
+
? loadManifest(repoPath)
|
|
98
|
+
: { ok: true, manifest: manifestOverride };
|
|
99
|
+
if (!loaded.ok) {
|
|
100
|
+
return { ok: false, stage: "manifest", errors: loaded.errors, changes: [] };
|
|
101
|
+
}
|
|
102
|
+
const dependencyError = releaseChainDependencyError(repoPath, loaded.manifest);
|
|
103
|
+
if (dependencyError) {
|
|
104
|
+
return { ok: false, stage: "dependency", errors: [dependencyError], changes: [] };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const rendered = renderLanes(loaded.manifest, repoPath);
|
|
108
|
+
const wantedFilenames = new Set(rendered.map((r) => r.filename));
|
|
109
|
+
const changes = [];
|
|
110
|
+
|
|
111
|
+
for (const { lane, filename, content } of rendered) {
|
|
112
|
+
const target = path.join(repoPath, WORKFLOWS_SUBDIR, filename);
|
|
113
|
+
let existing = null;
|
|
114
|
+
try {
|
|
115
|
+
existing = fs.readFileSync(target, "utf8");
|
|
116
|
+
} catch {
|
|
117
|
+
// not installed yet
|
|
118
|
+
}
|
|
119
|
+
if (existing === content) {
|
|
120
|
+
changes.push({ lane, filename, action: "unchanged", before: existing, diff: [] });
|
|
121
|
+
} else if (existing !== null && !existing.startsWith(MANAGED_MARKER)) {
|
|
122
|
+
changes.push({ lane, filename, action: "managed-conflict", before: existing, diff: [] });
|
|
123
|
+
} else {
|
|
124
|
+
changes.push({ lane, filename, action: existing === null ? "create" : "update", before: existing, diff: lineDiff(existing, content), content });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
for (const managedFilename of listManagedFiles(repoPath)) {
|
|
129
|
+
if (!wantedFilenames.has(managedFilename)) {
|
|
130
|
+
changes.push({ lane: null, filename: managedFilename, action: "remove", before: fs.readFileSync(path.join(repoPath, WORKFLOWS_SUBDIR, managedFilename), "utf8"), diff: [] });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const conflicts = changes.filter((change) => change.action === "managed-conflict");
|
|
135
|
+
return conflicts.length
|
|
136
|
+
? { ok: false, stage: "managed-conflict", errors: conflicts.map((change) => `${change.filename} is unmanaged`), changes }
|
|
137
|
+
: { ok: true, stage: "planned", errors: [], changes };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Apply a plan produced by planSync: write/update/remove files on disk. */
|
|
141
|
+
export function applyPlan(repoPath, plan) {
|
|
142
|
+
const dir = path.join(repoPath, WORKFLOWS_SUBDIR);
|
|
143
|
+
for (const change of plan.changes) {
|
|
144
|
+
if (change.action === "unchanged") continue;
|
|
145
|
+
const target = path.join(dir, change.filename);
|
|
146
|
+
let current = null;
|
|
147
|
+
try { current = fs.readFileSync(target, "utf8"); } catch {}
|
|
148
|
+
if (current !== change.before) {
|
|
149
|
+
return { ok: false, stage: "apply-conflict", errors: [`${change.filename} changed after planning`] };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
153
|
+
for (const change of plan.changes) {
|
|
154
|
+
const target = path.join(dir, change.filename);
|
|
155
|
+
if (change.action === "create" || change.action === "update") {
|
|
156
|
+
fs.writeFileSync(target, change.content, "utf8");
|
|
157
|
+
} else if (change.action === "remove") {
|
|
158
|
+
fs.rmSync(target, { force: true });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return { ok: true, stage: "applied", errors: [] };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Full sync: plan, print diff, apply unless dryRun. Returns the plan. */
|
|
165
|
+
export async function syncCommand(repoPath, { dryRun = false, deps = {} } = {}) {
|
|
166
|
+
const plan = await planSync(repoPath, deps);
|
|
167
|
+
if (!plan.ok) return plan;
|
|
168
|
+
|
|
169
|
+
for (const change of plan.changes) {
|
|
170
|
+
if (change.action === "unchanged") continue;
|
|
171
|
+
console.log(`\n${change.action.toUpperCase()} ${change.filename}`);
|
|
172
|
+
for (const line of change.diff) console.log(line);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (!dryRun) {
|
|
176
|
+
const applied = applyPlan(repoPath, plan);
|
|
177
|
+
if (!applied.ok) return { ...plan, ...applied };
|
|
178
|
+
}
|
|
179
|
+
return plan;
|
|
180
|
+
}
|
package/sync.test.mjs
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import test from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { applyPlan, planSync, syncCommand } from "./sync.mjs";
|
|
6
|
+
import { makeTempRepo, PUBLIC_DEPS, PRIVATE_DEPS, SAMPLE_MANIFEST } from "./test-support.mjs";
|
|
7
|
+
|
|
8
|
+
test("sync refuses a private repo and writes nothing", async () => {
|
|
9
|
+
const dir = makeTempRepo(SAMPLE_MANIFEST);
|
|
10
|
+
const result = await syncCommand(dir, { deps: PRIVATE_DEPS });
|
|
11
|
+
assert.equal(result.ok, false);
|
|
12
|
+
assert.equal(result.stage, "visibility");
|
|
13
|
+
assert.equal(fs.existsSync(path.join(dir, ".github", "workflows")), false);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("sync writes one rendered file per lane for a public repo", async () => {
|
|
17
|
+
const dir = makeTempRepo(SAMPLE_MANIFEST);
|
|
18
|
+
const result = await syncCommand(dir, { deps: PUBLIC_DEPS });
|
|
19
|
+
assert.equal(result.ok, true);
|
|
20
|
+
for (const filename of ["ci.yml", "package-smoke.yml"]) {
|
|
21
|
+
assert.ok(fs.existsSync(path.join(dir, ".github", "workflows", filename)), `${filename} was not written`);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("sync --dry-run plans changes without writing files", async () => {
|
|
26
|
+
const dir = makeTempRepo(SAMPLE_MANIFEST);
|
|
27
|
+
const result = await syncCommand(dir, { deps: PUBLIC_DEPS, dryRun: true });
|
|
28
|
+
assert.equal(result.ok, true);
|
|
29
|
+
assert.ok(result.changes.some((c) => c.action === "create"));
|
|
30
|
+
assert.equal(fs.existsSync(path.join(dir, ".github", "workflows")), false);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("sync is idempotent: a second run reports no changes", async () => {
|
|
34
|
+
const dir = makeTempRepo(SAMPLE_MANIFEST);
|
|
35
|
+
await syncCommand(dir, { deps: PUBLIC_DEPS });
|
|
36
|
+
const second = await syncCommand(dir, { deps: PUBLIC_DEPS });
|
|
37
|
+
assert.ok(second.changes.every((c) => c.action === "unchanged"));
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("sync removes a workflow file for a lane dropped from the manifest", async () => {
|
|
41
|
+
const dir = makeTempRepo(SAMPLE_MANIFEST);
|
|
42
|
+
await syncCommand(dir, { deps: PUBLIC_DEPS });
|
|
43
|
+
fs.writeFileSync(path.join(dir, ".rightgit.json"), `${JSON.stringify({ ...SAMPLE_MANIFEST, lanes: ["ci"] }, null, 2)}\n`, "utf8");
|
|
44
|
+
const result = await syncCommand(dir, { deps: PUBLIC_DEPS });
|
|
45
|
+
assert.equal(result.ok, true);
|
|
46
|
+
assert.equal(fs.existsSync(path.join(dir, ".github", "workflows", "package-smoke.yml")), false);
|
|
47
|
+
assert.ok(fs.existsSync(path.join(dir, ".github", "workflows", "ci.yml")));
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("sync reports manifest errors instead of writing files", async () => {
|
|
51
|
+
const dir = makeTempRepo(null);
|
|
52
|
+
const result = await syncCommand(dir, { deps: PUBLIC_DEPS });
|
|
53
|
+
assert.equal(result.ok, false);
|
|
54
|
+
assert.equal(result.stage, "manifest");
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test("sync rejects a Membrane-like release chain without root @rightkit/release", async () => {
|
|
58
|
+
const manifest = {
|
|
59
|
+
schemaVersion: 1,
|
|
60
|
+
compile: "github-actions-only",
|
|
61
|
+
lanes: ["ci", "release-candidate"],
|
|
62
|
+
matrix: { os: ["windows-2025", "macos-15"], node: ["22.23.2"] },
|
|
63
|
+
packageManager: "pnpm@11.24.0",
|
|
64
|
+
templateVersion: "1.5.0",
|
|
65
|
+
profile: "rust-hybrid",
|
|
66
|
+
gate: { path: "scripts/ci/run-ci.sh" },
|
|
67
|
+
candidate: {
|
|
68
|
+
buildScript: "release:candidate:build",
|
|
69
|
+
checkScript: "release:candidate:check",
|
|
70
|
+
admissionScript: "release:admit",
|
|
71
|
+
stageSummaryScript: "release:stage-summary",
|
|
72
|
+
artifactRoot: "membrane-release-candidate",
|
|
73
|
+
os: ["windows-2025", "macos-15"],
|
|
74
|
+
signWindows: true,
|
|
75
|
+
signMacos: true,
|
|
76
|
+
releaseChain: {
|
|
77
|
+
evidenceVerificationScript: "release:verify-evidence",
|
|
78
|
+
windowsFinalizeScript: "release:finalize:windows",
|
|
79
|
+
macosFinalizeScript: "release:finalize:macos",
|
|
80
|
+
installedQualificationScript: "release:qualify:installed",
|
|
81
|
+
publishScript: "release:publish:qualified",
|
|
82
|
+
qualificationRunnerVariable: "MEMBRANE_QUALIFICATION_RUNNER_LABEL",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
const dir = makeTempRepo(manifest, { packageJson: { name: "membrane", devDependencies: { "@rightkit/ci": "0.2.13" } } });
|
|
87
|
+
const missing = await syncCommand(dir, { deps: PUBLIC_DEPS });
|
|
88
|
+
assert.equal(missing.ok, false);
|
|
89
|
+
assert.equal(missing.stage, "dependency");
|
|
90
|
+
assert.match(missing.errors[0], /direct devDependency @rightkit\/release/);
|
|
91
|
+
assert.equal(fs.existsSync(path.join(dir, ".github", "workflows")), false);
|
|
92
|
+
|
|
93
|
+
fs.writeFileSync(path.join(dir, "package.json"), JSON.stringify({ name: "membrane", devDependencies: { "@rightkit/ci": "0.2.13", "@rightkit/release": "0.2.84" } }), "utf8");
|
|
94
|
+
const present = await syncCommand(dir, { deps: PUBLIC_DEPS });
|
|
95
|
+
assert.equal(present.ok, true);
|
|
96
|
+
assert.ok(fs.existsSync(path.join(dir, ".github", "workflows", "release-candidate.yml")));
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test("sync refuses an unmanaged same-name workflow", async () => {
|
|
100
|
+
const dir = makeTempRepo(SAMPLE_MANIFEST);
|
|
101
|
+
const target = path.join(dir, ".github", "workflows", "ci.yml");
|
|
102
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
103
|
+
fs.writeFileSync(target, "name: handwritten\n", "utf8");
|
|
104
|
+
const result = await syncCommand(dir, { deps: PUBLIC_DEPS });
|
|
105
|
+
assert.equal(result.stage, "managed-conflict");
|
|
106
|
+
assert.equal(fs.readFileSync(target, "utf8"), "name: handwritten\n");
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test("apply preflights every planned byte before writing", async () => {
|
|
110
|
+
const dir = makeTempRepo(SAMPLE_MANIFEST);
|
|
111
|
+
const plan = await planSync(dir, PUBLIC_DEPS);
|
|
112
|
+
const target = path.join(dir, ".github", "workflows", "ci.yml");
|
|
113
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
114
|
+
fs.writeFileSync(target, "raced\n", "utf8");
|
|
115
|
+
const applied = applyPlan(dir, plan);
|
|
116
|
+
assert.equal(applied.stage, "apply-conflict");
|
|
117
|
+
assert.equal(fs.existsSync(path.join(dir, ".github", "workflows", "package-smoke.yml")), false);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// F15 end-to-end: a hostile `.rightgit.json` on disk — the real attack
|
|
121
|
+
// surface, not just the in-memory validateManifest() unit — must be refused
|
|
122
|
+
// at the manifest stage, before renderLanes() (and therefore render.mjs's
|
|
123
|
+
// unescaped `${TOKEN}` substitution) ever sees the payload. This is the
|
|
124
|
+
// concrete proof that "none survive into rendered output": nothing is
|
|
125
|
+
// rendered or written at all when the manifest is hostile. Covers a family
|
|
126
|
+
// of payloads across the fields that flow into the credential-bearing
|
|
127
|
+
// publish-package-managers lane.
|
|
128
|
+
const HOSTILE_MANIFESTS = [
|
|
129
|
+
{ tap: "acme/tap", formulaName: "${{ secrets.APPLE_CERTIFICATE }}" },
|
|
130
|
+
{ tap: "acme/tap", formulaName: "`whoami`" },
|
|
131
|
+
{ tap: "acme/tap", formulaName: "widgets\nrun: exit 1" },
|
|
132
|
+
{ tap: "acme/${{ secrets.X }}", formulaName: "widgets" },
|
|
133
|
+
];
|
|
134
|
+
|
|
135
|
+
for (const [i, homebrew] of HOSTILE_MANIFESTS.entries()) {
|
|
136
|
+
test(`F15: sync refuses a hostile manifest and writes nothing (payload ${i})`, async () => {
|
|
137
|
+
const dir = makeTempRepo({
|
|
138
|
+
...SAMPLE_MANIFEST,
|
|
139
|
+
lanes: ["publish-package-managers"],
|
|
140
|
+
publish: { homebrew, winget: { packageIdentifier: "Acme.Widgets" } },
|
|
141
|
+
});
|
|
142
|
+
const result = await syncCommand(dir, { deps: PUBLIC_DEPS });
|
|
143
|
+
assert.equal(result.ok, false);
|
|
144
|
+
assert.equal(result.stage, "manifest");
|
|
145
|
+
assert.equal(fs.existsSync(path.join(dir, ".github", "workflows")), false, "no workflow file may be written for a hostile manifest");
|
|
146
|
+
});
|
|
147
|
+
}
|
package/templates/ci.yml
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Managed by right-git — do not hand-edit. Run `right-git sync` to update.
|
|
2
|
+
# Template: ci.yml | Template version: ${TEMPLATE_VERSION}
|
|
3
|
+
name: ci
|
|
4
|
+
on:
|
|
5
|
+
pull_request:
|
|
6
|
+
push:
|
|
7
|
+
branches: [${DEFAULT_BRANCH}]
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
concurrency:
|
|
11
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
12
|
+
cancel-in-progress: ${CI_CANCEL_IN_PROGRESS}
|
|
13
|
+
# F5 fix: `private-repo-guard` carries no job-level `if`, so it always runs.
|
|
14
|
+
# Its one step's own `if` fires only when the repo is private, and `exit 1`
|
|
15
|
+
# then fails the JOB (loud, visible, non-zero) rather than the previous
|
|
16
|
+
# design of gating the whole job with `if: !private`, which made the guard
|
|
17
|
+
# step unreachable and left the run merely SKIPPED — indistinguishable from
|
|
18
|
+
# "nothing to do" instead of a failure nobody can miss. Every other job below
|
|
19
|
+
# depends on this one, so a skipped-by-failure guard blocks them too
|
|
20
|
+
# (GitHub's default `needs` semantics require the needed job to succeed).
|
|
21
|
+
jobs:
|
|
22
|
+
private-repo-guard:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- name: Refuse private repository
|
|
26
|
+
if: ${{ github.event.repository.private }}
|
|
27
|
+
run: |
|
|
28
|
+
echo "::error::right-git: repository is private; managed public-only workflows must not run here."
|
|
29
|
+
exit 1
|
|
30
|
+
test:
|
|
31
|
+
needs: [private-repo-guard]
|
|
32
|
+
strategy:
|
|
33
|
+
fail-fast: false
|
|
34
|
+
matrix:
|
|
35
|
+
os: ${OS_MATRIX}
|
|
36
|
+
node: ${NODE_MATRIX}
|
|
37
|
+
runs-on: ${{ matrix.os }}
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v5
|
|
40
|
+
- uses: actions/setup-node@v5
|
|
41
|
+
with:
|
|
42
|
+
node-version: ${{ matrix.node }}
|
|
43
|
+
package-manager-cache: false
|
|
44
|
+
${PACKAGE_MANAGER_SETUP}
|
|
45
|
+
- run: ${INSTALL_COMMAND}${PNPM_LOCK_PATCH_STEP}${SWIFT_PRIVATE_CONFIGURE_STEP}
|
|
46
|
+
- run: ${PM_RUN} test
|
|
47
|
+
- run: ${PM_RUN} test:random
|
|
48
|
+
- run: ${PM_RUN} test:all
|
|
49
|
+
- run: node scripts/ci/check-generated.mjs
|
|
50
|
+
- run: node scripts/ci/check-network-boundary.mjs${OWNERSHIP_STEP}${SWIFT_PRIVATE_CLEANUP_STEP}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Managed by right-git — do not hand-edit. Run `right-git sync` to update.
|
|
2
|
+
# Template: package-smoke.yml | Template version: ${TEMPLATE_VERSION}
|
|
3
|
+
# Adapted from Cortex's package.yml (DESIGN.md §6).
|
|
4
|
+
name: package-smoke
|
|
5
|
+
on:
|
|
6
|
+
pull_request:
|
|
7
|
+
push:
|
|
8
|
+
branches: [${DEFAULT_BRANCH}]
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
# F5 fix: see ci.yml for why the guard is its own always-runs job rather
|
|
12
|
+
# than a job-level `if: !private` (which only skipped instead of failing).
|
|
13
|
+
jobs:
|
|
14
|
+
private-repo-guard:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- name: Refuse private repository
|
|
18
|
+
if: ${{ github.event.repository.private }}
|
|
19
|
+
run: |
|
|
20
|
+
echo "::error::right-git: repository is private; managed public-only workflows must not run here."
|
|
21
|
+
exit 1
|
|
22
|
+
clean-tarball:
|
|
23
|
+
needs: [private-repo-guard]
|
|
24
|
+
strategy:
|
|
25
|
+
fail-fast: false
|
|
26
|
+
matrix:
|
|
27
|
+
os: ${OS_MATRIX}
|
|
28
|
+
runs-on: ${{ matrix.os }}
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v5
|
|
31
|
+
- uses: actions/setup-node@v5
|
|
32
|
+
with:
|
|
33
|
+
node-version: ${{ fromJSON('${NODE_MATRIX}')[0] }}
|
|
34
|
+
package-manager-cache: false
|
|
35
|
+
${PACKAGE_MANAGER_SETUP}
|
|
36
|
+
- run: ${INSTALL_COMMAND}
|
|
37
|
+
${OWNERSHIP_STEP}
|
|
38
|
+
- run: node scripts/test-package.mjs
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Managed by right-git — do not hand-edit. Run `right-git sync` to update.
|
|
2
|
+
# Template: profiles/rust-hybrid/ci.yml | Template version: ${TEMPLATE_VERSION}
|
|
3
|
+
name: ${ARTIFACT_PREFIX}-ci
|
|
4
|
+
on:
|
|
5
|
+
pull_request:
|
|
6
|
+
push:
|
|
7
|
+
branches: [${DEFAULT_BRANCH}]
|
|
8
|
+
${CI_DISPATCH_TRIGGER}permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
concurrency:
|
|
11
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
12
|
+
cancel-in-progress: ${CI_CANCEL_IN_PROGRESS}
|
|
13
|
+
jobs:
|
|
14
|
+
private-repo-guard:
|
|
15
|
+
runs-on: ubuntu-24.04
|
|
16
|
+
steps:
|
|
17
|
+
- name: Refuse private repository
|
|
18
|
+
if: ${{ github.event.repository.private }}
|
|
19
|
+
run: exit 1
|
|
20
|
+
ci:
|
|
21
|
+
needs: [private-repo-guard]
|
|
22
|
+
strategy:
|
|
23
|
+
fail-fast: false
|
|
24
|
+
matrix:
|
|
25
|
+
${CI_MATRIX_OS}
|
|
26
|
+
node: ${NODE_MATRIX}
|
|
27
|
+
runs-on: ${{ matrix.os }}
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
30
|
+
with:
|
|
31
|
+
fetch-depth: 0
|
|
32
|
+
- name: Restore last green commit marker
|
|
33
|
+
if: github.event_name != 'pull_request'
|
|
34
|
+
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
35
|
+
with:
|
|
36
|
+
path: ~/.right-git-last-green
|
|
37
|
+
key: ${ARTIFACT_PREFIX}-last-green-${{ matrix.os }}-${{ matrix.node }}-${{ github.ref_name }}-${{ github.sha }}
|
|
38
|
+
restore-keys: |
|
|
39
|
+
${ARTIFACT_PREFIX}-last-green-${{ matrix.os }}-${{ matrix.node }}-${{ github.ref_name }}-
|
|
40
|
+
- name: Detect Rust-affecting changes
|
|
41
|
+
id: rust-changes
|
|
42
|
+
shell: bash
|
|
43
|
+
env:
|
|
44
|
+
RIGHT_GIT_DIFF_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || '' }}
|
|
45
|
+
run: |
|
|
46
|
+
set -euo pipefail
|
|
47
|
+
changed=true
|
|
48
|
+
base="$RIGHT_GIT_DIFF_BASE"
|
|
49
|
+
if [[ "$GITHUB_EVENT_NAME" != "pull_request" ]]; then
|
|
50
|
+
# A push is compared with the last commit this job passed on, never with the previous
|
|
51
|
+
# push: a failed run followed by a non-Rust commit must still run the Rust checks.
|
|
52
|
+
# No marker, or a marker that is not an ancestor, means changed=true.
|
|
53
|
+
base=""
|
|
54
|
+
if [[ -f "$HOME/.right-git-last-green/sha" ]]; then
|
|
55
|
+
base="$(tr -d '[:space:]' < "$HOME/.right-git-last-green/sha")"
|
|
56
|
+
fi
|
|
57
|
+
if [[ "$base" =~ ^[0-9a-fA-F]{40}$ ]] && ! git merge-base --is-ancestor "$base" "$GITHUB_SHA" 2>/dev/null; then
|
|
58
|
+
base=""
|
|
59
|
+
fi
|
|
60
|
+
fi
|
|
61
|
+
if [[ "$base" =~ ^[0-9a-fA-F]{40}$ ]] && [[ ! "$base" =~ ^0{40}$ ]] && git cat-file -e "$base^{commit}" 2>/dev/null; then
|
|
62
|
+
if changed_paths="$(git diff --name-only --diff-filter=ACDMRTUXB "$base" "$GITHUB_SHA")"; then
|
|
63
|
+
changed=false
|
|
64
|
+
while IFS= read -r changed_path; do
|
|
65
|
+
case "$changed_path" in
|
|
66
|
+
*.rs|Cargo.toml|*/Cargo.toml|Cargo.lock|*/Cargo.lock|rust-toolchain|*/rust-toolchain|rust-toolchain.toml|*/rust-toolchain.toml|.cargo/*|*/.cargo/*|.rightgit.json|.github/workflows/*.yml|.github/workflows/*.yaml|${GATE_PATH})
|
|
67
|
+
changed=true
|
|
68
|
+
break
|
|
69
|
+
;;
|
|
70
|
+
esac
|
|
71
|
+
done <<< "$changed_paths"
|
|
72
|
+
fi
|
|
73
|
+
fi
|
|
74
|
+
printf 'changed=%s\n' "$changed" >> "$GITHUB_OUTPUT"
|
|
75
|
+
required="$changed"
|
|
76
|
+
if [[ "${RUST_REQUIRED_FOR_GATE}" == "true" ]]; then
|
|
77
|
+
required=true
|
|
78
|
+
fi
|
|
79
|
+
printf 'required=%s\n' "$required" >> "$GITHUB_OUTPUT"
|
|
80
|
+
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
|
81
|
+
with:
|
|
82
|
+
node-version: ${{ matrix.node }}
|
|
83
|
+
package-manager-cache: false
|
|
84
|
+
${PACKAGE_MANAGER_SETUP}
|
|
85
|
+
- run: ${INSTALL_COMMAND}${PNPM_LOCK_PATCH_STEP}
|
|
86
|
+
${OWNERSHIP_STEP}${CI_DERIVED_DATA_STEP}
|
|
87
|
+
- uses: dtolnay/rust-toolchain@f8be11a05b1d4f3fcebe6410cc16743212b999b0
|
|
88
|
+
if: steps.rust-changes.outputs.required == 'true'
|
|
89
|
+
with:
|
|
90
|
+
components: rustfmt, clippy
|
|
91
|
+
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
|
92
|
+
if: steps.rust-changes.outputs.required == 'true'
|
|
93
|
+
with:
|
|
94
|
+
workspaces: |
|
|
95
|
+
${RUST_CACHE_WORKSPACES}
|
|
96
|
+
shared-key: ${ARTIFACT_PREFIX}-rust
|
|
97
|
+
add-job-id-key: false
|
|
98
|
+
${RUST_CACHE_KEY} cache-workspace-crates: ${CI_CACHE_WORKSPACE_CRATES}
|
|
99
|
+
cache-on-failure: true
|
|
100
|
+
save-if: ${{ github.event_name != 'pull_request' }}
|
|
101
|
+
- uses: Mozilla-Actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
|
|
102
|
+
if: steps.rust-changes.outputs.required == 'true'
|
|
103
|
+
with:
|
|
104
|
+
version: "v0.16.0"${SWIFT_PRIVATE_CONFIGURE_STEP}
|
|
105
|
+
- run: bash ./${GATE_PATH}
|
|
106
|
+
env:
|
|
107
|
+
RIGHT_GIT_RUST_CHANGED: ${{ steps.rust-changes.outputs.changed }}
|
|
108
|
+
RIGHT_GIT_RUST_REQUIRED: ${{ steps.rust-changes.outputs.required }}
|
|
109
|
+
SCCACHE_GHA_ENABLED: "true"
|
|
110
|
+
RUSTC_WRAPPER: ${CI_RUSTC_WRAPPER}
|
|
111
|
+
CARGO_INCREMENTAL: "${CI_CARGO_INCREMENTAL}"
|
|
112
|
+
CARGO_PROFILE_DEV_DEBUG: "0"
|
|
113
|
+
CARGO_PROFILE_TEST_DEBUG: "0"${SWIFT_PRIVATE_CLEANUP_STEP}
|
|
114
|
+
- name: Record last green commit marker
|
|
115
|
+
if: github.event_name != 'pull_request'
|
|
116
|
+
shell: bash
|
|
117
|
+
run: |
|
|
118
|
+
set -euo pipefail
|
|
119
|
+
mkdir -p "$HOME/.right-git-last-green"
|
|
120
|
+
printf '%s\n' "$GITHUB_SHA" > "$HOME/.right-git-last-green/sha"
|
|
121
|
+
- name: Save last green commit marker
|
|
122
|
+
if: github.event_name != 'pull_request'
|
|
123
|
+
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
124
|
+
with:
|
|
125
|
+
path: ~/.right-git-last-green
|
|
126
|
+
key: ${ARTIFACT_PREFIX}-last-green-${{ matrix.os }}-${{ matrix.node }}-${{ github.ref_name }}-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
|
|
127
|
+
${QA_EVIDENCE_STEP}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Managed by right-git — do not hand-edit. Run `right-git sync` to update.
|
|
2
|
+
# Template: profiles/rust-hybrid/regenerate.yml | Template version: ${TEMPLATE_VERSION}
|
|
3
|
+
# Manual only. Runs the repository's regenerate script (derived artifacts,
|
|
4
|
+
# formatting, lockfile repair) and, when tracked files change, runs the ci
|
|
5
|
+
# gate on the result, pushes it to a right-git/regenerate-<run> branch and
|
|
6
|
+
# opens a pull request. It never writes to the default branch. Pull requests
|
|
7
|
+
# opened with the workflow token do not trigger pull_request workflows, which
|
|
8
|
+
# is why the gate runs here and the PR body links this run.
|
|
9
|
+
name: ${ARTIFACT_PREFIX}-regenerate
|
|
10
|
+
on:
|
|
11
|
+
workflow_dispatch:
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
concurrency:
|
|
15
|
+
group: ${ARTIFACT_PREFIX}-regenerate
|
|
16
|
+
cancel-in-progress: false
|
|
17
|
+
jobs:
|
|
18
|
+
private-repo-guard:
|
|
19
|
+
runs-on: ubuntu-24.04
|
|
20
|
+
steps:
|
|
21
|
+
- name: Refuse private repository
|
|
22
|
+
if: ${{ github.event.repository.private }}
|
|
23
|
+
run: exit 1
|
|
24
|
+
regenerate:
|
|
25
|
+
needs: [private-repo-guard]
|
|
26
|
+
if: ${{ github.event_name == 'workflow_dispatch' }}
|
|
27
|
+
runs-on: ubuntu-24.04
|
|
28
|
+
timeout-minutes: 60
|
|
29
|
+
permissions:
|
|
30
|
+
contents: write
|
|
31
|
+
pull-requests: write
|
|
32
|
+
steps:
|
|
33
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
34
|
+
with:
|
|
35
|
+
ref: ${{ github.event.repository.default_branch }}
|
|
36
|
+
fetch-depth: 0
|
|
37
|
+
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
|
38
|
+
with:
|
|
39
|
+
node-version: ${NODE_PUBLISH_VERSION}
|
|
40
|
+
package-manager-cache: false
|
|
41
|
+
${PACKAGE_MANAGER_SETUP}
|
|
42
|
+
- run: ${INSTALL_COMMAND}
|
|
43
|
+
${OWNERSHIP_STEP}
|
|
44
|
+
- uses: dtolnay/rust-toolchain@f8be11a05b1d4f3fcebe6410cc16743212b999b0
|
|
45
|
+
with:
|
|
46
|
+
components: rustfmt, clippy
|
|
47
|
+
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
|
48
|
+
with:
|
|
49
|
+
workspaces: |
|
|
50
|
+
${RUST_CACHE_WORKSPACES}
|
|
51
|
+
shared-key: ${ARTIFACT_PREFIX}-rust
|
|
52
|
+
add-job-id-key: false
|
|
53
|
+
${RUST_CACHE_KEY} cache-workspace-crates: ${CI_CACHE_WORKSPACE_CRATES}
|
|
54
|
+
cache-on-failure: true
|
|
55
|
+
save-if: false${SWIFT_PRIVATE_CONFIGURE_STEP}
|
|
56
|
+
- name: Regenerate derived artifacts
|
|
57
|
+
run: ${PM_RUN} ${REGENERATE_SCRIPT}
|
|
58
|
+
- name: Detect regenerated files
|
|
59
|
+
id: changes
|
|
60
|
+
shell: bash
|
|
61
|
+
run: |
|
|
62
|
+
set -euo pipefail
|
|
63
|
+
if [[ -z "$(git status --porcelain)" ]]; then
|
|
64
|
+
echo "Derived artifacts are already current."
|
|
65
|
+
printf 'changed=false\n' >> "$GITHUB_OUTPUT"
|
|
66
|
+
else
|
|
67
|
+
printf 'changed=true\n' >> "$GITHUB_OUTPUT"
|
|
68
|
+
fi
|
|
69
|
+
- name: Gate the regenerated tree
|
|
70
|
+
if: steps.changes.outputs.changed == 'true'
|
|
71
|
+
run: bash ./${GATE_PATH}
|
|
72
|
+
env:
|
|
73
|
+
RIGHT_GIT_RUST_CHANGED: "true"
|
|
74
|
+
RIGHT_GIT_RUST_REQUIRED: "true"
|
|
75
|
+
CARGO_INCREMENTAL: "0"
|
|
76
|
+
CARGO_PROFILE_DEV_DEBUG: "0"
|
|
77
|
+
CARGO_PROFILE_TEST_DEBUG: "0"${SWIFT_PRIVATE_CLEANUP_STEP}
|
|
78
|
+
- name: Open a pull request with the regenerated files
|
|
79
|
+
if: steps.changes.outputs.changed == 'true'
|
|
80
|
+
shell: bash
|
|
81
|
+
env:
|
|
82
|
+
GH_TOKEN: ${{ github.token }}
|
|
83
|
+
RIGHT_GIT_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
|
|
84
|
+
RIGHT_GIT_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
85
|
+
run: |
|
|
86
|
+
set -euo pipefail
|
|
87
|
+
branch="right-git/regenerate-${{ github.run_id }}-${{ github.run_attempt }}"
|
|
88
|
+
git config user.name "github-actions[bot]"
|
|
89
|
+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
90
|
+
git checkout -b "$branch"
|
|
91
|
+
git add -A
|
|
92
|
+
git commit -m "Regenerate derived artifacts"
|
|
93
|
+
git push origin "HEAD:refs/heads/$branch"
|
|
94
|
+
gh pr create --base "$RIGHT_GIT_DEFAULT_BRANCH" --head "$branch" \
|
|
95
|
+
--title "Regenerate derived artifacts" \
|
|
96
|
+
--body "Opened by the right-git regenerate lane. The ci gate passed on this tree in $RIGHT_GIT_RUN_URL (pull requests opened with the workflow token do not trigger pull_request workflows)."
|