Skip to content

Commit 3dbcc27

Browse files
committed
[dev/ts-refs] don't use cache when building a new cache or when using --clean
1 parent 1d11f02 commit 3dbcc27

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/dev/typescript/build_ts_refs_cli.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,45 @@ export async function runBuildRefsCli() {
2323
async ({ log, flags }) => {
2424
const outDirs = getOutputsDeep(REF_CONFIG_PATHS);
2525

26-
if (flags.clean) {
26+
const cacheEnabled = process.env.BUILD_TS_REFS_CACHE_ENABLE === 'true' || !!flags.cache;
27+
const doCapture = process.env.BUILD_TS_REFS_CACHE_CAPTURE === 'true';
28+
const doClean = !!flags.clean || doCapture;
29+
const doInitCache = cacheEnabled && !doClean;
30+
31+
if (doClean) {
2732
log.info('deleting', outDirs.length, 'ts output directories');
2833
await concurrentMap(100, outDirs, (outDir) => del(outDir));
2934
}
3035

3136
let outputCache;
32-
if (flags.cache) {
37+
if (cacheEnabled) {
3338
outputCache = await RefOutputCache.create({
3439
log,
3540
outDirs,
3641
repoRoot: REPO_ROOT,
3742
workingDir: CACHE_WORKING_DIR,
3843
upstreamUrl: 'https://github.com/elastic/kibana.git',
3944
});
45+
}
4046

47+
if (outputCache && doInitCache) {
4148
await outputCache.initCaches();
4249
}
4350

4451
await buildAllTsRefs(log);
4552

46-
if (outputCache) {
47-
if (process.env.BUILD_TS_REFS_CACHE_CAPTURE === 'true') {
48-
await outputCache.captureCache(Path.resolve(REPO_ROOT, 'target/ts_refs_cache'));
49-
}
53+
if (outputCache && doCapture) {
54+
await outputCache.captureCache(Path.resolve(REPO_ROOT, 'target/ts_refs_cache'));
55+
}
5056

57+
if (outputCache) {
5158
await outputCache.cleanup();
5259
}
5360
},
5461
{
5562
description: 'Build TypeScript projects',
5663
flags: {
5764
boolean: ['clean', 'cache'],
58-
default: {
59-
cache: process.env.BUILD_TS_REFS_CACHE_ENABLE === 'true' ? true : false,
60-
},
6165
},
6266
log: {
6367
defaultLevel: 'debug',

src/dev/typescript/ref_output_cache/repo_info.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class RepoInfo {
3131

3232
this.log.info('determining merge base with upstream');
3333

34-
const mergeBase = this.git(['merge-base', ref, 'FETCH_HEAD']);
34+
const mergeBase = await this.git(['merge-base', ref, 'FETCH_HEAD']);
3535
this.log.info('merge base with', upstreamBranch, 'is', mergeBase);
3636

3737
return mergeBase;

0 commit comments

Comments
 (0)