16export type SkipResult = { skip: boolean, reason?: string, lastRecord?: ActionResult } 18export const shouldSkipTests = async ({ep, ptenv}: { 21}): Promise<SkipResult> => { 25 r.ep === epRel && r.action === 'runtests' && r.ptenv === ptenv && r.success 27 if (!last?.gitSha) return { skip: false } 30 const lastSha = last.gitSha 32 // Tier 1: same commit (fast path — no tree computation needed) 33 if (currentSha === lastSha) { 34 if (isVeryVerbose) betLog({tier: 'memo:tier1', skip: true}) 35 return { skip: true, reason: `unchanged at ${currentSha}`, lastRecord: last } 38 // Tier 1.5: reuse lastSha's cached import tree to check for diffs before recomputing. 39 // Safe because any file added to the tree between shas implies a modifying edit to a 40 // file already in the old tree (the one that gained the new import) → gitDiff catches it. 42 if (lastTree?.length) { 43 const lastAllPaths = [...lastTree, ...globalDependPaths] 45 if (!uncommittedInLastTree.length) { 48 if (isVeryVerbose) betLog({tier: 'memo:tier1.5', skip: true}) 49 return { skip: true, reason: `no import-tree changes since ${lastSha}`, lastRecord: last } 51 } catch { // catch:userapproved 57 const allPaths = [...importPaths, ...globalDependPaths] 60 if (uncommittedInCodeTree.length) { 61 if (isVeryVerbose) betLog({tier: 'memo:uncommitted', skip: false}) 62 return { skip: false } 65 // Tier 2: different commit but no import-tree diff 68 if (isVeryVerbose) betLog({tier: 'memo:tier2', skip: true}) 69 return { skip: true, reason: `no import-tree changes since ${lastSha}`, lastRecord: last } 71 } catch { // catch:userapproved 72 // old SHA pruned from git, etc. — don't skip 75 if (isVeryVerbose) betLog({tier: 'memo:miss', skip: false}) 76 return { skip: false } 79export const printSkipMsg = (ptenv: Ptenv, reason: string, lastRecord?: ActionResult) => { 81 if (lastRecord?.suites) { 82 for (const [name, sr] of Object.entries(lastRecord.suites)) { 84 console.log(` ${status} testsuite=${name} ${sr.message} ${chalkGray('(memoized)')}`) 88 const cliSchema = action && availActionsCtx.getStore()?.[action]?.cliSchema