From 6846e1ec36a4d1bb9e97ae9dfe7a4cc86af5ab33 Mon Sep 17 00:00:00 2001 From: metalwarrior665 Date: Mon, 11 May 2026 13:18:46 +0200 Subject: [PATCH] feat: option to use docker cache on all builds --- bin/build.ts | 22 ++++++++++++++++++---- bin/diff-changes.ts | 8 ++++++-- bin/main.ts | 11 +++++++++-- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/bin/build.ts b/bin/build.ts index 5b7b1aa..a5784c7 100644 --- a/bin/build.ts +++ b/bin/build.ts @@ -11,6 +11,7 @@ type BuildPrActorOptions = { versionNumber: string; gitRepoUrl: string; actorName: string; + useDockerCache: boolean; }; class ApifyBuilder { private constructor( @@ -51,7 +52,12 @@ class ApifyBuilder { return { defaultBuildNumber, defaultVersionNumber, defaultBuildTag }; }; - startActorBuild = async ({ buildTag, versionNumber, gitRepoUrl }: BuildPrActorOptions): Promise => { + startActorBuild = async ({ + buildTag, + versionNumber, + gitRepoUrl, + useDockerCache, + }: BuildPrActorOptions): Promise => { const actorClient = this.apifyClient.actor(this.actorName); const actorInfo = await actorClient.get(); if (!actorInfo) { @@ -84,7 +90,7 @@ class ApifyBuilder { } // We also get back actId so the testing actor can both match by actor ID and name - const { id, actId, buildNumber } = await actorClient.build(versionNumber); + const { id, actId, buildNumber } = await actorClient.build(versionNumber, { useCache: useDockerCache }); console.error(`[${this.actorName}]: ${id} (${buildNumber})`); return { buildId: id, actorId: actId, buildNumber, actorName: this.actorName }; @@ -224,9 +230,17 @@ type RunBuildsOptions = { repoUrl: string; branch: string; dryRun: boolean; + useDockerCache: boolean; }; -export const runBuilds = async ({ repoUrl, branch, actorConfigs, isLatest = false, dryRun }: RunBuildsOptions) => { +export const runBuilds = async ({ + repoUrl, + branch, + actorConfigs, + isLatest = false, + dryRun, + useDockerCache, +}: RunBuildsOptions) => { const buildConfigs: BuildPrActorOptions[] = []; const circleActors = isLatest ? await findCircleApifyManaged(actorConfigs) : []; @@ -249,7 +263,7 @@ export const runBuilds = async ({ repoUrl, branch, actorConfigs, isLatest = fals if (folder) { gitRepoUrl = `${gitRepoUrl}:${folder}`; } - buildConfigs.push({ actorName, gitRepoUrl, versionNumber, buildTag }); + buildConfigs.push({ actorName, gitRepoUrl, versionNumber, buildTag, useDockerCache }); } if (dryRun) { diff --git a/bin/diff-changes.ts b/bin/diff-changes.ts index 9e4c86b..7af55e0 100644 --- a/bin/diff-changes.ts +++ b/bin/diff-changes.ts @@ -140,8 +140,12 @@ export const getChangedActors = ({ file: string; change: Extract; }[]; - const semanticallyVerifiedFiles = cosmeticChanges.filter(({ change }) => change.semanticallyVerified).map(({ file }) => file); - const inherentlyCosmeticFiles = cosmeticChanges.filter(({ change }) => !change.semanticallyVerified).map(({ file }) => file); + const semanticallyVerifiedFiles = cosmeticChanges + .filter(({ change }) => change.semanticallyVerified) + .map(({ file }) => file); + const inherentlyCosmeticFiles = cosmeticChanges + .filter(({ change }) => !change.semanticallyVerified) + .map(({ file }) => file); console.error( `[DIFF]: Cosmetic-only JSON schema changes (semantically verified, only trigger release build): ${formatFiles(semanticallyVerifiedFiles)}`, ); diff --git a/bin/main.ts b/bin/main.ts index 21d2fb1..120ea1b 100644 --- a/bin/main.ts +++ b/bin/main.ts @@ -30,6 +30,10 @@ const buildOptions = (y: Argv) => { type: 'string', demandOption: true, }) + .option('use-docker-cache', { + type: 'boolean', + default: false, + }) .option('base-commit', { type: 'string', }); @@ -131,7 +135,7 @@ await yargs() 'build', '', (args) => buildOptions(args).option('dry-run', { type: 'boolean', default: false }), - async ({ targetBranch, sourceBranch, baseCommit, dryRun }) => { + async ({ targetBranch, sourceBranch, baseCommit, dryRun, useDockerCache }) => { const actorsChanged = await resolveChangedActors( { targetBranch, sourceBranch, baseCommit }, { isLatest: false }, @@ -148,6 +152,7 @@ await yargs() actorConfigs: actorsChanged, branch: sourceBranch.replace('origin/', ''), dryRun, + useDockerCache, }); console.log(JSON.stringify(builds)); }, @@ -160,7 +165,8 @@ await yargs() .option('push-event-path', { type: 'string', demandOption: true }) .option('dry-run', { type: 'boolean', default: false }) .option('report-slack-channel', { type: 'string' }) - .option('release-slack-channel', { type: 'string' }), + .option('release-slack-channel', { type: 'string' }) + .option('use-docker-cache', { type: 'boolean', default: false }), async (args) => { const { branch, changedFiles, repoUrl, commits, changelog, repository, author } = await getPushData( args.pushEventPath, @@ -180,6 +186,7 @@ await yargs() actorConfigs: actorsChanged, branch, dryRun, + useDockerCache: args.useDockerCache, }); console.error(JSON.stringify(builds));