mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
build(bazel): improve remote caching for AIO local deps build (#48579)
Fix non-hermetic zipping of example zips by fixing the zip entry timestamps. I also hardcoded stamp values in stable-status.txt and volatile-status.txt using the workspace status command for the aio_local_deps config to improve cache performance. The Bazel remote cache appears to not ignore volatile-status.txt when there are no other changes, unlike the local Bazel cache: https://github.com/bazelbuild/bazel/issues/10075#issuecomment-546872111 PR Close #48579
This commit is contained in:
committed by
Paul Gschwendtner
parent
125b3df884
commit
4ae66558bf
@@ -125,7 +125,6 @@ copy_to_directory(
|
||||
# All source and configuration files required to build the docs app
|
||||
APPLICATION_FILES = [
|
||||
"angular.json",
|
||||
"package.json",
|
||||
"tsconfig.app.json",
|
||||
"tsconfig.json",
|
||||
"tsconfig.worker.json",
|
||||
|
||||
@@ -16,7 +16,20 @@ const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
|
||||
|
||||
const aioAngularVersion = pkgJson.dependencies['@angular/core'].replace(/^[\^~]/, '') + "+forAIOLocalBuildToAvoidMismatch";
|
||||
|
||||
// Output the workspace status variable format to stdout so Bazel can read it
|
||||
console.log(`\
|
||||
BUILD_SCM_VERSION ${aioAngularVersion}
|
||||
`);
|
||||
|
||||
// Fix stable-status.txt values to improve remote cache performance.
|
||||
console.log(`\
|
||||
BUILD_HOST fake_host
|
||||
BUILD_USER fake_user
|
||||
`)
|
||||
|
||||
// Fix the timestamp in volatile-status.txt to improve remote cache performance.
|
||||
// Unlike the local Bazel cache, the remote cache does not ignore volatile-status.txt
|
||||
// and will invalidate actions that depend on it when the values change.
|
||||
// https://github.com/bazelbuild/bazel/issues/10075#issuecomment-546872111
|
||||
console.log(`\
|
||||
BUILD_TIMESTAMP 0
|
||||
`)
|
||||
|
||||
@@ -182,18 +182,25 @@ export class ExampleZipper {
|
||||
// zip.append(fs.createReadStream(fileName), { name: relativePath });
|
||||
let output = regionExtractor()(content, extn).contents;
|
||||
|
||||
zip.append(output, { name: relativePath } );
|
||||
appendToZip(zip, output, { name: relativePath });
|
||||
});
|
||||
|
||||
// also a systemjs config
|
||||
if (exampleType === 'systemjs') {
|
||||
zip.append(fs.readFileSync(this.examplesSystemjsConfig, 'utf8'), { name: 'src/systemjs.config.js' });
|
||||
zip.append(fs.readFileSync(this.examplesSystemjsLoaderConfig, 'utf8'), { name: 'src/systemjs-angular-loader.js' });
|
||||
appendToZip(zip, fs.readFileSync(this.examplesSystemjsConfig, 'utf8'), { name: 'src/systemjs.config.js' });
|
||||
appendToZip(zip, fs.readFileSync(this.examplesSystemjsLoaderConfig, 'utf8'), { name: 'src/systemjs-angular-loader.js' });
|
||||
// a modified tsconfig
|
||||
let tsconfig = fs.readFileSync(this.exampleTsconfig, 'utf8');
|
||||
zip.append(this._changeTypeRoots(tsconfig), {name: 'src/tsconfig.json'});
|
||||
appendToZip(zip, this._changeTypeRoots(tsconfig), {name: 'src/tsconfig.json' });
|
||||
}
|
||||
|
||||
zip.finalize();
|
||||
}
|
||||
}
|
||||
|
||||
// Fix the timestamp on zip entries in order create reproducible zip
|
||||
// files, which improves remote Bazel cache performance.
|
||||
function appendToZip(zip, source, data) {
|
||||
const FIXED_DATE = new Date(0);
|
||||
zip.append(source, {...data, date: FIXED_DATE});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user