From 6d6632f648b15faf0eb609de093a95f1d1675c1f Mon Sep 17 00:00:00 2001 From: kazadoiyul Date: Wed, 22 Oct 2025 10:12:38 +0200 Subject: [PATCH 1/2] feat: ignore test files --- bin/utils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/utils.ts b/bin/utils.ts index c96700a..8e9a1db 100644 --- a/bin/utils.ts +++ b/bin/utils.ts @@ -117,6 +117,11 @@ const isIgnoredTopLevelFile = (lowercaseFilePath: string) => { return IGNORED_TOP_LEVEL_FILES.some((ignoredFile) => sanitizedLowercaseFilePath.startsWith(ignoredFile)); }; +const isIgnoredTestFile = (lowercaseFilePath: string) => { + const sanitizedLowercaseFilePath = lowercaseFilePath.replace(/^code\//, '').replace(/^shared\//, ''); + return sanitizedLowercaseFilePath.startsWith('tests/'); +} + const isLatestBuildOnlyFile = (lowercaseFilePath: string) => { if (lowercaseFilePath.endsWith('changelog.md')) { return true; @@ -145,7 +150,7 @@ export const getChangedActors = ( const lowercaseFiles = filepathsChanged.map((file) => file.toLowerCase()); for (const lowercaseFilePath of lowercaseFiles) { - if (isIgnoredTopLevelFile(lowercaseFilePath)) { + if (isIgnoredTopLevelFile(lowercaseFilePath) || isIgnoredTestFile(lowercaseFilePath)) { continue; } // First we check for specific actors that have configs in /actors or standalone actors in /standalone-actors From f370276327d7683533536be777bad8704e6b7ac8 Mon Sep 17 00:00:00 2001 From: kazadoiyul Date: Wed, 22 Oct 2025 10:14:18 +0200 Subject: [PATCH 2/2] feat: get existing builds to run tests --- bin/build.ts | 16 ++++++++++++++++ bin/main.ts | 14 ++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/bin/build.ts b/bin/build.ts index 1651db5..2a972da 100644 --- a/bin/build.ts +++ b/bin/build.ts @@ -174,6 +174,13 @@ class ApifyBuilder { await this.apifyClient.build(build.id).delete(); } } + + async getDefaultBuilt() { + const client = this.apifyClient.actor(this.actorName) + const { defaultVersionNumber } = await this.getDefaultVersionAndTag() + const { id, actId, buildNumber } = await client.build(defaultVersionNumber) + return { buildId: id, actorId: actId, buildNumber, actorName: this.actorName }; + } } type RunBuildsOptions = { @@ -184,6 +191,15 @@ type RunBuildsOptions = { dryRun: boolean } +export const getAllDefaultBuilds = async (actorConfigs: ActorConfig[]) => { + const existingBuilds = await Promise.all( + actorConfigs.map(actor => + ApifyBuilder.fromActorName(actor.actorName).getDefaultBuilt() + ) + ); + return existingBuilds; +} + export const runBuilds = async ({ repoUrl, branch, diff --git a/bin/main.ts b/bin/main.ts index 157ce0e..754876f 100644 --- a/bin/main.ts +++ b/bin/main.ts @@ -10,7 +10,7 @@ import { spawnCommandInGhWorkspace, setCwd, } from './utils.js'; -import { runBuilds } from './build.js'; +import {getAllDefaultBuilds, runBuilds} from './build.js'; import { getChangedFiles, getCommits } from './git.js'; import { getPushData } from './github.js'; import { notifyToSlack } from './slack.js'; @@ -107,7 +107,17 @@ await yargs() branch: args.sourceBranch.replace('origin/', ''), dryRun: args.dryRun, }); - console.log(JSON.stringify(builds)); + + if (args.dryRun) { + console.log(JSON.stringify([...builds])); + return; + } + + // add a build entry even if no build was triggered to run the tests on all actors + const remainingActors = actorConfigs.filter((a) => !actorsChanged.find((ac) => ac.actorName === a.actorName)) + const existingBuilds = await getAllDefaultBuilds(remainingActors) + + console.log(JSON.stringify([...builds, ...existingBuilds])); }) .command( 'release',