Files
angular__angular/aio/scripts/local-workspace-status.mjs
Derek Cormier 4ae66558bf 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
2023-01-02 12:16:12 +00:00

36 lines
1.5 KiB
JavaScript

import fs from 'node:fs';
import path from 'node:path';
import url from 'node:url';
/*
Script to use as a Bazel workspace status command (https://bazel.build/docs/user-manual#workspace-status)
when building AIO against local Angular packages (--config=aio_local_deps). This provides an Angular version
stamp variable used to stamp the locally built Angular packages. We stamp the packages with whatever version
of Angular AIO is currently using. In order for the architect build to succeed, we need to trick architect
into thinking it's using compatible Angular versions even if the Angular version is actually futher ahead.
*/
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
const pkgJsonPath = path.join(__dirname, '..', 'package.json');
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
const aioAngularVersion = pkgJson.dependencies['@angular/core'].replace(/^[\^~]/, '') + "+forAIOLocalBuildToAvoidMismatch";
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
`)