apify-test-tools 0.9.1-beta.10 → 0.9.1-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/.github/workflows/public_push-build-latest.yaml +3 -1
  2. package/.github/workflows-package-version +1 -1
  3. package/CHANGELOG.md +2 -0
  4. package/CONTRIBUTING.md +2 -4
  5. package/README.md +146 -35
  6. package/bin/build-from-local.ts +2 -2
  7. package/bin/build.ts +114 -70
  8. package/bin/git.ts +140 -0
  9. package/bin/main.ts +46 -19
  10. package/bin/slack.ts +5 -2
  11. package/bin/types.ts +0 -73
  12. package/bin/utils/config/parser.ts +6 -5
  13. package/bin/utils/config/structures/base.ts +5 -1
  14. package/bin/utils/config/structures/grouped.ts +40 -0
  15. package/bin/utils/config/structures/legacy.ts +3 -1
  16. package/bin/utils.ts +2 -3
  17. package/dist/bin/build-from-local.js.map +1 -1
  18. package/dist/bin/build.d.ts +25 -4
  19. package/dist/bin/build.d.ts.map +1 -1
  20. package/dist/bin/build.js +76 -47
  21. package/dist/bin/build.js.map +1 -1
  22. package/dist/bin/git.d.ts +40 -0
  23. package/dist/bin/git.d.ts.map +1 -1
  24. package/dist/bin/git.js +118 -0
  25. package/dist/bin/git.js.map +1 -1
  26. package/dist/bin/main.d.ts.map +1 -1
  27. package/dist/bin/main.js +33 -13
  28. package/dist/bin/main.js.map +1 -1
  29. package/dist/bin/slack.d.ts.map +1 -1
  30. package/dist/bin/slack.js +4 -2
  31. package/dist/bin/slack.js.map +1 -1
  32. package/dist/bin/types.d.ts +0 -64
  33. package/dist/bin/types.d.ts.map +1 -1
  34. package/dist/bin/utils/config/parser.d.ts.map +1 -1
  35. package/dist/bin/utils/config/parser.js +6 -5
  36. package/dist/bin/utils/config/parser.js.map +1 -1
  37. package/dist/bin/utils/config/structures/base.d.ts +3 -2
  38. package/dist/bin/utils/config/structures/base.d.ts.map +1 -1
  39. package/dist/bin/utils/config/structures/base.js +1 -0
  40. package/dist/bin/utils/config/structures/base.js.map +1 -1
  41. package/dist/bin/utils/config/structures/grouped.d.ts +6 -0
  42. package/dist/bin/utils/config/structures/grouped.d.ts.map +1 -0
  43. package/dist/bin/utils/config/structures/grouped.js +29 -0
  44. package/dist/bin/utils/config/structures/grouped.js.map +1 -0
  45. package/dist/bin/utils/config/structures/legacy.d.ts +1 -1
  46. package/dist/bin/utils/config/structures/legacy.d.ts.map +1 -1
  47. package/dist/bin/utils/config/structures/legacy.js +1 -1
  48. package/dist/bin/utils/config/structures/legacy.js.map +1 -1
  49. package/dist/bin/utils.d.ts.map +1 -1
  50. package/dist/bin/utils.js +2 -3
  51. package/dist/bin/utils.js.map +1 -1
  52. package/dist/test/unit/bin/build.test.d.ts +2 -0
  53. package/dist/test/unit/bin/build.test.d.ts.map +1 -0
  54. package/dist/test/unit/bin/build.test.js +46 -0
  55. package/dist/test/unit/bin/build.test.js.map +1 -0
  56. package/dist/test/unit/bin/git.test.js +104 -1
  57. package/dist/test/unit/bin/git.test.js.map +1 -1
  58. package/dist/test/unit/bin/utils/config/load-config.test.js +1 -0
  59. package/dist/test/unit/bin/utils/config/load-config.test.js.map +1 -1
  60. package/dist/test/unit/bin/utils/config/parser.test.js +23 -5
  61. package/dist/test/unit/bin/utils/config/parser.test.js.map +1 -1
  62. package/dist/test/unit/bin/utils/config/structures/grouped.test.d.ts +2 -0
  63. package/dist/test/unit/bin/utils/config/structures/grouped.test.d.ts.map +1 -0
  64. package/dist/test/unit/bin/utils/config/structures/grouped.test.js +75 -0
  65. package/dist/test/unit/bin/utils/config/structures/grouped.test.js.map +1 -0
  66. package/dist/tsconfig.tsbuildinfo +1 -1
  67. package/package.json +2 -2
  68. package/test/unit/bin/build.test.ts +68 -0
  69. package/test/unit/bin/git.test.ts +122 -0
  70. package/test/unit/bin/utils/config/load-config.test.ts +1 -0
  71. package/test/unit/bin/utils/config/parser.test.ts +26 -5
  72. package/test/unit/bin/utils/config/structures/grouped.test.ts +90 -0
  73. package/bin/github.ts +0 -69
  74. package/dist/bin/github.d.ts +0 -11
  75. package/dist/bin/github.d.ts.map +0 -1
  76. package/dist/bin/github.js +0 -59
  77. package/dist/bin/github.js.map +0 -1
package/bin/git.ts CHANGED
@@ -145,3 +145,143 @@ export const parseCommit = (commitString: string): Commit => {
145
145
  message,
146
146
  };
147
147
  };
148
+
149
+ /**
150
+ * Returns the currently checked-out branch. Release builds point the Actor version at this branch,
151
+ * so a detached HEAD (no branch to point at) is an error rather than a guess.
152
+ */
153
+ export const getCurrentBranch = (): string => {
154
+ const branch = spawnCommandInGhWorkspace('git rev-parse --abbrev-ref HEAD');
155
+ if (branch === 'HEAD') {
156
+ throw new Error(
157
+ 'Cannot determine the branch to release: HEAD is detached. Check out the branch you want to release.',
158
+ );
159
+ }
160
+ return branch;
161
+ };
162
+
163
+ /**
164
+ * Reads the repository URL from the `origin` remote, rewritten to the SSH form the Apify platform
165
+ * uses for Git repo sources, e.g. git@github.com:apify-store/google-maps
166
+ */
167
+ const getOriginRepoUrl = (): string => {
168
+ return spawnCommandInGhWorkspace('git remote get-url origin').replace(
169
+ /^https:\/\/github\.com\//,
170
+ 'git@github.com:',
171
+ );
172
+ };
173
+
174
+ /**
175
+ * Picks the repo URL to build from. By default it's the `origin` remote, and runBuilds then checks it against
176
+ * each Actor's default version, so a fork or mirror remote can't repoint a published Actor. An explicit
177
+ * --repo-url skips that check: passing it is how you move an Actor to another repository on purpose.
178
+ */
179
+ export const resolveRepoUrl = (explicitRepoUrl: string | undefined) => ({
180
+ repoUrl: explicitRepoUrl ?? getOriginRepoUrl(),
181
+ shouldVerifyRepoUrl: explicitRepoUrl === undefined,
182
+ });
183
+
184
+ /**
185
+ * Makes repo URLs comparable regardless of their form. All of these normalize to `github.com/org/repo`:
186
+ * - git@github.com:org/repo.git
187
+ * - https://github.com/org/repo
188
+ * - ssh://git@github.com/org/repo#master:actors/foo (Actor versions carry a `#branch:folder` fragment)
189
+ */
190
+ export const normalizeRepoUrl = (repoUrl: string): string => {
191
+ return repoUrl
192
+ .trim()
193
+ .split('#')[0]
194
+ .replace(/^[a-z+]+:\/\//i, '')
195
+ .replace(/^[^@/]+@/, '')
196
+ .replace(':', '/')
197
+ .replace(/\/+$/, '')
198
+ .replace(/\.git$/, '')
199
+ .toLowerCase();
200
+ };
201
+
202
+ /** Repository name from its URL, e.g. `google-maps` for git@github.com:apify-store/google-maps.git */
203
+ export const getRepoName = (repoUrl: string): string => {
204
+ return normalizeRepoUrl(repoUrl).split('/').pop()!;
205
+ };
206
+
207
+ // Sent by e.g. GitHub as the "before" commit of a push that created the branch
208
+ const ZERO_SHA_REGEX = /^0{40}$/;
209
+
210
+ /**
211
+ * Validates the base commit of a release: the last commit whose changes are already released.
212
+ * Unlike the PR path (getCommits), there is no lenient fallback. Falling back to "everything"
213
+ * would rebuild the latest build of every Actor and post it to Slack, so every problem is an error.
214
+ */
215
+ export const resolveReleaseBaseCommit = (baseCommit: string): string => {
216
+ const sha = parseBaseCommit(baseCommit);
217
+ if (!sha) {
218
+ throw new Error('--base-commit is required for release. See the README section "Releasing Actors".');
219
+ }
220
+ if (ZERO_SHA_REGEX.test(sha)) {
221
+ throw new Error(
222
+ `Base commit is ${sha}, which means the branch was just created and there is no previous release to diff against. ` +
223
+ `Rerun with --base-commit set to the last commit before the changes you want to release.`,
224
+ );
225
+ }
226
+ // --quiet makes rev-parse print nothing (instead of an error) when the commit is missing
227
+ if (!spawnCommandInGhWorkspace(`git rev-parse --verify --quiet "${sha}^{commit}"`)) {
228
+ throw new Error(
229
+ `Base commit ${sha} is not in the local git history. Either the checkout is shallow ` +
230
+ `(fetch the full history, e.g. fetch-depth: 0 in actions/checkout) or the branch was force-pushed.`,
231
+ );
232
+ }
233
+ // git merge-base A B outputs the common ancestor. If that equals A, then A is an ancestor of B.
234
+ if (spawnCommandInGhWorkspace(`git merge-base ${sha} HEAD`) !== sha) {
235
+ throw new Error(
236
+ `Base commit ${sha} is not an ancestor of HEAD, most likely because the branch was force-pushed. ` +
237
+ `The changed files cannot be determined reliably. Rerun with --base-commit set to an ancestor of HEAD ` +
238
+ `from before the changes you want to release.`,
239
+ );
240
+ }
241
+ return sha;
242
+ };
243
+
244
+ const CHANGELOG_PATH = 'CHANGELOG.md';
245
+
246
+ /** Returns the lines added to the root CHANGELOG.md between baseSha and HEAD, or null if it didn't change. */
247
+ const getChangelogAdditions = (baseSha: string, changedFiles: string[]): string | null => {
248
+ if (!changedFiles.includes(CHANGELOG_PATH)) {
249
+ return null;
250
+ }
251
+ const diff = spawnCommandInGhWorkspace('git', ['diff', baseSha, 'HEAD', '--', CHANGELOG_PATH]);
252
+
253
+ const added: string[] = [];
254
+ let startedChangelog = false;
255
+ for (const line of diff.split('\n')) {
256
+ // The diff is already limited to the changelog but better to double check
257
+ if (line.startsWith('+++') && line.toLowerCase().includes(CHANGELOG_PATH.toLowerCase())) {
258
+ startedChangelog = true;
259
+ continue;
260
+ }
261
+ if (startedChangelog) {
262
+ if (line.startsWith('diff')) {
263
+ break;
264
+ }
265
+ if (line.startsWith('+')) {
266
+ added.push(line.slice(1).trim());
267
+ }
268
+ }
269
+ }
270
+ return added.join('\n').trim();
271
+ };
272
+
273
+ /**
274
+ * Everything that changed since the last release (baseSha, exclusive) up to HEAD, or null when there
275
+ * are no new commits. Changed files come from diffing the range directly instead of from the commit
276
+ * list: with a merge commit, the oldest commit of the merged branch can be older than baseSha, and
277
+ * diffing from its parent would pull in already-released changes.
278
+ */
279
+ export const getReleaseChanges = (baseSha: string) => {
280
+ if (spawnCommandInGhWorkspace('git rev-parse HEAD') === baseSha) {
281
+ return null;
282
+ }
283
+ const commits = fetchAllBranchCommits('HEAD', baseSha);
284
+ const changedFiles = spawnCommandInGhWorkspace(`git diff --name-only ${baseSha} HEAD`).split('\n').filter(Boolean);
285
+ const changelog = getChangelogAdditions(baseSha, changedFiles);
286
+ return { commits, changedFiles, changelog };
287
+ };
package/bin/main.ts CHANGED
@@ -9,12 +9,21 @@ import { hideBin } from 'yargs/helpers';
9
9
  import { deleteOldBuilds, runBuilds } from './build.js';
10
10
  import { runBuildsFromLocal } from './build-from-local.js';
11
11
  import { getChangedActors } from './diff-changes.js';
12
- import { getBranchOnlyChangedFiles, getChangedFiles, getCommits, hasMergeFromTarget } from './git.js';
13
- import { getPushData } from './github.js';
12
+ import {
13
+ getBranchOnlyChangedFiles,
14
+ getChangedFiles,
15
+ getCommits,
16
+ getCurrentBranch,
17
+ getReleaseChanges,
18
+ getRepoName,
19
+ hasMergeFromTarget,
20
+ resolveReleaseBaseCommit,
21
+ resolveRepoUrl,
22
+ } from './git.js';
14
23
  import { notifyToSlack } from './slack.js';
15
24
  import { reportTestResults } from './test-report.js';
16
25
  import type { Config } from './types.js';
17
- import { setCwd, spawnCommandInGhWorkspace } from './utils.js';
26
+ import { setCwd } from './utils.js';
18
27
  import { readConfigFile } from './utils/config/load-config.js';
19
28
 
20
29
  /**
@@ -42,6 +51,16 @@ export const buildOptions = <T>(y: Argv<T>) => {
42
51
  });
43
52
  };
44
53
 
54
+ /**
55
+ * Where to build the Actors from. Defaults to the `origin` remote, which is then checked against each
56
+ * Actor's default version. Passing it explicitly skips that check (see assertRepoUrlMatchesDefaultVersion).
57
+ */
58
+ const repoUrlOptions = <T>(y: Argv<T>) => {
59
+ return y.option('repo-url', {
60
+ type: 'string',
61
+ });
62
+ };
63
+
45
64
  /**
46
65
  * Actor-selection flags, applied to every command that reads the actor config so a caller can
47
66
  * narrow the set it operates on (e.g. two-stage releases: `--ignore X`, then `--actors X`).
@@ -150,18 +169,15 @@ await yargs()
150
169
  .command(
151
170
  'build',
152
171
  '',
153
- (args) => actorSelectionOptions(buildOptions(args)).option('dry-run', { type: 'boolean', default: false }),
172
+ (args) =>
173
+ repoUrlOptions(actorSelectionOptions(buildOptions(args))).option('dry-run', {
174
+ type: 'boolean',
175
+ default: false,
176
+ }),
154
177
  async (config) => {
155
178
  const actorsChanged = await resolveChangedActors(config, { isLatest: false });
156
- // https://github.com/apify-store/google-maps#:actors/lukaskrivka_google-maps-with-contact-details
157
- // git@github.com:apify-store/google-maps#:actors/lukaskrivka_google-maps-with-contact-details
158
- const repoUrl = spawnCommandInGhWorkspace(`git remote get-url origin`).replace(
159
- /^https:\/\/github\.com\//,
160
- 'git@github.com:',
161
- );
162
-
163
179
  const builds = await runBuilds({
164
- repoUrl,
180
+ ...resolveRepoUrl(config.repoUrl),
165
181
  actorConfigs: actorsChanged,
166
182
  branch: config.sourceBranch.replace('origin/', ''),
167
183
  dryRun: config.dryRun,
@@ -174,16 +190,25 @@ await yargs()
174
190
  'release',
175
191
  '',
176
192
  (args) =>
177
- actorSelectionOptions(args)
178
- .option('push-event-path', { type: 'string', demandOption: true })
193
+ repoUrlOptions(actorSelectionOptions(args))
194
+ // The last commit that is already released, everything after it up to HEAD gets released.
195
+ // Required, see the README section "Releasing Actors" for how to set it for each merge strategy.
196
+ .option('base-commit', { type: 'string', demandOption: true })
179
197
  .option('dry-run', { type: 'boolean', default: false })
180
198
  .option('report-slack-channel', { type: 'string' })
181
199
  .option('release-slack-channel', { type: 'string' })
182
200
  .option('use-docker-cache', { type: 'boolean', default: false }),
183
201
  async (args) => {
184
- const { branch, changedFiles, repoUrl, commits, changelog, repository, author } = await getPushData(
185
- args.pushEventPath,
186
- );
202
+ const baseSha = resolveReleaseBaseCommit(args.baseCommit);
203
+ const branch = getCurrentBranch();
204
+ const changes = getReleaseChanges(baseSha);
205
+ if (!changes) {
206
+ console.error(`HEAD is the base commit ${baseSha}, there is nothing new to release`);
207
+ return;
208
+ }
209
+ const { commits, changedFiles, changelog } = changes;
210
+ const { repoUrl, shouldVerifyRepoUrl } = resolveRepoUrl(args.repoUrl);
211
+
187
212
  const isLatest = true;
188
213
  const actorConfigs = await readConfigFile(args);
189
214
  const actorsChanged = getChangedActors({
@@ -196,6 +221,7 @@ await yargs()
196
221
  const builds = await runBuilds({
197
222
  isLatest,
198
223
  repoUrl,
224
+ shouldVerifyRepoUrl,
199
225
  actorConfigs: actorsChanged,
200
226
  branch,
201
227
  dryRun,
@@ -207,9 +233,10 @@ await yargs()
207
233
  changedFiles,
208
234
  commits,
209
235
  changelog,
210
- repository,
236
+ repository: getRepoName(repoUrl),
211
237
  dryRun,
212
- author,
238
+ // The newest commit, same as the pushed head commit
239
+ author: commits[commits.length - 1].author,
213
240
  reportSlackChannel,
214
241
  releaseSlackChannel,
215
242
  });
package/bin/slack.ts CHANGED
@@ -14,6 +14,9 @@ type NotifyToSlackOptions = {
14
14
  reportSlackChannel?: string;
15
15
  };
16
16
 
17
+ // Git authors come as "Name<email>", Slack only needs the name
18
+ const displayName = (author: string) => author.replace(/\s*<[^>]*>$/, '');
19
+
17
20
  export const notifyToSlack = async ({
18
21
  changedFiles,
19
22
  commits,
@@ -30,7 +33,7 @@ export const notifyToSlack = async ({
30
33
  console.warn('No new changelog entries found, did you forget to update it?');
31
34
  }
32
35
 
33
- let shortMessage = `*${repository}* – New release (by ${author}):\n\n`;
36
+ let shortMessage = `*${repository}* – New release (by ${displayName(author)}):\n\n`;
34
37
 
35
38
  // This one is just for broader public that only cares about public facing changes
36
39
  if (changelog && releaseSlackChannel) {
@@ -49,7 +52,7 @@ export const notifyToSlack = async ({
49
52
  const commitsMessage = `${commits
50
53
  .map(
51
54
  ({ author: commitAuthor, message }, index) =>
52
- `${index + 1}. Commit message: ${message}\n\tAuthor: ${commitAuthor}.`,
55
+ `${index + 1}. Commit message: ${message}\n\tAuthor: ${displayName(commitAuthor)}.`,
53
56
  )
54
57
  .join('\n')}`;
55
58
  const changedFilesMessage = `*Files changed*: ${changedFiles.map((file) => `\`${file}\``).join(', ')}`;
package/bin/types.ts CHANGED
@@ -14,79 +14,6 @@ export type Commit = {
14
14
  message: string;
15
15
  };
16
16
 
17
- // NOTE: The GitHub types are incomplete, feel free to add fields/complete (not sure how stable GitHub API is)
18
- export interface GitHubHeadCommit {
19
- added: string[];
20
- removed: string[];
21
- modified: string[];
22
- author: {
23
- name: string;
24
- };
25
- message: string;
26
- id: string;
27
- }
28
-
29
- export interface Repository {
30
- full_name: string;
31
- name: string;
32
- ssh_url: string;
33
- owner: {
34
- login: string;
35
- };
36
- }
37
-
38
- export type GitHubEvent = GitHubEventPullRequest | GitHubEventPush;
39
-
40
- export interface GitHubEventPullRequest {
41
- // Type is our own variable we inject to have discriminated union
42
- // The rest of the properties are raw from GitHub API
43
- type: 'pull_request';
44
- pull_request: {
45
- number: number;
46
- base: {
47
- ref: string;
48
- sha: string;
49
- };
50
- head: {
51
- ref: string;
52
- sha: string;
53
- };
54
- };
55
- repository: Repository;
56
- }
57
-
58
- export interface GitHubEventPush {
59
- type: 'push';
60
- head_commit: GitHubHeadCommit;
61
- repository: Repository;
62
- ref: string;
63
- commits: GithubCommit[];
64
- before: string;
65
- after: string;
66
- }
67
-
68
- export interface GithubCommit {
69
- id: string;
70
- tree_id: string;
71
- distinct: boolean;
72
- message: string;
73
- timestamp: string;
74
- url: string;
75
- author: {
76
- name: string;
77
- email: string;
78
- username: string;
79
- };
80
- committer: {
81
- name: string;
82
- email: string;
83
- username: string;
84
- };
85
- added: string[];
86
- removed: string[];
87
- modified: string[];
88
- }
89
-
90
17
  export interface BuildData {
91
18
  buildId: string;
92
19
  actorRawId: string;
@@ -1,6 +1,7 @@
1
1
  import z from 'zod';
2
2
 
3
3
  import { CONFIG_FILE_STRATEGY, type ResolvedActorConfig, type StrategyParser } from './structures/base.js';
4
+ import { GROUPED_PARSER } from './structures/grouped.js';
4
5
  import { LEGACY_PARSER } from './structures/legacy.js';
5
6
 
6
7
  const CONFIG_FILE_STRATEGIES: {
@@ -8,9 +9,10 @@ const CONFIG_FILE_STRATEGIES: {
8
9
  [key in CONFIG_FILE_STRATEGY]: StrategyParser & { mode: key };
9
10
  } = {
10
11
  [CONFIG_FILE_STRATEGY.LEGACY]: LEGACY_PARSER,
12
+ [CONFIG_FILE_STRATEGY.GROUPED]: GROUPED_PARSER,
11
13
  } as const;
12
14
 
13
- const ModeSelectionSchema = z.enum(CONFIG_FILE_STRATEGY).default(CONFIG_FILE_STRATEGY.LEGACY);
15
+ const ModeSelectionSchema = z.object({ mode: z.enum(CONFIG_FILE_STRATEGY).default(CONFIG_FILE_STRATEGY.LEGACY) });
14
16
 
15
17
  function selectStrategy(mode: unknown): StrategyParser {
16
18
  const parsed = ModeSelectionSchema.safeParse(mode);
@@ -18,7 +20,7 @@ function selectStrategy(mode: unknown): StrategyParser {
18
20
  throw new Error(z.prettifyError(parsed.error));
19
21
  }
20
22
 
21
- return CONFIG_FILE_STRATEGIES[parsed.data];
23
+ return CONFIG_FILE_STRATEGIES[parsed.data.mode];
22
24
  }
23
25
 
24
26
  // Strips a trailing slash so config-declared paths ("actors/shopify/" vs "actors/shopify") compare equal.
@@ -79,10 +81,9 @@ export const _privates = {
79
81
  };
80
82
 
81
83
  export function parseConfigFile(body: Record<string, unknown>): ResolvedActorConfig[] {
82
- const { mode, ...rest } = body;
83
- const strategy = selectStrategy(mode);
84
+ const strategy = selectStrategy(body);
84
85
 
85
- const resolved = strategy.parse(rest);
86
+ const resolved = strategy.parse(body);
86
87
  const validated = verifyConfiguration(resolved);
87
88
  return validated;
88
89
  }
@@ -11,15 +11,19 @@ export const ACTOR_FULL_NAME_REGEX = new RegExp(
11
11
  USERNAME.REGEX.flags + ACTOR_NAME.REGEX.flags,
12
12
  );
13
13
 
14
+ // All fields must exist, even if their value can be undefined.
15
+ // This makes typescript enforce all configs to have resolution for EVERY field.
16
+ // So adding an extra field here creates TS errors in every config file that doesn't have it.
14
17
  export interface ResolvedActorConfig {
15
18
  actorFullName: string;
16
19
  folder: string;
17
20
  tokenEnvVar: string;
18
- overrideActorContext?: string[];
21
+ overrideActorContext: string[] | undefined;
19
22
  }
20
23
 
21
24
  export enum CONFIG_FILE_STRATEGY {
22
25
  LEGACY = 'legacy',
26
+ GROUPED = 'grouped',
23
27
  }
24
28
 
25
29
  export type StrategyParser = {
@@ -0,0 +1,40 @@
1
+ import z from 'zod';
2
+
3
+ import { ACTOR_FULL_NAME_REGEX, CONFIG_FILE_STRATEGY, defineStrategy } from './base.js';
4
+
5
+ const schema = z.object({
6
+ groups: z
7
+ .record(
8
+ z.string(),
9
+ z.object({
10
+ actors: z
11
+ .array(
12
+ z.object({
13
+ folder: z.string(),
14
+ actorFullName: z.string().regex(ACTOR_FULL_NAME_REGEX),
15
+ // these allow overrides from stuff set at the group level
16
+ tokenEnvVar: z.string().optional(),
17
+ overrideActorContext: z.array(z.string()).optional(),
18
+ }),
19
+ )
20
+ .min(1),
21
+ tokenEnvVar: z.string(),
22
+ overrideActorContext: z.array(z.string()).optional(),
23
+ }),
24
+ )
25
+ .refine((data) => Object.keys(data).length > 0, 'Invalid input: At least one configuration group is required.'),
26
+ });
27
+
28
+ type GroupedConfig = z.infer<typeof schema>;
29
+
30
+ export const GROUPED_PARSER = defineStrategy(CONFIG_FILE_STRATEGY.GROUPED, schema, (body: GroupedConfig) => {
31
+ const entries = Object.entries(body.groups);
32
+ return entries.flatMap(([_folder, entry]) =>
33
+ entry.actors.map((actor) => ({
34
+ tokenEnvVar: entry.tokenEnvVar,
35
+ overrideActorContext: entry.overrideActorContext,
36
+ // last so actor can override stuff from the group
37
+ ...actor,
38
+ })),
39
+ );
40
+ });
@@ -17,4 +17,6 @@ const schema = z.object({
17
17
 
18
18
  type LegacyConfig = z.infer<typeof schema>;
19
19
 
20
- export const LEGACY_PARSER = defineStrategy(CONFIG_FILE_STRATEGY.LEGACY, schema, (body: LegacyConfig) => body.actors);
20
+ export const LEGACY_PARSER = defineStrategy(CONFIG_FILE_STRATEGY.LEGACY, schema, (body: LegacyConfig) =>
21
+ body.actors.map((x) => ({ overrideActorContext: undefined, ...x })),
22
+ );
package/bin/utils.ts CHANGED
@@ -84,11 +84,10 @@ export const getEnvVar = (varName: string, defaultValue?: string): string => {
84
84
  return value;
85
85
  };
86
86
 
87
+ // Commands expect to run from the repository root (config file and Actor folders are relative to it).
88
+ // That is the current directory by default, --workspace points elsewhere, e.g. for local development.
87
89
  export const setCwd = ({ workspace }: { workspace: string | undefined }) => {
88
90
  if (workspace) {
89
91
  process.chdir(workspace);
90
- return;
91
92
  }
92
- const ghWorkspace = getEnvVar('GITHUB_WORKSPACE', process.cwd());
93
- process.chdir(ghWorkspace);
94
93
  };
@@ -1 +1 @@
1
- {"version":3,"file":"build-from-local.js","sourceRoot":"","sources":["../../bin/build-from-local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,MAAM,MAAM,SAAS,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACjG,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGpD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjG,yGAAyG;AACzG,yGAAyG;AACzG,yGAAyG;AACzG,yDAAyD;AACzD,MAAM,kBAAkB,GAAG,CAAC,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACtF,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAW,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEjH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,SAAiB,EAAE,QAAgB,EAAyB,EAAE;IACnG,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC/B,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,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AC,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC1D,KAAK,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,IAAI,YAAY,EAAE,CAAC;YACnD,OAAO,CAAC,KAAK,CAAC,KAAK,aAAa,KAAK,MAAM,GAAG,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,eAAe,CAAC,aAAa,EAAE,2BAA2B,CAAC,CAAC,CAAC;IAChH,CAAC;IAED,OAAO,qBAAqB,CAAC,YAAY,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE;QACtF,6FAA6F;QAC7F,MAAM,GAAG,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,KAAK,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,MAAM,kBAAkB,CAAC,WAAW,CAAC,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;YACtG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/B,CAAC;QACD,MAAM,YAAY,GAAkC;YAChD,aAAa,EAAE,2BAA2B;YAC1C,UAAU,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,2BAA2B,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC;YACtF,UAAU,EAAE,eAAe,CAAC,OAAO;SACtC,CAAC;QACF,OAAO,OAAO,CAAC,qBAAqB,CAAC,2BAA2B,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;IAC3F,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
@@ -1,18 +1,38 @@
1
- import type { ActorVersion, Build } from 'apify-client';
1
+ import type * as ApifyClientTypes from 'apify-client';
2
2
  import type { ActorConfig, BuildData } from './types.js';
3
3
  export declare const LOCAL_SOURCE_VERSION_NUMBER = "0.98";
4
+ /**
5
+ * Finds the Actor's default version: the one whose build the default build tag points to.
6
+ * Usually tagged 'latest' but not necessarily (can be e.g. 'version-0').
7
+ */
8
+ export declare const resolveDefaultVersion: (actorFullName: string, actorInfo: ApifyClientTypes.Actor) => {
9
+ defaultBuildNumber: string;
10
+ defaultVersionNumber: string;
11
+ defaultBuildTag: string;
12
+ defaultVersion: ApifyClientTypes.ActorVersion | undefined;
13
+ };
14
+ /**
15
+ * Guards against building an Actor from a different repository than it is published from, e.g. when the
16
+ * local `origin` remote is a fork or a mirror. Every build overwrites the version's Git URL, so building
17
+ * from the wrong remote would silently repoint the Actor. The default version is the source of truth
18
+ * since it is what users run. Skipped when the repo URL is passed explicitly, which is how you move an
19
+ * Actor to a new repository on purpose.
20
+ */
21
+ export declare const assertRepoUrlMatchesDefaultVersion: (actorFullName: string, defaultVersion: ApifyClientTypes.ActorVersion | undefined, repoUrl: string) => void;
4
22
  export declare class ApifyBuilder {
5
23
  private readonly apifyClient;
6
24
  private readonly actorFullName;
7
25
  private constructor();
26
+ getActorInfo: () => Promise<ApifyClientTypes.Actor>;
8
27
  getDefaultVersionAndTag: () => Promise<{
9
28
  defaultBuildNumber: string;
10
29
  defaultVersionNumber: string;
11
30
  defaultBuildTag: string;
31
+ defaultVersion: ApifyClientTypes.ActorVersion | undefined;
12
32
  }>;
13
33
  uploadSourceZip: (versionNumber: string, zip: Buffer) => Promise<string>;
14
- createVersionAndBuild: (versionNumber: string, actorVersion: ActorVersion, useCache: boolean) => Promise<BuildData>;
15
- waitForBuildToFinish: (buildId: string) => Promise<Build>;
34
+ createVersionAndBuild: (versionNumber: string, actorVersion: ApifyClientTypes.ActorVersion, useCache: boolean, actorInfo?: ApifyClientTypes.Actor) => Promise<BuildData>;
35
+ waitForBuildToFinish: (buildId: string) => Promise<ApifyClientTypes.Build>;
16
36
  static fromActorConfig: (actorConfig: ActorConfig) => ApifyBuilder;
17
37
  /**
18
38
  * Deletes build of all versions. Apify API doesn't allow to delete default build and we explicitly skip it
@@ -27,11 +47,12 @@ type RunBuildsOptions = {
27
47
  actorConfigs: ActorConfig[];
28
48
  isLatest?: boolean;
29
49
  repoUrl: string;
50
+ shouldVerifyRepoUrl: boolean;
30
51
  branch: string;
31
52
  dryRun: boolean;
32
53
  useDockerCache: boolean;
33
54
  };
34
- export declare const runBuilds: ({ repoUrl, branch, actorConfigs, isLatest, dryRun, useDockerCache, }: RunBuildsOptions) => Promise<BuildData[]>;
55
+ export declare const runBuilds: ({ repoUrl, shouldVerifyRepoUrl, branch, actorConfigs, isLatest, dryRun, useDockerCache, }: RunBuildsOptions) => Promise<BuildData[]>;
35
56
  export declare const deleteOldBuilds: (actorConfigs: ActorConfig[]) => Promise<void>;
36
57
  export {};
37
58
  //# sourceMappingURL=build.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../bin/build.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAGxD,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAWzD,eAAO,MAAM,2BAA2B,SAAS,CAAC;AAGlD,qBAAa,YAAY;IAEjB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAFlC,OAAO;IAMP,uBAAuB,QAAa,OAAO,CAAC;QACxC,kBAAkB,EAAE,MAAM,CAAC;QAC3B,oBAAoB,EAAE,MAAM,CAAC;QAC7B,eAAe,EAAE,MAAM,CAAC;KAC3B,CAAC,CAgCA;IAIF,eAAe,GAAU,eAAe,MAAM,EAAE,KAAK,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC,CAY3E;IAEF,qBAAqB,GACjB,eAAe,MAAM,EACrB,cAAc,YAAY,EAC1B,UAAU,OAAO,KAClB,OAAO,CAAC,SAAS,CAAC,CA0BnB;IAEF,oBAAoB,GAAU,SAAS,MAAM,KAAG,OAAO,CAAC,KAAK,CAAC,CAmB5D;IAEF,MAAM,CAAC,eAAe,G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