Skip to content

Commit

Permalink
[dev/ts-refs] don't use cache when building a new cache or when using…
Browse files Browse the repository at this point in the history
… --clean
  • Loading branch information
spalger committed Feb 13, 2021
1 parent 1d11f02 commit 3dbcc27
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions src/dev/typescript/build_ts_refs_cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,45 @@ export async function runBuildRefsCli() {
async ({ log, flags }) => {
const outDirs = getOutputsDeep(REF_CONFIG_PATHS);

if (flags.clean) {
const cacheEnabled = process.env.BUILD_TS_REFS_CACHE_ENABLE === 'true' || !!flags.cache;
const doCapture = process.env.BUILD_TS_REFS_CACHE_CAPTURE === 'true';
const doClean = !!flags.clean || doCapture;
const doInitCache = cacheEnabled && !doClean;

if (doClean) {
log.info('deleting', outDirs.length, 'ts output directories');
await concurrentMap(100, outDirs, (outDir) => del(outDir));
}

let outputCache;
if (flags.cache) {
if (cacheEnabled) {
outputCache = await RefOutputCache.create({
log,
outDirs,
repoRoot: REPO_ROOT,
workingDir: CACHE_WORKING_DIR,
upstreamUrl: 'https://github.com/elastic/kibana.git',
});
}

if (outputCache && doInitCache) {
await outputCache.initCaches();
}

await buildAllTsRefs(log);

if (outputCache) {
if (process.env.BUILD_TS_REFS_CACHE_CAPTURE === 'true') {
await outputCache.captureCache(Path.resolve(REPO_ROOT, 'target/ts_refs_cache'));
}
if (outputCache && doCapture) {
await outputCache.captureCache(Path.resolve(REPO_ROOT, 'target/ts_refs_cache'));
}

if (outputCache) {
await outputCache.cleanup();
}
},
{
description: 'Build TypeScript projects',
flags: {
boolean: ['clean', 'cache'],
default: {
cache: process.env.BUILD_TS_REFS_CACHE_ENABLE === 'true' ? true : false,
},
},
log: {
defaultLevel: 'debug',
Expand Down
2 changes: 1 addition & 1 deletion src/dev/typescript/ref_output_cache/repo_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class RepoInfo {

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

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

return mergeBase;
Expand Down

0 comments on commit 3dbcc27

Please sign in to comment.