From ba6321f52f18e6a74252c3d2fc27d765c8d18b75 Mon Sep 17 00:00:00 2001
From: askalf <263217947+askalf@users.noreply.github.com>
Date: Fri, 13 Nov 2026 11:56:34 -0500
Subject: [PATCH] tree-tested: allow other repositories checked out at a pinned
commit
A job that also checks out another repository, at a full commit sha its own tree names, never
skipped: the rule wanted one actions/checkout step and one "HEAD is now at" line in the log.
The new pinned-checkouts input names such repositories. The log is cut into steps, and each
actions/checkout step's repository, ref and path are read from the inputs the runner prints under
"with:". Exactly one checkout is of the job's own repository and shows the pull request merge, as
before. Every other one must be of a named repository, at a ref that is a full commit sha, into a
relative directory of its own, and at that commit. A "HEAD is now at" line outside a checkout step
still runs the push in full. With the input empty, the rule is as strict as it was.
---
CHANGELOG.md | 6 ++
actions/tree-tested/action.yml | 18 ++++-
actions/tree-tested/main.mjs | 2 +-
scripts/tree-tested/check.mjs | 113 +++++++++++++++++++++++------
scripts/tree-tested/check.test.mjs | 77 +++++++++++++++++---
5 files changed, 181 insertions(+), 35 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6c10b7b..3ec893e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,12 @@ names the commit's date and the pull request it came from.
## November 2026
+- `actions/tree-tested` takes `pinned-checkouts`: other repositories a job checks out at a commit
+ its own tree names, such as a full sha read from a file of the checkout. The job log must show
+ each one checked out at a full commit sha, into a directory of its own under the workspace, and
+ at that commit. A checkout of a repository not named there still runs the push in full, as does
+ a second checkout of the job's own repository or a "HEAD is now at" line outside a checkout.
+ Each checkout's repository, ref and path are read from the inputs the runner prints for it.
- The bump job in `redline-pin-bump.yml` may run 45 minutes, up from 30. Twenty callers at the
measured rate need about 29 minutes with room to spare, so the next caller would not have fit;
45 covers thirty. `scripts/redline/pin-bump.test.mjs` now also fails a limit of an hour or more,
diff --git a/actions/tree-tested/action.yml b/actions/tree-tested/action.yml
index 0c4eb47..0b8f0db 100644
--- a/actions/tree-tested/action.yml
+++ b/actions/tree-tested/action.yml
@@ -11,9 +11,11 @@
# as an early step of a job, and puts `if: steps.tree.outputs.tested != 'true'` on the steps that
# install, build and test. same-on-pull-request is the caller's word that the job runs the same steps,
# commands and inputs on a push as on a pull request (nothing that runs only on push, no matrix a
-# push widens, one checkout of the event's own commit); without it the answer is always false. On anything but a push to the default branch it answers false without a
-# request. Every read that fails, and every rule that does not hold, answers false too: the job then
-# runs in full, as it did before. The step never fails the job.
+# push widens, one checkout of the event's own commit); without it the answer is always false. A
+# job that also checks out another repository at a commit its tree names (a pinned sha in a file)
+# lists that repository in pinned-checkouts. On anything but a push to the default branch it answers
+# false without a request. Every read that fails, and every rule that does not hold, answers false
+# too: the job then runs in full, as it did before. The step never fails the job.
#
# It checks out nothing and runs on the Node the runner ships. The job's token needs actions: read,
# contents: read and pull-requests: read, which a workflow's default token has unless its
@@ -32,6 +34,16 @@ inputs:
on a pull request. Anything else, and the answer is false.
required: false
default: 'false'
+ pinned-checkouts:
+ description: >-
+ Other repositories this job checks out, owner/name, separated by spaces, commas or new lines.
+ Each is the caller's word that its checkout is at a full commit sha the tree itself names (read
+ from a file of the checkout, so the same tree checks out the same commit), into a directory of
+ its own. The log must show each checkout at a full sha, in a path under the workspace. A
+ checkout of a repository not named here is not taken. Empty, the default: the job may check
+ out only its own repository.
+ required: false
+ default: ''
default-branch:
description: The repository's default branch. A caller passes none.
required: false
diff --git a/actions/tree-tested/main.mjs b/actions/tree-tested/main.mjs
index 08e6fc3..b9d8d14 100644
--- a/actions/tree-tested/main.mjs
+++ b/actions/tree-tested/main.mjs
@@ -7,7 +7,7 @@ import { main } from '../../scripts/tree-tested/check.mjs';
const input = (name) => (process.env[`INPUT_${name.toUpperCase()}`] ?? '').trim();
try {
- process.exitCode = await main({ ...process.env, GITHUB_TOKEN: input('token'), DEFAULT_BRANCH: input('default-branch'), SAME_ON_PULL_REQUEST: input('same-on-pull-request') });
+ process.exitCode = await main({ ...process.env, GITHUB_TOKEN: input('token'), DEFAULT_BRANCH: input('default-branch'), SAME_ON_PULL_REQUEST: input('same-on-pull-request'), PINNED_CHECKOUTS: input('pinned-checkouts') });
} catch (e) {
// A failure of the check runs the job in full; it never fails the job.
console.log(`tested in full: ${e.message}`);
diff --git a/scripts/tree-tested/check.mjs b/scripts/tree-tested/check.mjs
index ad6b069..86f8966 100644
--- a/scripts/tree-tested/check.mjs
+++ b/scripts/tree-tested/check.mjs
@@ -17,6 +17,11 @@
// checkout of anything but the event's own commit, and nothing after that checkout that moves the
// tests onto other files (a branch switch, a reset, a second checkout). What the rules below can
// check, they check; the rest is the caller's word.
+// One more checkout is allowed when the caller names its repository in pinned-checkouts: another
+// repository, checked out into a directory of its own at a full commit sha that the tree itself
+// names (it reads that repository's sha from a file of its own checkout). The same tree then
+// names the same commit on the push. That the sha comes from the tree is the caller's word; that the
+// checkout was at a full sha, in its own directory, and of a repository named, the log shows.
//
// The rule, all of it read from the GitHub API with the job's own token:
// 0. The caller declared the job the same on push and on pull request (above).
@@ -36,9 +41,13 @@
// labels as this one: a job whose runs-on depends on who opened the pull request (a fork's or
// a bot's pull request on a hosted runner, its push on a self-hosted one) tested on another
// machine than the push would, and is not taken.
-// 6. That job's log shows what its checkout made. It has exactly one actions/checkout step, and
-// exactly one "HEAD is now at" line in the whole log, and that line is inside the checkout
-// step and reads "Merge
into ": GitHub's merge of the pull request. The head
+// 6. That job's log shows what its checkouts made. Every "HEAD is now at" line in the log is
+// inside an actions/checkout step, one to a step. Exactly one of those steps checks out this
+// repository, and its line reads "Merge into ": GitHub's merge of the pull
+// request. Each other checkout step (its repository, ref and path read from the inputs the
+// runner prints under "with:") is of a repository named in pinned-checkouts, at a ref that is
+// a full commit sha, into a relative path that is a directory of its own, and its line is at
+// that commit. The head
// there is the pull request's head, and that base is inside the head by GitHub's compare. A
// merge of a base the head already holds is the head's own tree, so the checkout was exactly
// the pushed tree, whatever branch the pull request pointed at then and whatever main did
@@ -75,6 +84,7 @@ export function factsOf(env) {
runId: text('GITHUB_RUN_ID'),
runnerName: text('RUNNER_NAME'),
declared: text('SAME_ON_PULL_REQUEST'),
+ pinned: text('PINNED_CHECKOUTS'),
};
}
@@ -157,28 +167,89 @@ export function runnerProblem(me, twin) {
const STEP_START = /##\[group\]Run (.*)$/;
const CHECKOUT_STEP = /^actions\/checkout@/;
-const HEAD_LINE = /HEAD is now at [0-9a-f]{7,40} /;
+const HEAD_LINE = /HEAD is now at ([0-9a-f]{7,40}) /;
const MERGE_LINE = /HEAD is now at [0-9a-f]{7,40} Merge ([0-9a-f]{40}) into ([0-9a-f]{40})\s*$/;
+/** The runner's timestamp at the start of every log line. */
+const STAMP = /^\d{4}-\d\d-\d\dT[0-9:.]+Z /;
+/** One input of a step's "with:" block, as the runner prints it: two spaces, name, colon, value. */
+const WITH_INPUT = /^ {2}([A-Za-z0-9_-]+): ?(.*)$/;
+
+/**
+ * The repositories a caller named in pinned-checkouts: owner/name words, lower case, split on
+ * whitespace or commas. A word that is not owner/name is dropped, so it names nothing. Pure.
+ */
+export function pinnedList(text) {
+ return [...new Set(String(text ?? '').split(/[\s,]+/).map((w) => w.trim().toLowerCase()).filter((w) => REPO_RE.test(w)))];
+}
+
+/** Why a pinned checkout's path is not a directory of its own under the workspace, or ''. Pure. */
+function pathProblem(path) {
+ const p = String(path ?? '').trim();
+ if (!p) return 'no path, so it checks out over the workspace';
+ if (p.startsWith('/') || /^[A-Za-z]:/.test(p) || p.startsWith('~')) return `the path ${p} is not under the workspace`;
+ const parts = p.split(/[\\/]+/).filter(Boolean);
+ if (parts.length === 0 || parts.every((x) => x === '.') || parts.includes('..')) return `the path ${p} is not a directory of its own under the workspace`;
+ return '';
+}
+
/**
- * What a job's log shows its tests ran on: { head, base } of the pull request merge its one
- * checkout made, or { why }. The log is cut into steps at each "##[group]Run " line; there
- * must be exactly one actions/checkout step, exactly one "HEAD is now at" line in the whole log,
- * and that line inside the checkout step, naming a merge. Pure.
+ * What a job's log shows its tests ran on: { head, base } of the pull request merge its checkout of
+ * this repository made, or { why }. The log is cut into steps at each "##[group]Run " line,
+ * and each actions/checkout step's "with:" block (the inputs the runner prints, expressions already
+ * filled in) says what it checked out. Every "HEAD is now at" line must be inside an actions/checkout
+ * step, and each of those steps must have exactly one. Exactly one checkout is of this repository
+ * (its repository input, or none, which is this repository), and its line names a merge. Every
+ * other checkout is of a repository the caller named in pinned-checkouts, into a path of its own
+ * under the workspace, at a ref that is a full commit sha, and its line is at that commit. Pure.
+ * opts: { repo: owner/name, pinned: [owner/name, ...] (lower case) }.
*/
-export function checkoutMerge(log) {
+export function checkoutMerge(log, opts = {}) {
+ const repo = String(opts.repo ?? '').toLowerCase();
+ const pinned = Array.isArray(opts.pinned) ? opts.pinned : [];
const lines = String(log ?? '').split(/\r?\n/);
- let step = '';
- let checkouts = 0;
- const heads = [];
- for (const line of lines) {
- const s = STEP_START.exec(line);
- if (s) { step = s[1].trim(); if (CHECKOUT_STEP.test(step)) checkouts++; continue; }
- if (HEAD_LINE.test(line)) heads.push({ line, step });
+ const steps = [];
+ let cur = { name: '', checkout: false, inputs: {}, heads: [] };
+ let inWith = false;
+ let first = false;
+ for (const raw of lines) {
+ const s = STEP_START.exec(raw);
+ if (s) {
+ cur = { name: s[1].trim(), inputs: {}, heads: [] };
+ cur.checkout = CHECKOUT_STEP.test(cur.name);
+ steps.push(cur);
+ inWith = false; first = true;
+ continue;
+ }
+ const line = raw.replace(STAMP, '');
+ if (first && cur.checkout && line === 'with:') { inWith = true; first = false; continue; }
+ first = false;
+ if (inWith) {
+ const w = WITH_INPUT.exec(line);
+ if (w) { if (!(w[1] in cur.inputs)) cur.inputs[w[1]] = w[2].trim(); continue; }
+ inWith = false;
+ }
+ if (HEAD_LINE.test(line)) {
+ if (!cur.checkout) return { why: `a "HEAD is now at" line is outside every checkout step (in ${cur.name ? `"${cur.name.slice(0, 60)}"` : 'the job\'s setup'}), so something after the checkout may have moved what the tests ran on` };
+ cur.heads.push(line);
+ }
+ }
+ const checkouts = steps.filter((st) => st.checkout);
+ const repoOf = (st) => String(st.inputs.repository || repo).toLowerCase();
+ const own = checkouts.filter((st) => repoOf(st) === repo);
+ if (own.length !== 1) return { why: `the job has ${own.length} actions/checkout steps of ${repo || 'this repository'}, not one` };
+ for (const st of checkouts) {
+ if (st.heads.length !== 1) return { why: `a checkout of ${repoOf(st)} printed ${st.heads.length} "HEAD is now at" lines, not one` };
+ if (st === own[0]) continue;
+ const other = repoOf(st);
+ if (!pinned.includes(other)) return { why: `the job also checks out ${other}, which the caller has not named in pinned-checkouts` };
+ const ref = String(st.inputs.ref ?? '');
+ if (!SHA_RE.test(ref)) return { why: `its checkout of ${other} is at ${ref ? `the ref ${ref.slice(0, 60)}` : 'no ref'}, not a full commit sha, so a later run may get another commit` };
+ const where = pathProblem(st.inputs.path);
+ if (where) return { why: `its checkout of ${other} has ${where}` };
+ const at = HEAD_LINE.exec(st.heads[0])[1];
+ if (!ref.startsWith(at)) return { why: `its checkout of ${other} asked for ${ref.slice(0, 7)} and is at ${at}` };
}
- if (checkouts !== 1) return { why: `the job has ${checkouts} actions/checkout steps, not one` };
- if (heads.length !== 1) return { why: `the log has ${heads.length} "HEAD is now at" lines, not one, so something after the checkout may have moved what the tests ran on` };
- if (!CHECKOUT_STEP.test(heads[0].step)) return { why: 'its one "HEAD is now at" line is not in the checkout step' };
- const m = MERGE_LINE.exec(heads[0].line);
+ const m = MERGE_LINE.exec(own[0].heads[0]);
if (!m) return { why: 'the checkout did not check out a pull request merge' };
return { head: m[1], base: m[2] };
}
@@ -264,7 +335,7 @@ export async function decide(env, io = { fetch: globalThis.fetch }) {
const elsewhere = runnerProblem(me, twins[0]);
if (elsewhere) return { tested: false, why: `${elsewhere} (${run.html_url ?? run.id})` };
// What that job checked out.
- const seen = checkoutMerge(await getLog(io, env, f.repo, twins[0].id));
+ const seen = checkoutMerge(await getLog(io, env, f.repo, twins[0].id), { repo: f.repo, pinned: pinnedList(f.pinned) });
if (seen.why) return { tested: false, why: `in the log of "${me.name}" there, ${seen.why}; what it tested is not known` };
const { head: tHead, base: tBase } = seen;
if (tHead !== head) return { tested: false, why: `"${me.name}" there checked out a merge of ${tHead.slice(0, 7)}, not of #${pr.number}'s head ${head.slice(0, 7)}` };
diff --git a/scripts/tree-tested/check.test.mjs b/scripts/tree-tested/check.test.mjs
index 452bf13..09f7e64 100644
--- a/scripts/tree-tested/check.test.mjs
+++ b/scripts/tree-tested/check.test.mjs
@@ -4,7 +4,7 @@
import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
-import { factsOf, notEligible, mergedAs, runAtHead, jobsProblem, contains, thisJob, runnerProblem, checkoutMerge, decide, main } from './check.mjs';
+import { factsOf, notEligible, mergedAs, runAtHead, jobsProblem, contains, thisJob, runnerProblem, checkoutMerge, pinnedList, decide, main } from './check.mjs';
let pass = 0;
let fail = 0;
@@ -35,8 +35,22 @@ const job = (name, conclusion = 'success', steps = [step('Set up job'), step('Te
const mine = (name, runner = 'pool-e3', labels = LABELS) => ({ id: 1, name, status: 'in_progress', runner_name: runner, labels });
// A job log as GitHub writes it: each step opens with "##[group]Run ".
const T = '2026-11-12T02:58:14.1195074Z ';
-const checkoutStep = (head = HEAD, base = BASE) => [`${T}##[group]Run actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1`, `${T}with:`, `${T}##[endgroup]`,
+const checkoutStep = (head = HEAD, base = BASE) => [`${T}##[group]Run actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1`, `${T}with:`, `${T} repository: ${REPO}`, `${T} token: ***`,
+ `${T} fetch-depth: 2`, `${T}env:`, `${T} GIT_CONFIG_COUNT: 2`, `${T}##[endgroup]`, `${T}Syncing repository: ${REPO}`,
`${T}##[group]Checking out the ref`, `${T}HEAD is now at 25a09da Merge ${head} into ${base}`, `${T}##[endgroup]`];
+// A checkout of another repository, as checkout-with-retry prints it (a real job log,
+// 2026-11-13): the composite's own group and inputs, then the inner actions/checkout with its
+// inputs filled in, its fetch, and the composite's next inner step.
+const PIN = '04072ed'.padEnd(40, '9');
+const PINNED = 'askalf/vendored';
+const pinnedStep = ({ repo = PINNED, ref = PIN, path = 'pitlane', at = (ref ?? 'aaaaaaa').slice(0, 7), heads = 1, extra = [] } = {}) => {
+ const inputs = [repo !== null && `${T} repository: ${repo}`, ref !== null && `${T} ref: ${ref}`, path !== null && `${T} path: ${path}`].filter(Boolean);
+ return [`${T}##[group]Run askalf/ci/actions/checkout-with-retry@${'1'.repeat(40)}`, `${T}with:`, ...inputs, `${T}##[endgroup]`,
+ `${T}##[group]Run actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1`, `${T}with:`, ...inputs, `${T} token: ***`, `${T} clean: true`, ...extra, `${T}##[endgroup]`,
+ `${T}Syncing repository: ${repo}`, `${T}##[group]Checking out the ref`, `${T}[command]/usr/bin/git checkout --progress --force ${ref}`,
+ ...Array.from({ length: heads }, () => `${T}HEAD is now at ${at} a pinned commit`), `${T}##[endgroup]`,
+ `${T}##[group]Run if [ "skipped" = "success" ]; then`, `${T}##[endgroup]`];
+};
const testStep = (out = 'tests pass') => [`${T}##[group]Run npm test`, `${T}npm test`, `${T}##[endgroup]`, `${T}${out}`];
const checkoutLog = (head = HEAD, base = BASE) => [`${T}##[group]Run askalf/ci/actions/checkout-with-retry@${'1'.repeat(40)}`, `${T}##[endgroup]`, ...checkoutStep(head, base), ...testStep()].join('\n') + '\n';
@@ -87,6 +101,7 @@ console.log('\n the facts and who is looked up');
console.log('\n the pure rules');
{
+ const O = { repo: REPO };
check('the pull request merged as this commit is found', mergedAs([pr({ number: 3, merge_commit_sha: OTHER }), pr()], REPO, SHA)?.number === 7);
check('an open, unmerged or other repository\'s pull request is not',
mergedAs([pr({ merged_at: null }), pr({ base: { repo: { full_name: 'x/y' } } }), pr({ head: { sha: 'short' } })], REPO, SHA) === null && mergedAs(null, REPO, SHA) === null);
@@ -111,17 +126,55 @@ console.log('\n the pure rules');
/ran on \[ubuntu-latest\], this job on \[pool-exec, self-hosted\]: another machine/.test(runnerProblem(mine('a'), job('a', 'success', undefined, ['ubuntu-latest']))));
check('a job with no labels listed, on either side, is not taken',
/not listed for both runs/.test(runnerProblem(mine('a', 'pool-e3', []), job('a'))) && /not listed for both runs/.test(runnerProblem(mine('a'), { name: 'a' })));
- check('the merge the one checkout made is read from its step', JSON.stringify(checkoutMerge(checkoutLog())) === JSON.stringify({ head: HEAD, base: BASE }));
+ check('the merge the one checkout made is read from its step', JSON.stringify(checkoutMerge(checkoutLog(), O)) === JSON.stringify({ head: HEAD, base: BASE }));
const lines = (...parts) => parts.flat().join('\n');
// A merge checkout, then a step that checks out an older ordinary commit before the tests.
- check('a later checkout of another commit, even by hand, is caught: two "HEAD is now at" lines',
- /2 "HEAD is now at" lines/.test(checkoutMerge(lines(checkoutStep(), [`${T}##[group]Run git checkout ${OTHER}`, `${T}##[endgroup]`, `${T}HEAD is now at ddddddd an older commit`], testStep())).why));
- check('a second actions/checkout step is not taken', /2 actions\/checkout steps/.test(checkoutMerge(lines(checkoutStep(), checkoutStep(), testStep())).why));
+ check('a later checkout of another commit, even by hand, is caught: a "HEAD is now at" line outside a checkout step',
+ /outside every checkout step \(in "git checkout d+"\)/.test(checkoutMerge(lines(checkoutStep(), [`${T}##[group]Run git checkout ${OTHER}`, `${T}##[endgroup]`, `${T}HEAD is now at ddddddd an older commit`], testStep()), O).why));
+ check('a second actions/checkout step is not taken', /2 actions\/checkout steps of askalf\/demo, not one/.test(checkoutMerge(lines(checkoutStep(), checkoutStep(), testStep()), O).why));
check('a merge line printed by a test, outside the checkout, is not taken',
- /not in the checkout step/.test(checkoutMerge(lines([`${T}##[group]Run actions/checkout@${'2'.repeat(40)}`, `${T}##[endgroup]`], testStep(`HEAD is now at 25a09da Merge ${HEAD} into ${BASE}`))).why));
+ /outside every checkout step \(in "npm test"\)/.test(checkoutMerge(lines([`${T}##[group]Run actions/checkout@${'2'.repeat(40)}`, `${T}##[endgroup]`], testStep(`HEAD is now at 25a09da Merge ${HEAD} into ${BASE}`)), O).why));
check('a checkout of the head itself, not a merge, is not taken',
- /did not check out a pull request merge/.test(checkoutMerge(lines([`${T}##[group]Run actions/checkout@${'2'.repeat(40)}`, `${T}HEAD is now at bbbbbbb the head commit`], testStep())).why));
- check('no checkout at all is not taken', /0 actions\/checkout steps/.test(checkoutMerge(lines(testStep())).why) && /0 actions\/checkout steps/.test(checkoutMerge('').why));
+ /did not check out a pull request merge/.test(checkoutMerge(lines([`${T}##[group]Run actions/checkout@${'2'.repeat(40)}`, `${T}HEAD is now at bbbbbbb the head commit`], testStep()), O).why));
+ check('no checkout at all is not taken', /0 actions\/checkout steps of askalf\/demo/.test(checkoutMerge(lines(testStep()), O).why) && /0 actions\/checkout steps of this repository/.test(checkoutMerge('').why));
+}
+
+console.log('\n a checkout of another repository at a pinned commit');
+{
+ const O_REPO = { repo: REPO };
+ const lines = (...parts) => parts.flat().join('\n');
+ const P = { repo: REPO, pinned: [PINNED] };
+ const ok = (log, opts = P) => JSON.stringify(checkoutMerge(log, opts)) === JSON.stringify({ head: HEAD, base: BASE });
+ const why = (log, opts = P) => checkoutMerge(log, opts).why ?? '';
+ check('pinned-checkouts is read as owner/name words, lower case, split on spaces, commas and new lines; other words name nothing',
+ JSON.stringify(pinnedList('Askalf/Vendored, a/b\n c/d not-a-repo a/b ../x')) === JSON.stringify(['askalf/vendored', 'a/b', 'c/d']) && pinnedList('').length === 0 && pinnedList(undefined).length === 0);
+ check('the merge, then a named repository at a full sha into a directory of its own: the merge is read',
+ ok(lines(checkoutStep(), testStep(), pinnedStep(), testStep())));
+ check('the pinned checkout first and the merge after it reads the same', ok(lines(pinnedStep(), checkoutStep(), testStep())));
+ check('names are compared without case, on either side', ok(lines(checkoutStep(), pinnedStep({ repo: 'Askalf/Vendored' })), { repo: 'ASKALF/demo', pinned: pinnedList('askalf/VENDORED') }));
+ check('a nested path is a directory of its own', ok(lines(checkoutStep(), pinnedStep({ path: 'vendor/pitlane' }))));
+ check('without pinned-checkouts, a checkout of another repository is not taken',
+ /also checks out askalf\/vendored, which the caller has not named in pinned-checkouts/.test(why(lines(checkoutStep(), pinnedStep()), O_REPO)));
+ check('a repository other than the ones named is not taken',
+ /also checks out askalf\/other, which the caller has not named/.test(why(lines(checkoutStep(), pinnedStep({ repo: 'askalf/other' })))));
+ check('a branch, a tag, a short sha or no ref is not a pinned commit: a later run may get another one',
+ [['main', /the ref main, not a full commit sha/], ['v1.2.3', /the ref v1\.2\.3/], [PIN.slice(0, 12), /the ref 04072ed99999, not a full/], [null, /at no ref, not a full commit sha/]]
+ .every(([ref, re]) => re.test(why(lines(checkoutStep(), pinnedStep({ ref, at: '04072ed' }))))));
+ check('no path, or a path that is the workspace, above it or outside it, is not a directory of its own',
+ [[null, /no path, so it checks out over the workspace/], ['.', /not a directory of its own/], ['./', /not a directory of its own/], ['a/../..', /not a directory of its own/],
+ ['/srv/elsewhere', /not under the workspace/], ['C:/x', /not under the workspace/], ['~/x', /not under the workspace/]]
+ .every(([path, re]) => re.test(why(lines(checkoutStep(), pinnedStep({ path }))))));
+ check('a checkout that landed on another commit than its ref is not taken',
+ /asked for 04072ed and is at 1234567/.test(why(lines(checkoutStep(), pinnedStep({ at: '1234567' })))));
+ check('a pinned checkout with two "HEAD is now at" lines, or none, is not taken',
+ /askalf\/vendored printed 2 "HEAD is now at" lines/.test(why(lines(checkoutStep(), pinnedStep({ heads: 2 })))) && /printed 0/.test(why(lines(checkoutStep(), pinnedStep({ heads: 0 })))));
+ check('a second checkout of this repository, even at a pinned sha into a path, is still a second one',
+ /2 actions\/checkout steps of askalf\/demo/.test(why(lines(checkoutStep(), pinnedStep({ repo: REPO })), { repo: REPO, pinned: [REPO] })));
+ check('a ref under env:, not with:, is not read as the checkout\'s ref',
+ /at no ref/.test(why(lines(checkoutStep(), pinnedStep({ ref: null, at: '04072ed', extra: [`${T}env:`, `${T} ref: ${PIN}`] })))));
+ check('a "HEAD is now at" line in a step after the pinned checkout is still caught',
+ /outside every checkout step/.test(why(lines(checkoutStep(), pinnedStep(), [`${T}##[group]Run cd pitlane && git checkout main`, `${T}HEAD is now at 9999999 moved`]))));
+ check('a "HEAD is now at" line before any step is caught', /outside every checkout step \(in the job's setup\)/.test(why(lines([`${T}HEAD is now at 9999999 x`], checkoutStep()))));
}
console.log('\n the decision against a stubbed GitHub');
@@ -149,7 +202,7 @@ for (const [name, over, re, envOver] of [
{ [`/repos/${REPO}/actions/runs/${RUN_ID}/jobs`]: { total_count: 1, jobs: [mine('test (windows)')] } }, /"test \(windows\)" is not a job in .*did not run it/],
['this job is not found in its own run', { [`/repos/${REPO}/actions/runs/${RUN_ID}/jobs`]: { total_count: 1, jobs: [mine('unit', 'someone-else')] } }, /not found in run 555/],
['this run\'s jobs cannot be read', { [`/repos/${REPO}/actions/runs/${RUN_ID}/jobs`]: 500 }, /HTTP 500/],
- ['the log shows no checkout', { LOG: { text: 'no checkout line\n' } }, /0 actions\/checkout steps, not one; what it tested is not known/],
+ ['the log shows no checkout', { LOG: { text: 'no checkout line\n' } }, /0 actions\/checkout steps of askalf\/demo, not one; what it tested is not known/],
['the log shows a merge checkout and then another checkout', { LOG: { text: checkoutLog() + checkoutLog(HEAD, RELEASE) } }, /2 actions\/checkout steps/],
// A matrix whose entries share one display name, wider on push: the job asking cannot be matched.
['two jobs of this run share the display name of the job asking (a wider push matrix under name: test)',
@@ -166,6 +219,7 @@ for (const [name, over, re, envOver] of [
// Main gained a change and reverted it between the run and the merge: the run merged the head
// into main with that change, a base the head does not hold.
['main changed and reverted after the run', { [`/repos/${REPO}/compare/${BASE}...${HEAD}`]: { status: 'diverged' } }, /does not hold/],
+ ['the job also checks out a pinned repository the caller did not name', { LOG: { text: checkoutLog() + [...pinnedStep(), ''].join('\n') } }, /in the log of "unit" there, the job also checks out askalf\/vendored, which the caller has not named/],
['the log cannot be read', { LOG: 410 }, /HTTP 410/],
['the compare cannot be read', { [`/repos/${REPO}/compare/${BASE}...${HEAD}`]: 500 }, /HTTP 500/],
['the pull request list cannot be read', { [`/repos/${REPO}/commits/${SHA}/pulls`]: 500 }, /HTTP 500; tested in full/],
@@ -176,6 +230,9 @@ for (const [name, over, re, envOver] of [
check(`${name}: tested in full`, d.tested === false && re.test(d.why));
}
{
+ const pinnedOk = await decide(env({ PINNED_CHECKOUTS: 'askalf/vendored' }), world({ LOG: { text: checkoutLog() + [...pinnedStep(), ''].join('\n') } }));
+ check('a named repository checked out at a pinned commit, the merge of the head as well: tested', pinnedOk.tested === true);
+ check('pinned-checkouts is read from the environment', factsOf(env({ PINNED_CHECKOUTS: ' a/b ' })).pinned === 'a/b');
const same = await decide(env(), world({ LOG: { text: checkoutLog(HEAD, HEAD) }, [`/repos/${REPO}/compare/${HEAD}...${HEAD}`]: { status: 'identical' } }));
check('a base that is the head itself counts as held', same.tested === true);
const w2 = world();