19 lines
1.7 KiB
JavaScript
19 lines
1.7 KiB
JavaScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import assert from 'node:assert/strict';
|
|
import { createHash } from 'node:crypto';
|
|
import { spawn } from 'node:child_process';
|
|
import { projectEnvironment } from '../src/core/process-environment.mjs';
|
|
const hash = bytes => createHash('sha256').update(bytes).digest('hex');
|
|
const baseline = JSON.parse(fs.readFileSync('docs/project-cache-release-code-baseline.json'));
|
|
function unchanged() { for (const item of [...baseline.inputs, ...baseline.builds, ...baseline.benchmarks]) assert.equal(hash(fs.readFileSync(item.path)), item.sha256, item.path); }
|
|
assert.equal(baseline.version, '1.19.0'); unchanged();
|
|
const logPath='.qa/cache-f-package.log'; assert.equal(fs.existsSync(logPath), false);
|
|
fs.writeFileSync('.qa/cache-f-prior-latest.json', fs.readFileSync('releases/latest.json'), {flag:'wx'});
|
|
const startedAt=new Date().toISOString(), log=fs.createWriteStream(logPath,{flags:'wx'});
|
|
const child=spawn(process.execPath,['scripts/package.mjs','--immutable'], {windowsHide:true, env:projectEnvironment({PATH:path.dirname(process.execPath)+path.delimiter+process.env.PATH}),stdio:['ignore','pipe','pipe']});
|
|
child.stdout.on('data',b=>log.write(b)); child.stderr.on('data',b=>log.write(b));
|
|
const exitCode=await new Promise((resolve,reject)=>{child.once('error',reject);child.once('close',resolve)}); await new Promise(resolve=>log.end(resolve)); unchanged();
|
|
const result={success:exitCode===0,exitCode,startedAt,finishedAt:new Date().toISOString(),codeCommit:baseline.codeCommit,logPath,logSha256:hash(fs.readFileSync(logPath)),unchangedInputs:true};
|
|
fs.writeFileSync('.qa/cache-f-package-result.json',JSON.stringify(result,null,2)+'\n',{flag:'wx'}); console.log(JSON.stringify(result)); if(exitCode!==0)process.exitCode=1;
|