@rightkit/git 0.2.20 → 0.2.22

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.
@@ -52,6 +52,7 @@ const templatesDir = path.join(packageRoot, "templates");
52
52
 
53
53
  const FULL_MANIFEST = {
54
54
  schemaVersion: 1,
55
+ compile: "github-actions-only",
55
56
  lanes: [...KNOWN_LANES],
56
57
  matrix: { os: ["ubuntu-latest", "macos-latest", "windows-latest"], node: ["22.13", "24"] },
57
58
  packageManager: "pnpm@11.24.0",
package/install.mjs CHANGED
@@ -13,7 +13,7 @@ import { applyPlan, planSync } from "./sync.mjs";
13
13
 
14
14
  export const DEFAULT_MATRIX = { os: ["ubuntu-latest", "macos-latest", "windows-latest"], node: ["22.13", "24"] };
15
15
  export const DEFAULT_PACKAGE_MANAGER = "pnpm@11.24.0";
16
- export const DEFAULT_TEMPLATE_VERSION = "1.1.0";
16
+ export const DEFAULT_TEMPLATE_VERSION = "1.7.0";
17
17
 
18
18
  /**
19
19
  * opts: { lanes: string[], matrix?, packageManager?, templateVersion?,
@@ -38,6 +38,7 @@ export async function installCommand(repoPath, opts = {}, deps = {}) {
38
38
 
39
39
  const manifest = {
40
40
  schemaVersion: 1,
41
+ compile: "github-actions-only",
41
42
  lanes,
42
43
  matrix: opts.matrix || DEFAULT_MATRIX,
43
44
  packageManager: opts.packageManager || DEFAULT_PACKAGE_MANAGER,
package/manifest.mjs CHANGED
@@ -50,6 +50,7 @@ const WINGET_PACKAGE_IDENTIFIER_RE = /^[A-Za-z0-9][A-Za-z0-9-]*(?:\.[A-Za-z0-9][
50
50
 
51
51
  const TOP_LEVEL_KEYS = new Set([
52
52
  "schemaVersion",
53
+ "compile",
53
54
  "lanes",
54
55
  "matrix",
55
56
  "packageManager",
@@ -100,6 +101,9 @@ export function validateManifest(manifest) {
100
101
  if (manifest.schemaVersion !== 1) {
101
102
  errors.push("schemaVersion must be exactly 1");
102
103
  }
104
+ if (manifest.compile !== "github-actions-only") {
105
+ errors.push("compile must be exactly 'github-actions-only' for public repositories");
106
+ }
103
107
 
104
108
  let lanes = [];
105
109
  if (!Array.isArray(manifest.lanes) || manifest.lanes.length === 0) {
@@ -4,12 +4,15 @@
4
4
  "title": "right-git per-repo manifest (.rightgit.json)",
5
5
  "description": "Declares which right-git lanes a public repo installs and how templates should be parameterized. Hand-validated by manifest.mjs — this file documents the contract, it is not fed to a JSON Schema validator at runtime.",
6
6
  "type": "object",
7
- "required": ["schemaVersion", "lanes", "matrix", "packageManager", "templateVersion"],
7
+ "required": ["schemaVersion", "compile", "lanes", "matrix", "packageManager", "templateVersion"],
8
8
  "additionalProperties": false,
9
9
  "properties": {
10
10
  "schemaVersion": {
11
11
  "const": 1
12
12
  },
13
+ "compile": {
14
+ "const": "github-actions-only"
15
+ },
13
16
  "lanes": {
14
17
  "type": "array",
15
18
  "minItems": 1,
package/manifest.test.mjs CHANGED
@@ -4,12 +4,18 @@ import { validateManifest } from "./manifest.mjs";
4
4
 
5
5
  const VALID_MINIMAL = {
6
6
  schemaVersion: 1,
7
+ compile: "github-actions-only",
7
8
  lanes: ["ci"],
8
9
  matrix: { os: ["ubuntu-latest"], node: ["22.13"] },
9
10
  packageManager: "pnpm@11.24.0",
10
11
  templateVersion: "1.0.0",
11
12
  };
12
13
 
14
+ test("requires GitHub Actions only compilation", () => {
15
+ assert.equal(validateManifest({ ...VALID_MINIMAL, compile: undefined }).valid, false);
16
+ assert.equal(validateManifest({ ...VALID_MINIMAL, compile: "local" }).valid, false);
17
+ });
18
+
13
19
  test("accepts a minimal valid manifest", () => {
14
20
  const { valid, errors } = validateManifest(VALID_MINIMAL);
15
21
  assert.equal(valid, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rightkit/git",
3
- "version": "0.2.20",
3
+ "version": "0.2.22",
4
4
  "description": "Public-repo-only GitHub Actions workflow layer: templates, visibility gate, sync/drift/adopt/uninstall for right-git.",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "type": "module",
package/render.test.mjs CHANGED
@@ -11,6 +11,7 @@ const templatesDir = path.join(packageRoot, "templates");
11
11
 
12
12
  const FULL_MANIFEST = {
13
13
  schemaVersion: 1,
14
+ compile: "github-actions-only",
14
15
  lanes: [...KNOWN_LANES],
15
16
  matrix: { os: ["ubuntu-latest", "macos-latest", "windows-latest"], node: ["22.13", "24"] },
16
17
  packageManager: "pnpm@11.24.0",
@@ -51,11 +52,32 @@ test("rust-hybrid ci renders its pinned package manager and gate", () => {
51
52
  assert.match(content, /version: 11\.24\.0/);
52
53
  assert.match(content, /components: rustfmt, clippy/);
53
54
  assert.doesNotMatch(content, /toolchain:/);
55
+ assert.match(content, /group: \$\{\{ github\.workflow \}\}-\$\{\{ github\.ref \}\}/);
56
+ assert.match(content, /cancel-in-progress: true/);
54
57
  assert.match(content, /bash \.\/scripts\/gate\.sh/);
58
+ assert.match(content, /name: Detect Rust-affecting changes\n id: rust-changes/);
59
+ assert.match(content, /RIGHT_GIT_DIFF_BASE: \$\{\{ github\.event_name == 'pull_request' && github\.event\.pull_request\.base\.sha \|\| github\.event\.before \}\}/);
60
+ assert.match(content, /changed=true[\s\S]*\^0\{40\}\$[\s\S]*git cat-file -e[\s\S]*git diff --name-only --diff-filter=ACDMRTUXB/);
61
+ assert.match(content, /--diff-filter=ACDMRTUXB/, "deleted Rust inputs must trigger Rust setup");
62
+ assert.match(content, /\*\.rs\|Cargo\.toml[\s\S]*scripts\/gate\.sh/);
63
+ assert.match(content, /\.rightgit\.json\|\.github\/workflows\/\*\.yml\|\.github\/workflows\/\*\.yaml/);
64
+ assert.equal((content.match(/if: steps\.rust-changes\.outputs\.changed == 'true'/g) ?? []).length, 3);
65
+ assert.match(content, /RIGHT_GIT_RUST_CHANGED: \$\{\{ steps\.rust-changes\.outputs\.changed \}\}/);
66
+ assert.match(content, /RUSTC_WRAPPER: \$\{\{ steps\.rust-changes\.outputs\.changed == 'true' && 'sccache' \|\| '' \}\}/);
67
+ assert.match(content, /CARGO_INCREMENTAL: "0"/);
68
+ assert.match(content, /CARGO_PROFILE_DEV_DEBUG: "0"/);
69
+ assert.match(content, /CARGO_PROFILE_TEST_DEBUG: "0"/);
70
+ assert.doesNotMatch(content, /opt-level|codegen-units|\blto\b|strip\s*=/i);
55
71
  assert.match(content, /os: \["windows-latest"\]/);
56
72
  assert.doesNotMatch(content, /ubuntu-latest|macos-latest/);
57
73
  });
58
74
 
75
+ test("ordinary CI templates cancel superseded runs on the same ref", () => {
76
+ const generic = renderAllLanes(FULL_MANIFEST, "/repos/widgets").ci;
77
+ assert.match(generic, /group: \$\{\{ github\.workflow \}\}-\$\{\{ github\.ref \}\}/);
78
+ assert.match(generic, /cancel-in-progress: true/);
79
+ });
80
+
59
81
  test("rust-hybrid ci preserves a declared macOS-only lane", () => {
60
82
  const manifest = {
61
83
  ...FULL_MANIFEST,
@@ -96,6 +118,9 @@ test("rust-hybrid release candidate renders product scripts, artifact handoff, a
96
118
  assert.match(content, /RIGHT_GIT_RELEASE_ARCHITECTURE: \$\{\{ matrix\.architecture \}\}/);
97
119
  assert.match(content, /actions\/upload-artifact@[a-f0-9]{40}/);
98
120
  assert.doesNotMatch(content, /secrets\.|AZURE_|APPLE_|certificate|private.key/i);
121
+ assert.doesNotMatch(content, /rust-changes|RIGHT_GIT_RUST_CHANGED/);
122
+ assert.doesNotMatch(content, /if: steps\.rust-changes/);
123
+ assert.match(content, /uses: dtolnay\/rust-toolchain@[a-f0-9]{40}\n with:/);
99
124
  });
100
125
 
101
126
  test("rust-hybrid cache contract renders every declared Cargo workspace", () => {
@@ -115,7 +140,7 @@ test("rust-hybrid cache contract renders every declared Cargo workspace", () =>
115
140
  assert.match(content, /add-job-id-key: false/);
116
141
  assert.match(content, /cache-workspace-crates: false/);
117
142
  assert.match(content, /cache-on-failure: true/);
118
- assert.match(content, /RUSTC_WRAPPER: "sccache"/);
143
+ assert.match(content, /RUSTC_WRAPPER: \$\{\{ steps\.rust-changes\.outputs\.changed == 'true' && 'sccache' \|\| '' \}\}/);
119
144
  });
120
145
 
121
146
  test("rust-hybrid release candidate can opt into OIDC Windows signing without long-lived secrets", () => {
package/sync.test.mjs CHANGED
@@ -57,6 +57,7 @@ test("sync reports manifest errors instead of writing files", async () => {
57
57
  test("sync rejects a Membrane-like release chain without root @rightkit/release", async () => {
58
58
  const manifest = {
59
59
  schemaVersion: 1,
60
+ compile: "github-actions-only",
60
61
  lanes: ["ci", "release-candidate"],
61
62
  matrix: { os: ["windows-2025", "macos-15"], node: ["22.23.2"] },
62
63
  packageManager: "pnpm@11.24.0",
package/templates/ci.yml CHANGED
@@ -7,6 +7,9 @@ on:
7
7
  branches: [main]
8
8
  permissions:
9
9
  contents: read
10
+ concurrency:
11
+ group: ${{ github.workflow }}-${{ github.ref }}
12
+ cancel-in-progress: true
10
13
  # F5 fix: `private-repo-guard` carries no job-level `if`, so it always runs.
11
14
  # Its one step's own `if` fires only when the repo is private, and `exit 1`
12
15
  # then fails the JOB (loud, visible, non-zero) rather than the previous
@@ -7,6 +7,9 @@ on:
7
7
  branches: [main]
8
8
  permissions:
9
9
  contents: read
10
+ concurrency:
11
+ group: ${{ github.workflow }}-${{ github.ref }}
12
+ cancel-in-progress: true
10
13
  jobs:
11
14
  private-repo-guard:
12
15
  runs-on: ubuntu-24.04
@@ -16,9 +19,6 @@ jobs:
16
19
  run: exit 1
17
20
  ci:
18
21
  needs: [private-repo-guard]
19
- env:
20
- SCCACHE_GHA_ENABLED: "true"
21
- RUSTC_WRAPPER: "sccache"
22
22
  strategy:
23
23
  fail-fast: false
24
24
  matrix:
@@ -31,15 +31,40 @@ jobs:
31
31
  - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
32
32
  with:
33
33
  fetch-depth: 0
34
+ - name: Detect Rust-affecting changes
35
+ id: rust-changes
36
+ shell: bash
37
+ env:
38
+ RIGHT_GIT_DIFF_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
39
+ run: |
40
+ set -euo pipefail
41
+ changed=true
42
+ base="$RIGHT_GIT_DIFF_BASE"
43
+ if [[ "$base" =~ ^[0-9a-fA-F]{40}$ ]] && [[ ! "$base" =~ ^0{40}$ ]] && git cat-file -e "$base^{commit}" 2>/dev/null; then
44
+ if changed_paths="$(git diff --name-only --diff-filter=ACDMRTUXB "$base" "$GITHUB_SHA")"; then
45
+ changed=false
46
+ while IFS= read -r changed_path; do
47
+ case "$changed_path" in
48
+ *.rs|Cargo.toml|*/Cargo.toml|Cargo.lock|*/Cargo.lock|build.rs|*/build.rs|rust-toolchain|*/rust-toolchain|rust-toolchain.toml|*/rust-toolchain.toml|.cargo/*|*/.cargo/*|.rightgit.json|.github/workflows/*.yml|.github/workflows/*.yaml|${GATE_PATH})
49
+ changed=true
50
+ break
51
+ ;;
52
+ esac
53
+ done <<< "$changed_paths"
54
+ fi
55
+ fi
56
+ printf 'changed=%s\n' "$changed" >> "$GITHUB_OUTPUT"
34
57
  - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
35
58
  with:
36
59
  node-version: ${{ matrix.node }}
37
60
  package-manager-cache: false
38
61
  ${PACKAGE_MANAGER_SETUP}
39
62
  - uses: dtolnay/rust-toolchain@f8be11a05b1d4f3fcebe6410cc16743212b999b0
63
+ if: steps.rust-changes.outputs.changed == 'true'
40
64
  with:
41
65
  components: rustfmt, clippy
42
66
  - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
67
+ if: steps.rust-changes.outputs.changed == 'true'
43
68
  with:
44
69
  workspaces: |
45
70
  ${RUST_CACHE_WORKSPACES}
@@ -49,6 +74,14 @@ ${RUST_CACHE_WORKSPACES}
49
74
  cache-on-failure: true
50
75
  save-if: ${{ github.event_name != 'pull_request' }}
51
76
  - uses: Mozilla-Actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
77
+ if: steps.rust-changes.outputs.changed == 'true'
52
78
  with:
53
79
  version: "v0.16.0"
54
80
  - run: bash ./${GATE_PATH}
81
+ env:
82
+ RIGHT_GIT_RUST_CHANGED: ${{ steps.rust-changes.outputs.changed }}
83
+ SCCACHE_GHA_ENABLED: "true"
84
+ RUSTC_WRAPPER: ${{ steps.rust-changes.outputs.changed == 'true' && 'sccache' || '' }}
85
+ CARGO_INCREMENTAL: "0"
86
+ CARGO_PROFILE_DEV_DEBUG: "0"
87
+ CARGO_PROFILE_TEST_DEBUG: "0"
package/test-support.mjs CHANGED
@@ -26,6 +26,7 @@ export const PRIVATE_DEPS = ghDeps("PRIVATE");
26
26
 
27
27
  export const SAMPLE_MANIFEST = {
28
28
  schemaVersion: 1,
29
+ compile: "github-actions-only",
29
30
  lanes: ["ci", "package-smoke"],
30
31
  matrix: { os: ["ubuntu-latest"], node: ["22.13"] },
31
32
  packageManager: "pnpm@11.24.0",
@@ -3,7 +3,7 @@ import assert from "node:assert/strict";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
5
5
  import { syncCommand } from "./sync.mjs";
6
- import { installCommand } from "./install.mjs";
6
+ import { DEFAULT_TEMPLATE_VERSION, installCommand } from "./install.mjs";
7
7
  import { uninstallCommand } from "./uninstall.mjs";
8
8
  import { listManagedFiles } from "./sync.mjs";
9
9
  import { MANIFEST_FILENAME } from "./manifest.mjs";
@@ -77,3 +77,13 @@ test("install validates before it creates a manifest", async () => {
77
77
  assert.equal(result.stage, "manifest-invalid");
78
78
  assert.equal(fs.existsSync(path.join(dir, MANIFEST_FILENAME)), false);
79
79
  });
80
+
81
+ test("install emits GitHub-Actions-only policy at template 1.7.0", async () => {
82
+ const dir = makeTempRepo(null);
83
+ const result = await installCommand(dir, { lanes: ["ci"] }, PUBLIC_DEPS);
84
+ assert.equal(result.ok, true);
85
+ const manifest = JSON.parse(fs.readFileSync(path.join(dir, MANIFEST_FILENAME), "utf8"));
86
+ assert.equal(manifest.compile, "github-actions-only");
87
+ assert.equal(DEFAULT_TEMPLATE_VERSION, "1.7.0");
88
+ assert.equal(manifest.templateVersion, DEFAULT_TEMPLATE_VERSION);
89
+ });