@rightkit/ci 0.2.45 → 0.2.49
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 +57 -3
- package/checkout.test.mjs +1 -0
- package/guard-coverage.test.mjs +1 -0
- package/manifest.mjs +539 -27
- package/manifest.schema.json +101 -6
- package/manifest.test.mjs +48 -0
- package/package.json +1 -1
- package/render.test.mjs +362 -27
- package/supersede.mjs +127 -0
- package/supersede.test.mjs +84 -0
- package/swift-check.test.mjs +95 -0
- package/templates/ci.yml +4 -4
- package/templates/profiles/rust-hybrid/ci.yml +4 -4
- package/templates/profiles/rust-hybrid/release-candidate.yml +2 -1
- package/templates/profiles/rust-hybrid/sign-existing.yml +36 -0
- package/templates/swift-check.yml +85 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import test from "node:test";
|
|
4
|
+
|
|
5
|
+
import { decideSupersede, median, olderRuns, parseSettings, runDurationMs } from "./supersede.mjs";
|
|
6
|
+
|
|
7
|
+
const NOW = Date.parse("2026-10-17T12:00:00Z");
|
|
8
|
+
const MIN = 60_000;
|
|
9
|
+
const startedAgo = (ms) => new Date(NOW - ms).toISOString();
|
|
10
|
+
|
|
11
|
+
test("median handles odd, even, empty and unusable values", () => {
|
|
12
|
+
assert.equal(median([3, 1, 2]), 2);
|
|
13
|
+
assert.equal(median([4, 1, 2, 3]), 2.5);
|
|
14
|
+
assert.equal(median([]), null);
|
|
15
|
+
assert.equal(median([Number.NaN, -1]), null);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("runDurationMs reads start and update times", () => {
|
|
19
|
+
assert.equal(runDurationMs({ run_started_at: "2026-10-17T10:00:00Z", updated_at: "2026-10-17T10:10:00Z" }), 10 * MIN);
|
|
20
|
+
assert.equal(runDurationMs({ run_started_at: "2026-10-17T10:10:00Z", updated_at: "2026-10-17T10:00:00Z" }), null);
|
|
21
|
+
assert.equal(runDurationMs({}), null);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test("a run that has only just started is cancelled", () => {
|
|
25
|
+
const decision = decideSupersede({ run: { status: "in_progress", run_started_at: startedAgo(2 * MIN) }, medianMs: 20 * MIN, nowMs: NOW });
|
|
26
|
+
assert.equal(decision.cancel, true);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("a run past the grace fraction of the median is left alone", () => {
|
|
30
|
+
const decision = decideSupersede({ run: { status: "in_progress", run_started_at: startedAgo(15 * MIN) }, medianMs: 20 * MIN, nowMs: NOW });
|
|
31
|
+
assert.equal(decision.cancel, false);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("the grace boundary is exact: 0.7 of 20 minutes is 14 minutes", () => {
|
|
35
|
+
const at = (ms) => decideSupersede({ run: { status: "in_progress", run_started_at: startedAgo(ms) }, medianMs: 20 * MIN, nowMs: NOW }).cancel;
|
|
36
|
+
assert.equal(at(14 * MIN - 1), true);
|
|
37
|
+
assert.equal(at(14 * MIN), false);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("graceFraction changes the boundary", () => {
|
|
41
|
+
const run = { status: "in_progress", run_started_at: startedAgo(10 * MIN) };
|
|
42
|
+
assert.equal(decideSupersede({ run, medianMs: 20 * MIN, nowMs: NOW, graceFraction: 0.7 }).cancel, true);
|
|
43
|
+
assert.equal(decideSupersede({ run, medianMs: 20 * MIN, nowMs: NOW, graceFraction: 0.4 }).cancel, false);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("a run with a failed job is cancelled even when nearly done", () => {
|
|
47
|
+
const run = { status: "in_progress", run_started_at: startedAgo(19 * MIN) };
|
|
48
|
+
for (const conclusion of ["failure", "timed_out"]) {
|
|
49
|
+
assert.equal(decideSupersede({ run, jobs: [{ conclusion: "success" }, { conclusion }], medianMs: 20 * MIN, nowMs: NOW }).cancel, true, conclusion);
|
|
50
|
+
}
|
|
51
|
+
assert.equal(decideSupersede({ run, jobs: [{ conclusion: "success" }, { conclusion: null }], medianMs: 20 * MIN, nowMs: NOW }).cancel, false);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("a queued run that never started is cancelled", () => {
|
|
55
|
+
assert.equal(decideSupersede({ run: { status: "queued", created_at: startedAgo(MIN) }, medianMs: null, nowMs: NOW }).cancel, true);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("without a median nothing is cancelled for being young", () => {
|
|
59
|
+
const run = { status: "in_progress", run_started_at: startedAgo(MIN) };
|
|
60
|
+
assert.equal(decideSupersede({ run, medianMs: null, nowMs: NOW }).cancel, false);
|
|
61
|
+
assert.equal(decideSupersede({ run, medianMs: 0, nowMs: NOW }).cancel, false);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("olderRuns keeps only lower run numbers and never the current run", () => {
|
|
65
|
+
const current = { id: 30, run_number: 12 };
|
|
66
|
+
const runs = [{ id: 31, run_number: 13 }, { id: 30, run_number: 12 }, { id: 29, run_number: 11 }, { id: 27, run_number: 9 }];
|
|
67
|
+
assert.deepEqual(olderRuns(runs, current).map((run) => run.id), [27, 29]);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test("parseSettings defaults and validates", () => {
|
|
71
|
+
assert.deepEqual(parseSettings({}), { graceFraction: 0.7, medianWindow: 10 });
|
|
72
|
+
assert.deepEqual(parseSettings({ RIGHT_GIT_GRACE_FRACTION: "0.5", RIGHT_GIT_MEDIAN_WINDOW: "5" }), { graceFraction: 0.5, medianWindow: 5 });
|
|
73
|
+
assert.throws(() => parseSettings({ RIGHT_GIT_GRACE_FRACTION: "0" }));
|
|
74
|
+
assert.throws(() => parseSettings({ RIGHT_GIT_GRACE_FRACTION: "1.5" }));
|
|
75
|
+
assert.throws(() => parseSettings({ RIGHT_GIT_MEDIAN_WINDOW: "0" }));
|
|
76
|
+
assert.throws(() => parseSettings({ RIGHT_GIT_MEDIAN_WINDOW: "2.5" }));
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test("the script is safe to embed verbatim in a workflow heredoc", () => {
|
|
80
|
+
const source = fs.readFileSync(new URL("./supersede.mjs", import.meta.url), "utf8");
|
|
81
|
+
assert.doesNotMatch(source, /\$\{/, "no template placeholder or expression syntax");
|
|
82
|
+
assert.doesNotMatch(source, /^RIGHT_GIT_SUPERSEDE_EOF$/m);
|
|
83
|
+
assert.doesNotMatch(source, /\r/);
|
|
84
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import test from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { spawnSync } from "node:child_process";
|
|
7
|
+
import { buildRenderContext, validateManifest } from "./manifest.mjs";
|
|
8
|
+
import { renderLanes } from "./sync.mjs";
|
|
9
|
+
import { renderTemplate } from "./render.mjs";
|
|
10
|
+
|
|
11
|
+
const CHECK = { runner: "macos-15", xcodeVersion: "16.4", projectDirectory: "ios", spec: "project.yml", project: "Widgets.xcodeproj", scheme: "Widgets", xcodegenVersion: "2.44.1" };
|
|
12
|
+
const BASE = { schemaVersion: 1, compile: "github-actions-only", lanes: ["swift-check"], matrix: { os: ["macos-15"], node: ["26.8.1"] }, packageManager: "pnpm@11.24.0", templateVersion: "1.8.0", swift: { check: CHECK } };
|
|
13
|
+
const render = (manifest = BASE) => renderLanes(manifest, "/repos/widgets")[0].content;
|
|
14
|
+
|
|
15
|
+
test("swift-check supports a standalone default-profile manifest with or without private packages", () => {
|
|
16
|
+
assert.deepEqual(validateManifest(BASE).errors, []);
|
|
17
|
+
assert.deepEqual(validateManifest({ ...BASE, swift: { check: CHECK, privatePackages: [{ host: "github.com", secret: "SWIFT_READ_TOKEN" }] } }).errors, []);
|
|
18
|
+
assert.equal(renderLanes(BASE, "/repos/widgets")[0].filename, "swift-check.yml");
|
|
19
|
+
assert.match(render(), /^name: swift-check$/m);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("swift-check rejects missing configuration, unpinned tools, unsafe fields and unknown keys", () => {
|
|
23
|
+
assert.equal(validateManifest({ ...BASE, swift: undefined }).valid, false);
|
|
24
|
+
assert.equal(validateManifest({ ...BASE, swift: { check: null } }).valid, false);
|
|
25
|
+
assert.equal(validateManifest({ ...BASE, lanes: ["ci"] }).valid, false);
|
|
26
|
+
for (const [key, values] of Object.entries({
|
|
27
|
+
runner: ["macos-latest", "self-hosted", "xcode-27", "ubuntu-24.04", "${{ secrets.TOKEN }}"],
|
|
28
|
+
xcodeVersion: ["latest", "16", "16.4;id", "16.4\n"],
|
|
29
|
+
xcodegenVersion: ["latest", "2.44", "2.44.1$(id)"],
|
|
30
|
+
projectDirectory: ["../ios", "/tmp/ios", "ios dir", "ios\\x", "${{ github.ref }}"],
|
|
31
|
+
spec: ["../project.yml", "-x.yml", "project.yml\nrun: id", "project.json"],
|
|
32
|
+
project: ["../App.xcodeproj", "App.xcworkspace", "$(id).xcodeproj"],
|
|
33
|
+
scheme: ["-scheme", "App Name", "App'", "${{ secrets.TOKEN }}"],
|
|
34
|
+
arbitrary: ["value"],
|
|
35
|
+
})) for (const value of values) {
|
|
36
|
+
assert.equal(validateManifest({ ...BASE, swift: { check: { ...CHECK, [key]: value } } }).valid, false, `${key}=${value}`);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("swift-check pins actions, tools and read-only permissions; test execution stays unsigned Debug", () => {
|
|
41
|
+
const out = render();
|
|
42
|
+
for (const line of out.split("\n").filter((line) => line.includes("uses:"))) assert.match(line, /uses: [^@]+@[a-f0-9]{40}(?: |$)/);
|
|
43
|
+
assert.match(out, /^permissions:\n contents: read$/m);
|
|
44
|
+
assert.doesNotMatch(out, /: write|write-all|workflow_dispatch|pull_request_target|workflow_run|signing|notary|\bsecrets\./);
|
|
45
|
+
assert.match(out, /runs-on: macos-15/);
|
|
46
|
+
assert.match(out, /DEVELOPER_DIR: \/Applications\/Xcode_16\.4\.app\/Contents\/Developer/);
|
|
47
|
+
assert.match(out, /test "\$\(xcodegen --version\)" = 'Version: 2\.44\.1'/);
|
|
48
|
+
assert.match(out, /persist-credentials: false/);
|
|
49
|
+
assert.match(out, /xcodegen generate --spec 'project.yml'/);
|
|
50
|
+
assert.match(out, /simctl list devices available --json/);
|
|
51
|
+
assert.match(out, /xcodebuild test -project 'Widgets.xcodeproj' -scheme 'Widgets'/);
|
|
52
|
+
assert.match(out, /-configuration Debug -destination "platform=iOS Simulator,id=\$RIGHT_GIT_SIMULATOR_UDID"/);
|
|
53
|
+
assert.match(out, /-scmProvider system[\s\S]*CODE_SIGNING_ALLOWED=NO/);
|
|
54
|
+
assert.match(out, /Upload XCTest results\n if: \$\{\{ always\(\) \}\}/);
|
|
55
|
+
assert.match(out, /right-release ownership --app \./);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("swift-check shares exact private-package steps and keeps cleanup before artifact upload", () => {
|
|
59
|
+
const out = render({ ...BASE, swift: { check: CHECK, privatePackages: [{ host: "github.com", secret: "SWIFT_READ_TOKEN" }] } });
|
|
60
|
+
const configure = out.indexOf("Configure private Swift package access");
|
|
61
|
+
const generation = out.indexOf("Generate Xcode project");
|
|
62
|
+
const execution = out.indexOf("Run Debug XCTest");
|
|
63
|
+
const cleanup = out.indexOf("Remove private Swift package access");
|
|
64
|
+
assert.ok(configure < generation && generation < execution && execution < cleanup && cleanup < out.indexOf("Upload XCTest results"));
|
|
65
|
+
assert.match(out, /test -n "\$RIGHT_GIT_PRIVATE_TOKEN_0"[\s\S]*secret SWIFT_READ_TOKEN is unavailable/);
|
|
66
|
+
assert.match(out, /Remove private Swift package access\n if: \$\{\{ always\(\) \}\}/);
|
|
67
|
+
assert.equal((out.match(/secrets\.SWIFT_READ_TOKEN/g) ?? []).length, 2);
|
|
68
|
+
for (const line of out.split("\n").filter((line) => line.includes("secrets."))) assert.match(line, /^ {10}RIGHT_GIT_PRIVATE_TOKEN_0:/);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test("swift-check config does not change existing lane rendering when lane is unset", () => {
|
|
72
|
+
const manifest = { ...BASE, lanes: ["ci", "qualification", "package-smoke"], swift: undefined };
|
|
73
|
+
const before = renderLanes(manifest, "/repos/widgets");
|
|
74
|
+
const after = renderLanes({ ...manifest, swift: { check: CHECK } }, "/repos/widgets");
|
|
75
|
+
assert.deepEqual(after, before);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("swift-check render refuses credential-bearing unsafe triggers", () => {
|
|
79
|
+
const manifest = { ...BASE, swift: { check: CHECK, privatePackages: [{ host: "github.com", secret: "SWIFT_READ_TOKEN" }] } };
|
|
80
|
+
for (const trigger of ["pull_request_target", "workflow_run"]) {
|
|
81
|
+
assert.throws(() => renderTemplate(render(manifest).replace(" pull_request:", ` ${trigger}:`), buildRenderContext(manifest, "/repos/widgets", "swift-check")), /refusing to render/);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test("swift-check generated workflow passes actionlint", (t) => {
|
|
86
|
+
const available = spawnSync("actionlint", ["-version"], { encoding: "utf8" });
|
|
87
|
+
if (available.error?.code === "ENOENT") return t.skip("actionlint is unavailable");
|
|
88
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "right-git-swift-check-"));
|
|
89
|
+
try {
|
|
90
|
+
const filename = path.join(dir, "swift-check.yml");
|
|
91
|
+
fs.writeFileSync(filename, render({ ...BASE, swift: { check: CHECK, privatePackages: [{ host: "github.com", secret: "SWIFT_READ_TOKEN" }] } }));
|
|
92
|
+
const result = spawnSync("actionlint", ["-shellcheck=", "-pyflakes=", filename], { encoding: "utf8" });
|
|
93
|
+
assert.equal(result.status, 0, result.stdout + result.stderr);
|
|
94
|
+
} finally { fs.rmSync(dir, { recursive: true, force: true }); }
|
|
95
|
+
});
|
package/templates/ci.yml
CHANGED
|
@@ -7,8 +7,8 @@ on:
|
|
|
7
7
|
branches: [${DEFAULT_BRANCH}]
|
|
8
8
|
permissions:
|
|
9
9
|
contents: read
|
|
10
|
-
concurrency:
|
|
11
|
-
group: ${
|
|
10
|
+
${CI_CONCURRENCY_COMMENT}concurrency:
|
|
11
|
+
group: ${CI_CONCURRENCY_GROUP}
|
|
12
12
|
cancel-in-progress: ${CI_CANCEL_IN_PROGRESS}
|
|
13
13
|
# F5 fix: `private-repo-guard` carries no job-level `if`, so it always runs.
|
|
14
14
|
# Its one step's own `if` fires only when the repo is private, and `exit 1`
|
|
@@ -27,7 +27,7 @@ jobs:
|
|
|
27
27
|
run: |
|
|
28
28
|
echo "::error::right-git: repository is private; managed public-only workflows must not run here."
|
|
29
29
|
exit 1
|
|
30
|
-
test:
|
|
30
|
+
${CI_SUPERSEDE_JOB} test:
|
|
31
31
|
needs: [private-repo-guard]
|
|
32
32
|
strategy:
|
|
33
33
|
fail-fast: false
|
|
@@ -35,7 +35,7 @@ jobs:
|
|
|
35
35
|
os: ${OS_MATRIX}
|
|
36
36
|
node: ${NODE_MATRIX}
|
|
37
37
|
runs-on: ${{ matrix.os }}
|
|
38
|
-
steps:
|
|
38
|
+
${CI_JOB_CONCURRENCY} steps:
|
|
39
39
|
- uses: actions/checkout@v5
|
|
40
40
|
- uses: actions/setup-node@v5
|
|
41
41
|
with:
|
|
@@ -7,8 +7,8 @@ on:
|
|
|
7
7
|
branches: [${DEFAULT_BRANCH}]
|
|
8
8
|
${CI_DISPATCH_TRIGGER}permissions:
|
|
9
9
|
contents: read
|
|
10
|
-
concurrency:
|
|
11
|
-
group: ${
|
|
10
|
+
${CI_CONCURRENCY_COMMENT}concurrency:
|
|
11
|
+
group: ${CI_CONCURRENCY_GROUP}
|
|
12
12
|
cancel-in-progress: ${CI_CANCEL_IN_PROGRESS}
|
|
13
13
|
jobs:
|
|
14
14
|
private-repo-guard:
|
|
@@ -17,7 +17,7 @@ jobs:
|
|
|
17
17
|
- name: Refuse private repository
|
|
18
18
|
if: ${{ github.event.repository.private }}
|
|
19
19
|
run: exit 1
|
|
20
|
-
ci:
|
|
20
|
+
${CI_SUPERSEDE_JOB} ci:
|
|
21
21
|
needs: [private-repo-guard]
|
|
22
22
|
strategy:
|
|
23
23
|
fail-fast: false
|
|
@@ -25,7 +25,7 @@ jobs:
|
|
|
25
25
|
${CI_MATRIX_OS}
|
|
26
26
|
node: ${NODE_MATRIX}
|
|
27
27
|
runs-on: ${{ matrix.os }}
|
|
28
|
-
steps:
|
|
28
|
+
${CI_JOB_CONCURRENCY} steps:
|
|
29
29
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
30
30
|
with:
|
|
31
31
|
fetch-depth: 0
|
|
@@ -97,6 +97,7 @@ ${OWNERSHIP_STEP}
|
|
|
97
97
|
env:
|
|
98
98
|
SCCACHE_GHA_ENABLED: "true"
|
|
99
99
|
RUSTC_WRAPPER: "sccache"
|
|
100
|
+
RIGHTKIT_DEV_SIGNING: "ci-adhoc"
|
|
100
101
|
strategy:
|
|
101
102
|
fail-fast: false
|
|
102
103
|
matrix:
|
|
@@ -189,6 +190,6 @@ ${RUST_CACHE_KEY} cache-workspace-crates: false
|
|
|
189
190
|
name: ${ARTIFACT_PREFIX}-${{ github.run_id }}-${{ github.run_attempt }}-summary-candidate-${{ matrix.platform }}-${{ matrix.architecture }}-${{ needs.admission.outputs.version }}-${{ needs.admission.outputs.source_revision }}${{ needs.admission.outputs.artifact_suffix }}
|
|
190
191
|
path: ${{ runner.temp }}/right-git-stage-summary/stage-summary.json
|
|
191
192
|
if-no-files-found: error
|
|
192
|
-
${WINDOWS_SIGNING_JOB}
|
|
193
|
+
${DEV_QUALIFICATION_JOB}${WINDOWS_SIGNING_JOB}
|
|
193
194
|
${MACOS_SIGNING_JOB}
|
|
194
195
|
${RELEASE_CHAIN_JOBS}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Managed by right-git — do not hand-edit. Run `right-git sync` to update.
|
|
2
|
+
# Template: profiles/rust-hybrid/sign-existing.yml | Template version: ${TEMPLATE_VERSION}
|
|
3
|
+
# Manual only. Signs an already-qualified artifact of another run of this repository
|
|
4
|
+
# with right-release sign-dev-artifact (fixed per-file identifiers, Developer ID) inside
|
|
5
|
+
# the protected signing environment. It verifies the run, artifact and source commit
|
|
6
|
+
# through the GitHub API first, never rebuilds and never builds a release.
|
|
7
|
+
name: ${ARTIFACT_PREFIX}-sign-existing
|
|
8
|
+
on:
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
inputs:
|
|
11
|
+
run_id:
|
|
12
|
+
description: Workflow run id that produced the qualified artifact
|
|
13
|
+
required: true
|
|
14
|
+
type: string
|
|
15
|
+
artifact:
|
|
16
|
+
description: Artifact id or artifact name inside that run
|
|
17
|
+
required: true
|
|
18
|
+
type: string
|
|
19
|
+
source_sha:
|
|
20
|
+
description: Source commit the artifact was built from (7 to 40 lowercase hex characters, a prefix of the run head sha)
|
|
21
|
+
required: true
|
|
22
|
+
type: string
|
|
23
|
+
permissions:
|
|
24
|
+
contents: read
|
|
25
|
+
actions: read
|
|
26
|
+
concurrency:
|
|
27
|
+
group: ${ARTIFACT_PREFIX}-sign-existing
|
|
28
|
+
cancel-in-progress: false
|
|
29
|
+
jobs:
|
|
30
|
+
private-repo-guard:
|
|
31
|
+
runs-on: ubuntu-24.04
|
|
32
|
+
steps:
|
|
33
|
+
- name: Refuse private repository
|
|
34
|
+
if: ${{ github.event.repository.private }}
|
|
35
|
+
run: exit 1
|
|
36
|
+
${SIGN_EXISTING_JOB}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Managed by right-git — do not hand-edit. Run `right-git sync` to update.
|
|
2
|
+
# Template: swift-check.yml | Template version: ${TEMPLATE_VERSION}
|
|
3
|
+
name: swift-check
|
|
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_SWIFT_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: |
|
|
20
|
+
echo "::error::right-git: repository is private; managed public-only workflows must not run here."
|
|
21
|
+
exit 1
|
|
22
|
+
swift-check:
|
|
23
|
+
needs: [private-repo-guard]
|
|
24
|
+
runs-on: ${SWIFT_CHECK_RUNNER}
|
|
25
|
+
timeout-minutes: 45
|
|
26
|
+
env:
|
|
27
|
+
DEVELOPER_DIR: /Applications/Xcode_${SWIFT_CHECK_XCODE_VERSION}.app/Contents/Developer
|
|
28
|
+
defaults:
|
|
29
|
+
run:
|
|
30
|
+
shell: bash
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
33
|
+
with:
|
|
34
|
+
persist-credentials: false
|
|
35
|
+
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
|
36
|
+
with:
|
|
37
|
+
node-version: ${NODE_PUBLISH_VERSION}
|
|
38
|
+
package-manager-cache: false
|
|
39
|
+
${PACKAGE_MANAGER_SETUP}
|
|
40
|
+
- run: ${INSTALL_COMMAND}${OWNERSHIP_STEP}
|
|
41
|
+
- name: Verify pinned native tools
|
|
42
|
+
run: |
|
|
43
|
+
set -euo pipefail
|
|
44
|
+
test -d "$DEVELOPER_DIR" || { echo "::error::right-git: pinned Xcode is unavailable"; exit 1; }
|
|
45
|
+
test "$(xcodebuild -version | head -n 1)" = 'Xcode ${SWIFT_CHECK_XCODE_VERSION}' || { echo "::error::right-git: Xcode version mismatch"; exit 1; }
|
|
46
|
+
command -v xcodegen >/dev/null || { echo "::error::right-git: pinned XcodeGen must be provisioned on this runner"; exit 1; }
|
|
47
|
+
test "$(xcodegen --version)" = 'Version: ${SWIFT_CHECK_XCODEGEN_VERSION}' || { echo "::error::right-git: XcodeGen version mismatch"; exit 1; }${SWIFT_PRIVATE_CONFIGURE_STEP}
|
|
48
|
+
- name: Generate Xcode project
|
|
49
|
+
working-directory: ${SWIFT_CHECK_DIRECTORY}
|
|
50
|
+
run: xcodegen generate --spec '${SWIFT_CHECK_SPEC}'
|
|
51
|
+
- name: Discover available iOS simulator
|
|
52
|
+
id: simulator
|
|
53
|
+
run: |
|
|
54
|
+
set -euo pipefail
|
|
55
|
+
xcrun simctl list devices available --json > "$RUNNER_TEMP/right-git-simulators.json"
|
|
56
|
+
python3 - <<'PY'
|
|
57
|
+
import json, os
|
|
58
|
+
with open(os.path.join(os.environ['RUNNER_TEMP'], 'right-git-simulators.json')) as source:
|
|
59
|
+
devices = json.load(source)['devices']
|
|
60
|
+
candidates = sorted((runtime, device['udid']) for runtime, entries in devices.items()
|
|
61
|
+
if runtime.startswith('com.apple.CoreSimulator.SimRuntime.iOS-')
|
|
62
|
+
for device in entries if device.get('isAvailable') and device.get('name', '').startswith('iPhone'))
|
|
63
|
+
if not candidates:
|
|
64
|
+
raise SystemExit('right-git: no available iPhone simulator')
|
|
65
|
+
with open(os.environ['GITHUB_OUTPUT'], 'a') as output:
|
|
66
|
+
output.write('udid=' + candidates[-1][1] + '\n')
|
|
67
|
+
PY
|
|
68
|
+
- name: Run Debug XCTest
|
|
69
|
+
working-directory: ${SWIFT_CHECK_DIRECTORY}
|
|
70
|
+
env:
|
|
71
|
+
RIGHT_GIT_SIMULATOR_UDID: ${{ steps.simulator.outputs.udid }}
|
|
72
|
+
run: |
|
|
73
|
+
set -euo pipefail
|
|
74
|
+
xcodebuild test -project '${SWIFT_CHECK_PROJECT}' -scheme '${SWIFT_CHECK_SCHEME}' \
|
|
75
|
+
-configuration Debug -destination "platform=iOS Simulator,id=$RIGHT_GIT_SIMULATOR_UDID" \
|
|
76
|
+
-scmProvider system -derivedDataPath "$RUNNER_TEMP/right-git-swift-derived-data" \
|
|
77
|
+
-resultBundlePath "$RUNNER_TEMP/right-git-swift-tests.xcresult" CODE_SIGNING_ALLOWED=NO${SWIFT_PRIVATE_CLEANUP_STEP}
|
|
78
|
+
- name: Upload XCTest results
|
|
79
|
+
if: ${{ always() }}
|
|
80
|
+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
|
81
|
+
with:
|
|
82
|
+
name: swift-check-xcresult-${{ github.run_attempt }}
|
|
83
|
+
path: ${{ runner.temp }}/right-git-swift-tests.xcresult
|
|
84
|
+
retention-days: 7
|
|
85
|
+
if-no-files-found: ignore
|