Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions bin/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type BuildPrActorOptions = {
versionNumber: string;
gitRepoUrl: string;
actorName: string;
useDockerCache: boolean;
};
class ApifyBuilder {
private constructor(
Expand Down Expand Up @@ -51,7 +52,12 @@ class ApifyBuilder {
return { defaultBuildNumber, defaultVersionNumber, defaultBuildTag };
};

startActorBuild = async ({ buildTag, versionNumber, gitRepoUrl }: BuildPrActorOptions): Promise<BuildData> => {
startActorBuild = async ({
buildTag,
versionNumber,
gitRepoUrl,
useDockerCache,
}: BuildPrActorOptions): Promise<BuildData> => {
const actorClient = this.apifyClient.actor(this.actorName);
const actorInfo = await actorClient.get();
if (!actorInfo) {
Expand Down Expand Up @@ -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 };
Expand Down Expand Up @@ -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) : [];
Expand All @@ -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) {
Expand Down
8 changes: 6 additions & 2 deletions bin/diff-changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,12 @@ export const getChangedActors = ({
file: string;
change: Extract<FileChange, { impact: 'cosmetic' }>;
}[];
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)}`,
);
Expand Down
11 changes: 9 additions & 2 deletions bin/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
Expand Down Expand Up @@ -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 },
Expand All @@ -148,6 +152,7 @@ await yargs()
actorConfigs: actorsChanged,
branch: sourceBranch.replace('origin/', ''),
dryRun,
useDockerCache,
});
console.log(JSON.stringify(builds));
},
Expand All @@ -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,
Expand All @@ -180,6 +186,7 @@ await yargs()
actorConfigs: actorsChanged,
branch,
dryRun,
useDockerCache: args.useDockerCache,
});
console.error(JSON.stringify(builds));

Expand Down
Loading