Skip to content

Commit be65e92

Browse files
committed
fix(ci): round boundary artifact refresh mtimes
1 parent c2eeac1 commit be65e92

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎scripts/prepare-extension-package-boundary-artifacts.mts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ export function isArtifactSetFresh(params: ArtifactFreshParams) {
552552
}
553553
// Repair the mtime fast path so later invocations in this checkout skip
554554
// without re-reading every input byte.
555-
const now = new Date();
555+
const now = new Date(Math.max(Date.now(), Math.ceil(newestInputMtimeMs)));
556556
for (const relativePath of params.outputPaths) {
557557
const outputPath = resolve(rootDir, relativePath);
558558
if (fs.existsSync(outputPath)) {

‎test/scripts/prepare-extension-package-boundary-artifacts.test.ts‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,16 +583,26 @@ describe("prepare-extension-package-boundary-artifacts", () => {
583583
// Simulate checkout: inputs newer than restored outputs, bytes unchanged.
584584
fs.utimesSync(stampPath, new Date(1_000), new Date(1_000));
585585
fs.utimesSync(outputPath, new Date(1_000), new Date(1_000));
586+
const repairTimeMs = Date.now();
587+
fs.utimesSync(inputPath, repairTimeMs / 1_000, (repairTimeMs + 0.5) / 1_000);
586588
const freshParams = {
587589
rootDir,
588590
inputPaths: ["src"],
589591
outputPaths: ["dist/.demo.stamp", "dist/demo.d.ts"],
590592
hashStampPath: "dist/.demo.stamp",
591593
};
592594

593-
expect(isArtifactSetFresh(freshParams)).toBe(true);
594-
// The hash match repairs output mtimes so the next check takes the fast path.
595-
expect(fs.statSync(outputPath).mtimeMs).toBeGreaterThanOrEqual(fs.statSync(inputPath).mtimeMs);
595+
vi.useFakeTimers();
596+
vi.setSystemTime(repairTimeMs);
597+
try {
598+
expect(isArtifactSetFresh(freshParams)).toBe(true);
599+
// Round past fractional filesystem precision so the next check takes the fast path.
600+
expect(fs.statSync(outputPath).mtimeMs).toBeGreaterThanOrEqual(
601+
fs.statSync(inputPath).mtimeMs,
602+
);
603+
} finally {
604+
vi.useRealTimers();
605+
}
596606

597607
fs.appendFileSync(inputPath, "export const demoTwo = 2;\n", "utf8");
598608
fs.utimesSync(outputPath, new Date(1_000), new Date(1_000));

0 commit comments

Comments
 (0)