Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Restore nothing from the Actions cache in OK's shipped builds (#5663)

Nick Gomezc7066dc3858c
diff --git a/.github/scripts/cache-mode-shape.test.mjs b/.github/scripts/cache-mode-shape.test.mjs
index 1abb7bb02..1c8964eb3 100644
--- a/.github/scripts/cache-mode-shape.test.mjs
+++ b/.github/scripts/cache-mode-shape.test.mjs
@@ -44,12 +44,26 @@ const ACTIONS = {
'pnpm/setup': (inputs) =>
inputs.cache === undefined || isFalse(inputs.cache) ? [] : ['extract', 'save'],
'astral-sh/setup-uv': (inputs) => (isFalse(inputs['enable-cache']) ? [] : ['incidental']),
- 'mlugg/setup-zig': (inputs) => (isFalse(inputs['use-cache']) ? [] : ['incidental']),
+ 'mlugg/setup-zig': (inputs) => [
+ 'extract',
+ 'save',
+ ...(isFalse(inputs['use-cache']) ? [] : ['incidental']),
+ ],
'actions/stale': () => ['incidental'],
};
-function cacheOps(steps, root = OK_ROOT, seen = []) {
- const ops = [];
+const OFF_SWITCHES = {
+ 'actions/setup-node': 'package-manager-cache',
+ 'pnpm/action-setup': 'cache',
+ 'pnpm/setup': 'cache',
+ 'astral-sh/setup-uv': 'enable-cache',
+ 'mlugg/setup-zig': 'use-cache',
+};
+
+const actionName = (uses) => (uses.includes('@') ? uses.slice(0, uses.indexOf('@')) : undefined);
+
+function actionSteps(steps, root = OK_ROOT, seen = []) {
+ const found = [];
for (const step of steps ?? []) {
const uses = step.uses;
if (uses === undefined) continue;
@@ -64,25 +78,29 @@ function cacheOps(steps, root = OK_ROOT, seen = []) {
`local action ${uses} runs ${action.runs?.using}, not composite, so this sweep cannot see what cache it touches`,
);
}
- ops.push(
- ...cacheOps(action.runs.steps, root, [...seen, uses]).map((op) => ({
- ...op,
- via: [uses, ...op.via],
+ found.push(
+ ...actionSteps(action.runs.steps, root, [...seen, uses]).map((inner) => ({
+ ...inner,
+ via: [uses, ...inner.via],
})),
);
continue;
}
- const at = uses.indexOf('@');
- const classify = at === -1 ? undefined : ACTIONS[uses.slice(0, at)];
+ found.push({ step, via: [] });
+ }
+ return found;
+}
+
+function cacheOps(steps, root = OK_ROOT) {
+ return actionSteps(steps, root).flatMap(({ step, via }) => {
+ const classify = ACTIONS[actionName(step.uses)];
if (classify === undefined) {
throw new Error(
- `${uses} is not classified for cache access; add it to ACTIONS in cache-mode-shape.test.mjs`,
+ `${step.uses} is not classified for cache access; add it to ACTIONS in cache-mode-shape.test.mjs`,
);
}
- for (const kind of classify(step.with ?? {}))
- ops.push({ kind, step: step.name ?? uses, via: [] });
- }
- return ops;
+ return classify(step.with ?? {}).map((kind) => ({ kind, step: step.name ?? step.uses, via }));
+ });
}
function narrowestMode(ops) {
@@ -123,6 +141,44 @@ function cacheModeProblems(workflow, job, root = OK_ROOT) {
return problems;
}
+const SHIPS = [
+ 'desktop-release.yml#build-linux',
+ 'desktop-release.yml#build-macos',
+ 'desktop-release.yml#build-windows',
+ 'desktop-release.yml#prepare',
+ 'native-config-prebuild.yml#build',
+ 'native-config-prebuild.yml#combine',
+ 'release.yml#build',
+];
+
+const QA_BUILDS = [
+ 'desktop-build-win-linux.yml#build-linux',
+ 'desktop-build-win-linux.yml#build-windows',
+ 'desktop-build-win-linux.yml#prepare',
+ 'desktop-build.yml#build-macos-dmg',
+];
+
+function restoresNothingProblems(workflow, job, root = OK_ROOT) {
+ if (job.uses !== undefined)
+ return [`calls the reusable workflow ${job.uses}, which this sweep does not trace`];
+ const problems = [];
+ const mode = effectiveMode(workflow, job);
+ if (mode === null) problems.push('declares no cache-mode, so the trigger default applies');
+ else if (mode !== 'none') problems.push(`declares cache-mode ${mode}, not none`);
+ for (const op of cacheOps(job.steps, root)) {
+ problems.push(`touches the cache (${op.kind}) at ${[...op.via, op.step].join(' > ')}`);
+ }
+ for (const { step, via } of actionSteps(job.steps, root)) {
+ const input = OFF_SWITCHES[actionName(step.uses)];
+ if (input !== undefined && !isFalse(step.with?.[input])) {
+ problems.push(
+ `does not set ${input}: false at ${[...via, step.name ?? step.uses].join(' > ')}`,
+ );
+ }
+ }
+ return problems;
+}
+
const workflows = readdirSync(WORKFLOWS)
.filter((name) => /\.ya?ml$/.test(name))
.sort()
@@ -209,6 +265,28 @@ describe('credentialed jobs in public/open-knowledge/.github/workflows declare t
});
});
+describe('jobs in public/open-knowledge/.github/workflows that build what ships restore nothing from the Actions cache', () => {
+ test.each(SHIPS)(
+ '%s declares cache-mode none, touches no cache and turns every setup cache off',
+ (label) => {
+ const entry = allJobs.find((candidate) => candidate.label === label);
+ expect(entry, `${label} is missing`).toBeDefined();
+ expect(restoresNothingProblems(entry.workflow, entry.job)).toEqual([]);
+ },
+ );
+});
+
+describe('QA desktop build jobs in public/open-knowledge/.github/workflows, which can produce production-signed installers, restore nothing from the Actions cache', () => {
+ test.each(QA_BUILDS)(
+ '%s declares cache-mode none, touches no cache and turns every setup cache off',
+ (label) => {
+ const entry = allJobs.find((candidate) => candidate.label === label);
+ expect(entry, `${label} is missing`).toBeDefined();
+ expect(restoresNothingProblems(entry.workflow, entry.job)).toEqual([]);
+ },
+ );
+});
+
describe('cache-mode sweep self-tests', () => {
const sha = '668228422ae6a00e4ad889ee87cd7109ec5666a7';
const nodeSha = '48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e';
@@ -367,8 +445,16 @@ describe('cache-mode sweep self-tests', () => {
'incidental',
]);
expect(kinds({ uses: 'mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29' })).toEqual([
+ 'extract',
+ 'save',
'incidental',
]);
+ expect(
+ kinds({
+ uses: 'mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29',
+ with: { 'use-cache': false },
+ }),
+ ).toEqual(['extract', 'save']);
expect(kinds({ uses: 'actions/stale@b5d41d4e1d5dceea10e7104786b73624c18a190f' })).toEqual([
'incidental',
]);
@@ -506,6 +592,218 @@ describe('cache-mode sweep self-tests', () => {
}
});
+ test('a job that must restore nothing is accepted only at none, touching no cache, with every setup cache off', () => {
+ const offNode = {
+ ...implicitNode,
+ with: { 'node-version': '24', 'package-manager-cache': false },
+ };
+ const actionSetup = { uses: 'pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86' };
+ const pnpmSetup = { uses: 'pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2' };
+ const uv = { uses: 'astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990' };
+ const zig = { uses: 'mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29' };
+ const checkout = { uses: 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' };
+ const buildJob = (mode, ...steps) => ({
+ permissions: { contents: 'read' },
+ ...(mode === undefined ? {} : { 'cache-mode': mode }),
+ steps: [checkout, { run: 'pnpm install --frozen-lockfile' }, ...steps],
+ });
+ const accepted = {
+ 'none with setup-node and pnpm/action-setup off': [
+ {},
+ buildJob('none', offNode, { ...actionSetup, with: { cache: false } }),
+ ],
+ 'none with pnpm/setup and setup-uv off, spelled as strings': [
+ {},
+ buildJob(
+ 'none',
+ { ...pnpmSetup, with: { install: false, cache: 'false' } },
+ { ...uv, with: { 'enable-cache': 'FALSE' } },
+ ),
+ ],
+ 'none inherited from the workflow': [{ 'cache-mode': 'none' }, buildJob(undefined, offNode)],
+ 'none with no action that has a cache': [{}, buildJob('none')],
+ };
+ for (const [form, [workflow, job]] of Object.entries(accepted)) {
+ expect(restoresNothingProblems(workflow, job), form).toEqual([]);
+ }
+ const refused = {
+ 'no mode, so the trigger default applies': [
+ {},
+ buildJob(undefined, offNode),
+ /declares no cache-mode/,
+ ],
+ write: [{}, buildJob('write', offNode), /declares cache-mode write, not none/],
+ read: [{}, buildJob('read', offNode), /declares cache-mode read, not none/],
+ 'write-only': [
+ {},
+ buildJob('write-only', offNode),
+ /declares cache-mode write-only, not none/,
+ ],
+ 'a workflow write the job inherits': [
+ { 'cache-mode': 'write' },
+ buildJob(undefined, offNode),
+ /declares cache-mode write, not none/,
+ ],
+ 'a job mode overriding a workflow none': [
+ { 'cache-mode': 'none' },
+ buildJob('read', offNode),
+ /declares cache-mode read, not none/,
+ ],
+ 'an extracting restore under none': [
+ {},
+ buildJob('none', restore),
+ /touches the cache \(extract\) at restore/,
+ ],
+ 'a lookup-only restore under none': [
+ {},
+ buildJob('none', lookup),
+ /touches the cache \(lookup\) at lookup/,
+ ],
+ 'a save under none': [{}, buildJob('none', save), /touches the cache \(save\) at save/],
+ 'the combined cache action under none': [
+ {},
+ buildJob('none', { uses: `actions/cache@${sha}`, with: { path: 'p', key: 'k' } }),
+ /touches the cache \(extract\).*touches the cache \(save\)/s,
+ ],
+ 'setup-node with its package-manager cache left to its default': [
+ {},
+ buildJob('none', implicitNode),
+ /touches the cache \(incidental\) at node.*does not set package-manager-cache: false at node/s,
+ ],
+ 'setup-node with package-manager-cache set by an expression': [
+ {},
+ buildJob('none', {
+ ...implicitNode,
+ with: { 'package-manager-cache': '${{ inputs.package-manager-cache }}' },
+ }),
+ /does not set package-manager-cache: false/,
+ ],
+ 'setup-node with a cache input beside package-manager-cache false': [
+ {},
+ buildJob('none', {
+ ...implicitNode,
+ with: { cache: 'pnpm', 'package-manager-cache': false },
+ }),
+ /touches the cache \(extract\) at node/,
+ ],
+ 'pnpm/action-setup with its cache left to its default': [
+ {},
+ buildJob('none', offNode, actionSetup),
+ /does not set cache: false at pnpm\/action-setup/,
+ ],
+ 'pnpm/setup with its cache on': [
+ {},
+ buildJob('none', offNode, { ...pnpmSetup, with: { cache: true } }),
+ /touches the cache \(extract\)/,
+ ],
+ 'setup-zig, whose compiler tarball is cached whatever use-cache says': [
+ {},
+ buildJob('none', { ...zig, with: { 'use-cache': false } }),
+ /touches the cache \(extract\) at mlugg\/setup-zig/,
+ ],
+ 'actions/stale, which has no off switch': [
+ {},
+ buildJob('none', { uses: 'actions/stale@b5d41d4e1d5dceea10e7104786b73624c18a190f' }),
+ /touches the cache \(incidental\)/,
+ ],
+ 'a setup cache inside a local composite': [
+ {},
+ buildJob('none', { uses: './.github/composite-actions/share-contract-reader-gate' }),
+ /share-contract-reader-gate > Set up Node/,
+ ],
+ 'a reusable workflow call': [
+ {},
+ {
+ permissions: { contents: 'read' },
+ 'cache-mode': 'none',
+ uses: './.github/workflows/x.yml',
+ },
+ /reusable workflow/,
+ ],
+ };
+ for (const [form, [workflow, job, reason]] of Object.entries(refused)) {
+ expect(restoresNothingProblems(workflow, job).join('\n'), form).toMatch(reason);
+ }
+ expect(() =>
+ restoresNothingProblems({}, buildJob('none', { uses: 'someone/cache@v1' })),
+ ).toThrow(/not classified/);
+ });
+
+ test('the real ships jobs turn red when a cache comes back', () => {
+ const real = (label) => allJobs.find((candidate) => candidate.label === label);
+ const store = {
+ uses: `actions/cache@${sha}`,
+ with: { path: '${{ env.STORE_PATH }}', key: 'Linux-ok-pnpm-store-k' },
+ };
+ const release = real('release.yml#build');
+ expect(
+ restoresNothingProblems(release.workflow, {
+ ...release.job,
+ steps: [...release.job.steps, store],
+ }).join('\n'),
+ ).toMatch(/touches the cache \(extract\)/);
+ const linux = real('desktop-release.yml#build-linux');
+ expect(
+ restoresNothingProblems(linux.workflow, { ...linux.job, 'cache-mode': 'write' }).join('\n'),
+ ).toMatch(/declares cache-mode write, not none/);
+ const prebuild = real('native-config-prebuild.yml#build');
+ const withNode = (inputs) =>
+ prebuild.job.steps.map((step) =>
+ step.uses?.startsWith('actions/setup-node@') ? { ...step, with: inputs } : step,
+ );
+ expect(
+ restoresNothingProblems(prebuild.workflow, {
+ ...prebuild.job,
+ steps: withNode({ 'node-version': '24' }),
+ }).join('\n'),
+ ).toMatch(/does not set package-manager-cache: false at Setup Node/);
+ expect(
+ restoresNothingProblems(prebuild.workflow, {
+ ...prebuild.job,
+ steps: [
+ ...prebuild.job.steps,
+ {
+ uses: 'mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29',
+ with: { 'use-cache': false },
+ },
+ ],
+ }).join('\n'),
+ ).toMatch(/touches the cache \(extract\) at mlugg\/setup-zig/);
+ const combine = real('native-config-prebuild.yml#combine');
+ const { 'cache-mode': _mode, ...combineAtDefault } = combine.job;
+ expect(restoresNothingProblems(combine.workflow, combineAtDefault).join('\n')).toMatch(
+ /declares no cache-mode/,
+ );
+ });
+
+ test('the real QA desktop build jobs turn red when a cache comes back', () => {
+ const real = (label) => allJobs.find((candidate) => candidate.label === label);
+ const store = {
+ uses: `actions/cache@${sha}`,
+ with: { path: '${{ env.STORE_PATH }}', key: 'Linux-ok-pnpm-store-k' },
+ };
+ const prepare = real('desktop-build-win-linux.yml#prepare');
+ expect(
+ restoresNothingProblems(prepare.workflow, {
+ ...prepare.job,
+ steps: [...prepare.job.steps, store],
+ }).join('\n'),
+ ).toMatch(/touches the cache \(extract\)/);
+ const { 'cache-mode': _mode, ...prepareAtDefault } = prepare.job;
+ expect(restoresNothingProblems(prepare.workflow, prepareAtDefault).join('\n')).toMatch(
+ /declares no cache-mode/,
+ );
+ const windows = real('desktop-build-win-linux.yml#build-windows');
+ expect(
+ restoresNothingProblems(windows.workflow, {
+ ...windows.job,
+ steps: windows.job.steps.map((step) =>
+ step.uses?.startsWith('pnpm/setup@') ? { ...step, with: { install: false } } : step,
+ ),
+ }).join('\n'),
+ ).toMatch(/does not set cache: false at pnpm\/setup/);
+ });
+
test('the real signing jobs turn red at the default or at write', () => {
const { workflow } = workflows.find(({ file }) => file === 'desktop-release.yml');
for (const id of ['build-macos', 'build-windows', 'prepare']) {
diff --git a/.github/scripts/native-config-zig-install.test.mjs b/.github/scripts/native-config-zig-install.test.mjs
new file mode 100644
index 000000000..aa4ecb791
--- /dev/null
+++ b/.github/scripts/native-config-zig-install.test.mjs
@@ -0,0 +1,218 @@
+import { spawnSync } from 'node:child_process';
+import { createHash } from 'node:crypto';
+import {
+ chmodSync,
+ existsSync,
+ mkdirSync,
+ mkdtempSync,
+ readFileSync,
+ rmSync,
+ writeFileSync,
+} from 'node:fs';
+import { tmpdir } from 'node:os';
+import { delimiter, dirname, join } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { afterAll, describe, expect, test } from 'vitest';
+import { parse } from 'yaml';
+
+const WORKFLOW = join(
+ dirname(fileURLToPath(import.meta.url)),
+ '..',
+ 'workflows',
+ 'native-config-prebuild.yml',
+);
+const document = parse(readFileSync(WORKFLOW, 'utf8'));
+const job = document.jobs.build;
+const step = job.steps.find(({ name }) => name?.startsWith('Install Zig'));
+
+const runnerBashArgs = () => {
+ const shell = step.shell ?? job.defaults?.run?.shell ?? document.defaults?.run?.shell;
+ if (shell === 'bash') return ['--noprofile', '--norc', '-e', '-o', 'pipefail'];
+ throw new Error(`no runner argument format for the Zig step's shell: ${shell}`);
+};
+
+const sha256 = (bytes) => createHash('sha256').update(bytes).digest('hex');
+const onPath = (command) =>
+ (process.env.PATH ?? '').split(delimiter).some((dir) => existsSync(join(dir, command)));
+
+const CURL_STUB = [
+ '#!/bin/sh',
+ 'out=',
+ 'url=',
+ 'while [ "$#" -gt 0 ]; do',
+ ' case "$1" in',
+ ' -o) out=$2; shift 2 ;;',
+ ' --retry|--max-time|--connect-timeout|--speed-limit|--speed-time) shift 2 ;;',
+ ' -*) shift ;;',
+ ' *) url=$1; shift ;;',
+ ' esac',
+ 'done',
+ 'case "$url" in',
+ ' */community-mirrors.txt) cat "$STUB_MIRRORS"; exit 0 ;;',
+ 'esac',
+ 'while read -r host behavior; do',
+ ' case "$url" in',
+ ' "https://$host/"*)',
+ ' case "$behavior" in',
+ ' fail) echo "curl: (28) Operation too slow" >&2; exit 28 ;;',
+ ' garbage) printf \'not a zig tarball\' > "$out"; exit 0 ;;',
+ ' fixture) cp "$STUB_FIXTURE" "$out"; exit 0 ;;',
+ ' esac ;;',
+ ' esac',
+ 'done < "$STUB_SOURCES"',
+ 'echo "curl stub: no source rule for $url" >&2',
+ 'exit 7',
+ '',
+].join('\n');
+
+const fixtureRoot = mkdtempSync(join(tmpdir(), 'ok-zig-fixture-'));
+afterAll(() => rmSync(fixtureRoot, { recursive: true, force: true }));
+const fixture = (() => {
+ const tree = join(fixtureRoot, 'tree', 'zig-fixture');
+ mkdirSync(tree, { recursive: true });
+ writeFileSync(join(tree, 'zig'), '#!/bin/sh\necho 0.0.0-fixture\n');
+ chmodSync(join(tree, 'zig'), 0o755);
+ const path = join(fixtureRoot, 'zig-fixture.tar.xz');
+ const tar = spawnSync('tar', ['-cJf', path, '-C', join(fixtureRoot, 'tree'), 'zig-fixture'], {
+ encoding: 'utf8',
+ env: { ...process.env, COPYFILE_DISABLE: '1' },
+ });
+ if (tar.status !== 0) throw new Error(`could not build the Zig fixture: ${tar.stderr}`);
+ return { path, tarball: 'zig-fixture.tar.xz', sha256: sha256(readFileSync(path)) };
+})();
+
+const runStep = ({ mirrors, sources, env = {} }) => {
+ const dir = mkdtempSync(join(tmpdir(), 'ok-zig-install-'));
+ try {
+ const bin = join(dir, 'bin');
+ mkdirSync(bin);
+ const stub = (name, body) => {
+ writeFileSync(join(bin, name), body);
+ chmodSync(join(bin, name), 0o755);
+ };
+ stub('curl', CURL_STUB);
+ stub('uname', '#!/bin/sh\necho x86_64\n');
+ stub('shuf', '#!/bin/sh\ncat\n');
+ if (!onPath('sha256sum')) stub('sha256sum', '#!/bin/sh\nexec shasum -a 256 "$@"\n');
+ const runnerTemp = join(dir, 'runner-temp');
+ mkdirSync(runnerTemp);
+ const githubPath = join(dir, 'github-path');
+ writeFileSync(githubPath, '');
+ writeFileSync(join(dir, 'mirrors.txt'), mirrors.map((mirror) => `${mirror}\n`).join(''));
+ writeFileSync(
+ join(dir, 'sources.txt'),
+ Object.entries(sources)
+ .map(([host, behavior]) => `${host} ${behavior}\n`)
+ .join(''),
+ );
+ const script = join(dir, 'install-zig.sh');
+ writeFileSync(script, step.run);
+ const result = spawnSync('bash', [...runnerBashArgs(), script], {
+ encoding: 'utf8',
+ timeout: 30_000,
+ cwd: dir,
+ env: {
+ ...process.env,
+ ...step.env,
+ ...env,
+ PATH: `${bin}${delimiter}${process.env.PATH}`,
+ RUNNER_TEMP: runnerTemp,
+ GITHUB_PATH: githubPath,
+ STUB_MIRRORS: join(dir, 'mirrors.txt'),
+ STUB_SOURCES: join(dir, 'sources.txt'),
+ STUB_FIXTURE: fixture.path,
+ },
+ });
+ return {
+ status: result.status,
+ output: `${result.stdout}${result.stderr}`,
+ githubPath: readFileSync(githubPath, 'utf8'),
+ runnerTemp,
+ };
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+};
+
+describe.skipIf(process.platform === 'win32')(
+ 'native-config-prebuild.yml installs Zig only from bytes matching the pinned sha256',
+ () => {
+ test('the step pins one x86_64 Linux tarball by a full sha256', () => {
+ expect(step, 'the Install Zig step is missing').toBeDefined();
+ expect(step.env.ZIG_TARBALL).toMatch(/^zig-x86_64-linux-\d+\.\d+\.\d+\.tar\.xz$/);
+ expect(step.env.ZIG_SHA256).toMatch(/^[0-9a-f]{64}$/);
+ });
+
+ test('a working tarball whose sha256 is not the pin is refused at every source, and each source is named', () => {
+ const pin = sha256('a different build');
+ const result = runStep({
+ mirrors: ['https://slow.example', 'https://tampered.example/zig'],
+ sources: {
+ 'slow.example': 'fail',
+ 'tampered.example': 'fixture',
+ 'ziglang.org': 'fixture',
+ },
+ env: { ZIG_TARBALL: fixture.tarball, ZIG_SHA256: pin },
+ });
+ expect(result.status, result.output).toBe(1);
+ expect(result.githubPath).toBe('');
+ for (const source of [
+ 'https://tampered.example/zig',
+ 'https://ziglang.org/download/0.14.1',
+ ]) {
+ expect(result.output).toContain(
+ `::warning::${source} served ${fixture.tarball} with sha256 ${fixture.sha256}, not the expected ${pin}`,
+ );
+ }
+ expect(result.output).toContain('https://slow.example did not finish serving');
+ expect(result.output).not.toContain('::warning::https://slow.example');
+ expect(result.output).toContain(
+ `::error::no source served ${fixture.tarball} with sha256 ${pin}, and these served it with a different sha256: https://tampered.example/zig https://ziglang.org/download/0.14.1`,
+ );
+ expect(result.output).not.toContain('0.0.0-fixture');
+ });
+
+ test('the pinned tarball name and sha256 are what the step compares against', () => {
+ const result = runStep({
+ mirrors: ['https://mirror.example'],
+ sources: { 'mirror.example': 'garbage', 'ziglang.org': 'garbage' },
+ });
+ expect(result.status, result.output).toBe(1);
+ expect(result.githubPath).toBe('');
+ expect(result.output).toContain(
+ `::warning::https://mirror.example served ${step.env.ZIG_TARBALL} with sha256 ${sha256('not a zig tarball')}, not the expected ${step.env.ZIG_SHA256}`,
+ );
+ });
+
+ test('when every download fails, the error says no digest could be checked', () => {
+ const result = runStep({
+ mirrors: ['https://slow.example'],
+ sources: { 'slow.example': 'fail', 'ziglang.org': 'fail' },
+ });
+ expect(result.status, result.output).toBe(1);
+ expect(result.githubPath).toBe('');
+ expect(result.output).not.toContain('::warning::');
+ expect(result.output).toContain(
+ `::error::no source served ${step.env.ZIG_TARBALL} with sha256 ${step.env.ZIG_SHA256}; every download failed before its sha256 could be checked`,
+ );
+ });
+
+ test('the first source whose bytes match is installed, after a failed download and a mismatch', () => {
+ const result = runStep({
+ mirrors: ['https://slow.example', 'https://tampered.example', 'https://good.example/zig'],
+ sources: {
+ 'slow.example': 'fail',
+ 'tampered.example': 'garbage',
+ 'good.example': 'fixture',
+ },
+ env: { ZIG_TARBALL: fixture.tarball, ZIG_SHA256: fixture.sha256 },
+ });
+ expect(result.status, result.output).toBe(0);
+ expect(result.githubPath).toBe(`${join(result.runnerTemp, 'zig-fixture')}\n`);
+ expect(result.output).toContain('0.0.0-fixture');
+ expect(result.output).toContain(`Installed ${fixture.tarball} from https://good.example/zig`);
+ expect(result.output).toContain('::warning::https://tampered.example served');
+ expect(result.output).not.toContain('::error::');
+ });
+ },
+);
diff --git a/.github/scripts/release-cascade-shape.test.mjs b/.github/scripts/release-cascade-shape.test.mjs
index 7795bc8dd..61fe28d2a 100644
--- a/.github/scripts/release-cascade-shape.test.mjs
+++ b/.github/scripts/release-cascade-shape.test.mjs
@@ -88,7 +88,7 @@ describe('release jobs install the pnpm version declared by the checked-out tag'
expect(pnpmSteps, `${label} pnpm setup`).toHaveLength(1);
expect(setup).toBeGreaterThan(checkout);
expect(pnpmSteps[0].uses).toBe(tagCompatiblePnpmSetup);
- expect(pnpmSteps[0].with).toBeUndefined();
+ expect(pnpmSteps[0].with).toEqual({ cache: false });
});
});
diff --git a/.github/workflows/desktop-build-win-linux.yml b/.github/workflows/desktop-build-win-linux.yml
index 541261b13..7bfad008b 100644
--- a/.github/workflows/desktop-build-win-linux.yml
+++ b/.github/workflows/desktop-build-win-linux.yml
@@ -70,6 +70,7 @@ env:
jobs:
prepare:
runs-on: ubuntu-latest
+ cache-mode: none
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -77,23 +78,12 @@ jobs:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24"
+ package-manager-cache: false
- uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
with:
install: false
- - name: Get pnpm store directory
- shell: bash
- run: echo "STORE_PATH=$(pnpm store path --silent)" >> "$GITHUB_ENV"
- - name: Hash the lockfile for the pnpm store key
- id: lockfile
- shell: bash
- run: echo "hash=${{ hashFiles('pnpm-lock.yaml') }}" >> "$GITHUB_OUTPUT"
- - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
- with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-ok-pnpm-store-${{ steps.lockfile.outputs.hash }}
- restore-keys: |
- ${{ runner.os }}-ok-pnpm-store-
+ cache: false
- name: Install dependencies
run: pnpm install --frozen-lockfile
@@ -199,10 +189,12 @@ jobs:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24"
+ package-manager-cache: false
- uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
with:
install: false
+ cache: false
- name: Install dependencies
env:
@@ -425,6 +417,7 @@ jobs:
if: inputs.platforms == 'both' || inputs.platforms == 'linux'
needs: prepare
runs-on: ${{ matrix.runner }}
+ cache-mode: none
timeout-minutes: 45
strategy:
# One arch failing must not cancel the other — the operator can still QA
@@ -446,27 +439,12 @@ jobs:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24"
+ package-manager-cache: false
- uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
with:
install: false
- - name: Get pnpm store directory
- shell: bash
- run: echo "STORE_PATH=$(pnpm store path --silent)" >> "$GITHUB_ENV"
- - name: Hash the lockfile for the pnpm store key
- id: lockfile
- shell: bash
- run: echo "hash=${{ hashFiles('pnpm-lock.yaml') }}" >> "$GITHUB_OUTPUT"
- # `runner.arch` is part of the key: both Linux cells report
- # `runner.os == 'Linux'`, and a store populated on x64 carries none of the
- # arm64 prebuilds (and vice versa), so a shared key would thrash the cache
- # between cells on every run.
- - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
- with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-${{ runner.arch }}-ok-pnpm-store-${{ steps.lockfile.outputs.hash }}
- restore-keys: |
- ${{ runner.os }}-${{ runner.arch }}-ok-pnpm-store-
+ cache: false
- name: Install dependencies
env:
diff --git a/.github/workflows/desktop-build.yml b/.github/workflows/desktop-build.yml
index 3024caad1..11733aa2a 100644
--- a/.github/workflows/desktop-build.yml
+++ b/.github/workflows/desktop-build.yml
@@ -95,10 +95,12 @@ jobs:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24"
+ package-manager-cache: false
- uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
with:
install: false
+ cache: false
- name: Install dependencies
# ELECTRON_SKIP_REBUILD=0 overrides the default CI skip in
diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.yml
index fd831a31f..1159a74c1 100644
--- a/.github/workflows/desktop-release.yml
+++ b/.github/workflows/desktop-release.yml
@@ -287,8 +287,11 @@ jobs:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24"
+ package-manager-cache: false
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
+ with:
+ cache: false
- name: Install dependencies
run: pnpm install --frozen-lockfile
@@ -546,8 +549,11 @@ jobs:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24"
+ package-manager-cache: false
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
+ with:
+ cache: false
- name: Install dependencies
env:
@@ -1040,8 +1046,11 @@ jobs:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24"
+ package-manager-cache: false
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
+ with:
+ cache: false
- name: Install dependencies
env:
@@ -1332,6 +1341,7 @@ jobs:
needs: prepare
if: contains(needs.prepare.outputs.platforms, 'linux')
runs-on: ${{ matrix.runner }}
+ cache-mode: none
timeout-minutes: 45
env:
OK_DESKTOP_VARIANT: ${{ matrix.variant }}
@@ -1374,24 +1384,11 @@ jobs:
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24"
+ package-manager-cache: false
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
- - name: Get pnpm store directory
- run: echo "STORE_PATH=$(pnpm store path --silent)" >> "$GITHUB_ENV"
- - name: Hash the lockfile for the pnpm store key
- id: lockfile
- shell: bash
- run: echo "hash=${{ hashFiles('pnpm-lock.yaml') }}" >> "$GITHUB_OUTPUT"
- # `runner.arch` is part of the key: both Linux cells report
- # `runner.os == 'Linux'`, and a store populated on x64 carries none of the
- # arm64 prebuilds (and vice versa), so a shared key would thrash the cache
- # between cells on every run.
- - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-${{ runner.arch }}-ok-pnpm-store-${{ steps.lockfile.outputs.hash }}
- restore-keys: |
- ${{ runner.os }}-${{ runner.arch }}-ok-pnpm-store-
+ cache: false
- name: Install dependencies
env:
diff --git a/.github/workflows/native-config-prebuild.yml b/.github/workflows/native-config-prebuild.yml
index 7eaf61a33..e58d36920 100644
--- a/.github/workflows/native-config-prebuild.yml
+++ b/.github/workflows/native-config-prebuild.yml
@@ -46,6 +46,7 @@ jobs:
build:
name: build - ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
+ cache-mode: none
timeout-minutes: 30
strategy:
fail-fast: false
@@ -87,24 +88,13 @@ jobs:
- uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
with:
install: false
- - name: Get pnpm store directory
- shell: bash
- run: echo "STORE_PATH=$(pnpm store path --silent)" >> "$GITHUB_ENV"
- - name: Hash the lockfile for the pnpm store key
- id: lockfile
- shell: bash
- run: echo "hash=${{ hashFiles('pnpm-lock.yaml') }}" >> "$GITHUB_OUTPUT"
- - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
- with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-ok-pnpm-store-${{ steps.lockfile.outputs.hash }}
- restore-keys: |
- ${{ runner.os }}-ok-pnpm-store-
+ cache: false
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24"
+ package-manager-cache: false
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
@@ -112,31 +102,45 @@ jobs:
toolchain: stable
targets: ${{ matrix.settings.target }}
- - name: Hash the native-config Cargo files for the cargo cache key
- id: cargo-lock
- shell: bash
- run: echo "hash=${{ hashFiles('packages/native-config/Cargo.lock', 'packages/native-config/Cargo.toml') }}" >> "$GITHUB_OUTPUT"
- - name: Cache cargo + target
- uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
- with:
- path: |
- ~/.cargo/registry/index/
- ~/.cargo/registry/cache/
- ~/.cargo/git/db/
- packages/native-config/target/
- # Hash the manifest + lockfile into the key so a crate bump can't be
- # served a stale registry/target tree from an older resolution. The
- # restore-keys prefix still allows a partial warm-start (registry +
- # unchanged crates) on a manifest change.
- key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}-${{ steps.cargo-lock.outputs.hash }}
- restore-keys: |
- ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}-
-
- - name: Setup Zig (musl targets only)
+ - name: Install Zig 0.14.1 from a mirror, checked against its sha256 (musl targets only)
if: contains(matrix.settings.target, 'musl')
- uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2.2.1
- with:
- version: 0.14.1
+ shell: bash
+ env:
+ ZIG_TARBALL: zig-x86_64-linux-0.14.1.tar.xz
+ ZIG_SHA256: 24aeeec8af16c381934a6cd7d95c807a8cb2cf7df9fa40d359aa884195c4716c
+ run: |
+ set -euo pipefail
+ if [ "$(uname -m)" != x86_64 ]; then
+ echo "::error::$ZIG_TARBALL is the x86_64 Linux build, but this runner is $(uname -m)"
+ exit 1
+ fi
+ tarball="$RUNNER_TEMP/$ZIG_TARBALL"
+ mirrors=$(curl -fsSL --retry 3 --max-time 30 https://ziglang.org/download/community-mirrors.txt | shuf || true)
+ mismatched=""
+ for base in $mirrors https://ziglang.org/download/0.14.1; do
+ if ! curl -fsSL --connect-timeout 10 --speed-limit 1000000 --speed-time 15 --max-time 120 \
+ -o "$tarball" "$base/$ZIG_TARBALL?source=open-knowledge-native-config-prebuild"; then
+ echo "$base did not finish serving $ZIG_TARBALL"
+ continue
+ fi
+ actual=$(sha256sum "$tarball" | cut -d ' ' -f 1)
+ if [ "$actual" != "$ZIG_SHA256" ]; then
+ echo "::warning::$base served $ZIG_TARBALL with sha256 $actual, not the expected $ZIG_SHA256"
+ mismatched="$mismatched $base"
+ continue
+ fi
+ tar -xJf "$tarball" -C "$RUNNER_TEMP"
+ "$RUNNER_TEMP/${ZIG_TARBALL%.tar.xz}/zig" version
+ echo "$RUNNER_TEMP/${ZIG_TARBALL%.tar.xz}" >> "$GITHUB_PATH"
+ echo "Installed $ZIG_TARBALL from $base"
+ exit 0
+ done
+ if [ -n "$mismatched" ]; then
+ echo "::error::no source served $ZIG_TARBALL with sha256 $ZIG_SHA256, and these served it with a different sha256:$mismatched"
+ else
+ echo "::error::no source served $ZIG_TARBALL with sha256 $ZIG_SHA256; every download failed before its sha256 could be checked"
+ fi
+ exit 1
- name: Install cargo-zigbuild (musl targets only)
if: contains(matrix.settings.target, 'musl')
@@ -177,6 +181,7 @@ jobs:
name: combine + verify all targets present
needs: build
runs-on: ubuntu-latest
+ cache-mode: none
timeout-minutes: 10
steps:
- name: Download all bindings
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index a92750156..5f003fc74 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -158,6 +158,7 @@ jobs:
name: Build + pack (${{ github.event.action || github.event_name }})
needs: read-releases
runs-on: ubuntu-latest
+ cache-mode: none
timeout-minutes: 20
permissions:
contents: read
@@ -194,24 +195,14 @@ jobs:
ref: ${{ github.event.client_payload.ref || github.sha }}
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
- - name: Get pnpm store directory
- shell: bash
- run: echo "STORE_PATH=$(pnpm store path --silent)" >> "$GITHUB_ENV"
- - name: Hash the lockfile for the pnpm store key
- id: lockfile
- shell: bash
- run: echo "hash=${{ hashFiles('pnpm-lock.yaml') }}" >> "$GITHUB_OUTPUT"
- - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-ok-pnpm-store-${{ steps.lockfile.outputs.hash }}
- restore-keys: |
- ${{ runner.os }}-ok-pnpm-store-
+ cache: false
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24"
+ package-manager-cache: false
- name: Ensure npm 11 for the cli's package surface check
run: |