apify-test-tools 0.9.1-beta.3 → 0.9.1-beta.5
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.
- package/.prettierignore +3 -0
- package/.vscode/settings.json +2 -1
- package/CHANGELOG.md +4 -0
- package/bin/main.ts +2 -1
- package/bin/types.ts +0 -11
- package/bin/utils/config/load-config.ts +251 -0
- package/bin/utils/json-file.ts +55 -0
- package/bin/utils.ts +0 -138
- package/dist/bin/main.d.ts.map +1 -1
- package/dist/bin/main.js +2 -1
- package/dist/bin/main.js.map +1 -1
- package/dist/bin/types.d.ts +0 -9
- package/dist/bin/types.d.ts.map +1 -1
- package/dist/bin/utils/config/load-config.d.ts +44 -0
- package/dist/bin/utils/config/load-config.d.ts.map +1 -0
- package/dist/bin/utils/config/load-config.js +177 -0
- package/dist/bin/utils/config/load-config.js.map +1 -0
- package/dist/bin/utils/json-file.d.ts +20 -0
- package/dist/bin/utils/json-file.d.ts.map +1 -0
- package/dist/bin/utils/json-file.js +42 -0
- package/dist/bin/utils/json-file.js.map +1 -0
- package/dist/bin/utils.d.ts +0 -6
- package/dist/bin/utils.d.ts.map +1 -1
- package/dist/bin/utils.js +0 -98
- package/dist/bin/utils.js.map +1 -1
- package/dist/lib/consts.d.ts +1 -0
- package/dist/lib/consts.d.ts.map +1 -1
- package/dist/lib/consts.js +3 -0
- package/dist/lib/consts.js.map +1 -1
- package/dist/lib/lib.d.ts +4 -0
- package/dist/lib/lib.d.ts.map +1 -1
- package/dist/lib/lib.js +12 -16
- package/dist/lib/lib.js.map +1 -1
- package/dist/lib/types.d.ts +11 -3
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/test/unit/bin/utils/actor-config.test.d.ts +2 -0
- package/dist/test/unit/bin/utils/actor-config.test.d.ts.map +1 -0
- package/dist/test/unit/bin/{utils.test.js → utils/actor-config.test.js} +126 -51
- package/dist/test/unit/bin/utils/actor-config.test.js.map +1 -0
- package/dist/test/unit/bin/utils/files.test.d.ts +2 -0
- package/dist/test/unit/bin/utils/files.test.d.ts.map +1 -0
- package/dist/test/unit/bin/utils/files.test.js +117 -0
- package/dist/test/unit/bin/utils/files.test.js.map +1 -0
- package/dist/test/unit/lib.test.d.ts +2 -0
- package/dist/test/unit/lib.test.d.ts.map +1 -0
- package/dist/test/unit/lib.test.js +37 -0
- package/dist/test/unit/lib.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/consts.ts +4 -0
- package/lib/lib.ts +20 -18
- package/lib/types.ts +11 -3
- package/package.json +3 -2
- package/test/fixtures/bin/utils/files/array.json +1 -0
- package/test/fixtures/bin/utils/files/comments.jsonc +4 -0
- package/test/fixtures/bin/utils/files/directory.json/.gitkeep +0 -0
- package/test/fixtures/bin/utils/files/empty-object.json +1 -0
- package/test/fixtures/bin/utils/files/empty.json +0 -0
- package/test/fixtures/bin/utils/files/malformed.json +1 -0
- package/test/fixtures/bin/utils/files/nested.json +6 -0
- package/test/fixtures/bin/utils/files/no-json-extension.actorrc +1 -0
- package/test/fixtures/bin/utils/files/null.json +1 -0
- package/test/fixtures/bin/utils/files/number.json +1 -0
- package/test/fixtures/bin/utils/files/unreadable.json +1 -0
- package/test/tsconfig.json +4 -2
- package/test/unit/bin/{utils.test.ts → utils/actor-config.test.ts} +152 -52
- package/test/unit/bin/utils/files.test.ts +158 -0
- package/test/unit/lib.test.ts +53 -0
- package/dist/test/unit/bin/utils.test.d.ts +0 -2
- package/dist/test/unit/bin/utils.test.d.ts.map +0 -1
- package/dist/test/unit/bin/utils.test.js.map +0 -1
package/.prettierignore
CHANGED
package/.vscode/settings.json
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
<!-- git-cliff-unreleased-start -->
|
|
6
6
|
## 0.9.1 - **not yet released**
|
|
7
7
|
|
|
8
|
+
### 🐛 Bug Fixes
|
|
9
|
+
|
|
10
|
+
- Apply default actor timeout to runs ([#134](https://github.com/apify/apify-test-tools/pull/134)) ([82f5f7d](https://github.com/apify/apify-test-tools/commit/82f5f7d4de990db7ad8edf940c19ffd6b20bad13)) by [@Patai5](https://github.com/Patai5)
|
|
11
|
+
|
|
8
12
|
|
|
9
13
|
<!-- git-cliff-unreleased-end -->
|
|
10
14
|
## [0.9.0](https://github.com/apify/apify-test-tools/releases/tag/v0.9.0) (2026-08-11)
|
package/bin/main.ts
CHANGED
|
@@ -14,7 +14,8 @@ import { getPushData } from './github.js';
|
|
|
14
14
|
import { notifyToSlack } from './slack.js';
|
|
15
15
|
import { reportTestResults } from './test-report.js';
|
|
16
16
|
import type { Config } from './types.js';
|
|
17
|
-
import {
|
|
17
|
+
import { setCwd, spawnCommandInGhWorkspace } from './utils.js';
|
|
18
|
+
import { readConfigFile } from './utils/config/load-config.js';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Middlewares to be run before every command execution
|
package/bin/types.ts
CHANGED
|
@@ -87,17 +87,6 @@ export interface GithubCommit {
|
|
|
87
87
|
modified: string[];
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
export interface ActorConfigFileEntry {
|
|
91
|
-
folder: string;
|
|
92
|
-
actorFullName: string;
|
|
93
|
-
tokenEnvVar: string;
|
|
94
|
-
overrideActorContext?: string[];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export interface ActorConfigFile {
|
|
98
|
-
actors: ActorConfigFileEntry[];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
90
|
export interface BuildData {
|
|
102
91
|
buildId: string;
|
|
103
92
|
actorRawId: string;
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
import { selectActors } from '../../actor-filtering.js';
|
|
6
|
+
import { isPathWithinScope } from '../../path-utils.js';
|
|
7
|
+
import type { ActorConfig } from '../../types.js';
|
|
8
|
+
import { safeReadJsonObjectFile } from '../json-file.js';
|
|
9
|
+
|
|
10
|
+
export const CONFIG_FILE_NAME = 'apify-test-tools.config.json';
|
|
11
|
+
|
|
12
|
+
// Reading the config happens in four stages, each one swappable on its own:
|
|
13
|
+
//
|
|
14
|
+
// 1. file -> plain object (safeReadJsonObjectFile)
|
|
15
|
+
// 2. plain object -> ActorConfigFile (parseConfigFile — the schema, swap point for new flavours)
|
|
16
|
+
// 3. ActorConfigFile -> ResolvedActorConfig[] (resolveRawConfig — one normalized shape for everyone)
|
|
17
|
+
// 4. ResolvedActorConfig -> ActorConfig (loadActorConfig — merges in .actor/actor.json)
|
|
18
|
+
//
|
|
19
|
+
// Stages 1-3 are the "what did the user write" half and stage 4 the "what does the repo look like"
|
|
20
|
+
// half. A differently shaped config file only has to reach stage 3's output to work with the rest
|
|
21
|
+
// of the tool.
|
|
22
|
+
|
|
23
|
+
// #region schema (soon to be moved)
|
|
24
|
+
|
|
25
|
+
const ACTOR_ENTRY_SCHEMA = z.object({
|
|
26
|
+
folder: z.string(),
|
|
27
|
+
// "owner/name", with neither half empty — deliberately permissive about what characters those
|
|
28
|
+
// halves may contain, the platform is the authority on that.
|
|
29
|
+
actorFullName: z.string().regex(/^[^/]+\/[^/]+$/),
|
|
30
|
+
tokenEnvVar: z.string(),
|
|
31
|
+
overrideActorContext: z.array(z.string()).optional(),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const CONFIG_FILE_SCHEMA = z.object({
|
|
35
|
+
actors: z.array(ACTOR_ENTRY_SCHEMA),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export type ActorConfigFile = z.infer<typeof CONFIG_FILE_SCHEMA>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The single shape stage 4 understands: an actor entry whose paths have been normalized, with no
|
|
42
|
+
* trace left of which config flavour produced it. Whatever replaces or extends
|
|
43
|
+
* {@link parseConfigFile} and {@link resolveRawConfig} only has to produce this.
|
|
44
|
+
*/
|
|
45
|
+
export interface ResolvedActorConfig {
|
|
46
|
+
actorFullName: string;
|
|
47
|
+
folder: string;
|
|
48
|
+
tokenEnvVar: string;
|
|
49
|
+
overrideActorContext?: string[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// #endregion
|
|
53
|
+
|
|
54
|
+
// #region utils
|
|
55
|
+
|
|
56
|
+
// Strips a trailing slash so config-declared paths ("actors/shopify/" vs "actors/shopify") compare equal.
|
|
57
|
+
const stripTrailingSlash = (pathValue: string): string => pathValue.replace(/\/+$/, '');
|
|
58
|
+
|
|
59
|
+
const findOverlappingContextPaths = (contextPaths: string[]): [string, string] | undefined => {
|
|
60
|
+
for (let i = 0; i < contextPaths.length; i++) {
|
|
61
|
+
for (let j = i + 1; j < contextPaths.length; j++) {
|
|
62
|
+
if (
|
|
63
|
+
isPathWithinScope(contextPaths[i], contextPaths[j]) ||
|
|
64
|
+
isPathWithinScope(contextPaths[j], contextPaths[i])
|
|
65
|
+
) {
|
|
66
|
+
return [contextPaths[i], contextPaths[j]];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
type ConfigParsingIssue = z.ZodError<ActorConfigFile>['issues'][number];
|
|
74
|
+
|
|
75
|
+
// Restates a schema violation in the wording this config file has always used, so error output
|
|
76
|
+
// stays recognizable now that the hand-rolled checks are gone.
|
|
77
|
+
const describeIssue = (issue: ConfigParsingIssue, rawActors: unknown[]): string => {
|
|
78
|
+
const [, index, field] = issue.path;
|
|
79
|
+
|
|
80
|
+
if (typeof index !== 'number') {
|
|
81
|
+
return `Config file "${CONFIG_FILE_NAME}" must have an "actors" array at the top level.`;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const folder = (rawActors[index] as { folder?: unknown } | undefined)?.folder;
|
|
85
|
+
|
|
86
|
+
switch (field) {
|
|
87
|
+
case 'folder':
|
|
88
|
+
return (
|
|
89
|
+
`Invalid "folder" for actor entry at index ${index} in "${CONFIG_FILE_NAME}". ` +
|
|
90
|
+
`Must be a string (use "." for a single-actor repo).`
|
|
91
|
+
);
|
|
92
|
+
case 'actorFullName':
|
|
93
|
+
return (
|
|
94
|
+
`Invalid "actorFullName" for folder "${folder}" in "${CONFIG_FILE_NAME}". ` +
|
|
95
|
+
`Must be in "owner/name" format (e.g. "apify/web-scraper").`
|
|
96
|
+
);
|
|
97
|
+
case 'tokenEnvVar':
|
|
98
|
+
return `Invalid "tokenEnvVar" for folder "${folder}" in "${CONFIG_FILE_NAME}". Must be a string.`;
|
|
99
|
+
case 'overrideActorContext':
|
|
100
|
+
return (
|
|
101
|
+
`Invalid "overrideActorContext" for folder "${folder}" in "${CONFIG_FILE_NAME}". ` +
|
|
102
|
+
`Must be an array of strings.`
|
|
103
|
+
);
|
|
104
|
+
default:
|
|
105
|
+
return `Invalid actor entry at index ${index} in "${CONFIG_FILE_NAME}": ${issue.message}`;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// #endregion
|
|
110
|
+
|
|
111
|
+
// #region stages
|
|
112
|
+
|
|
113
|
+
/** Stage 1 — the config file as a plain object, or a failure phrased for whoever wrote it. */
|
|
114
|
+
const readConfigFileContents = async (): Promise<Record<string, unknown>> => {
|
|
115
|
+
const file = safeReadJsonObjectFile(CONFIG_FILE_NAME);
|
|
116
|
+
if (file.success) {
|
|
117
|
+
return file.contents;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
switch (file.reason) {
|
|
121
|
+
case 'invalid-json':
|
|
122
|
+
// TODO: support .jsonc
|
|
123
|
+
throw new Error(`Config file "${CONFIG_FILE_NAME}" contains invalid JSON and cannot be parsed.`);
|
|
124
|
+
// Valid JSON that isn't an object can't carry an "actors" array either.
|
|
125
|
+
case 'not-an-object':
|
|
126
|
+
throw new Error(`Config file "${CONFIG_FILE_NAME}" must have an "actors" array at the top level.`);
|
|
127
|
+
default:
|
|
128
|
+
throw new Error(
|
|
129
|
+
`Config file "${CONFIG_FILE_NAME}" not found in the current directory. ` +
|
|
130
|
+
`Please create one with the required actor entries.`,
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Stage 2 — validates the file's shape. Every problem is reported at once rather than only the
|
|
137
|
+
* first one to fail.
|
|
138
|
+
*/
|
|
139
|
+
export const parseConfigFile = (contents: Record<string, unknown>): ActorConfigFile => {
|
|
140
|
+
const parsed = CONFIG_FILE_SCHEMA.safeParse(contents);
|
|
141
|
+
if (parsed.success) {
|
|
142
|
+
return parsed.data;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const rawActors = Array.isArray(contents.actors) ? contents.actors : [];
|
|
146
|
+
const messages = new Set(parsed.error.issues.map((issue) => describeIssue(issue, rawActors)));
|
|
147
|
+
throw new Error([...messages].join('\n'));
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Stage 3 — normalizes the paths the user wrote and rejects entries that collide once normalized.
|
|
152
|
+
* The repo root is "" from here on, however it was spelled in the file.
|
|
153
|
+
*/
|
|
154
|
+
export const resolveRawConfig = (config: ActorConfigFile): ResolvedActorConfig[] => {
|
|
155
|
+
const seenFolders = new Set<string>();
|
|
156
|
+
|
|
157
|
+
return config.actors.map((entry) => {
|
|
158
|
+
const folder = entry.folder === '.' ? '' : stripTrailingSlash(entry.folder);
|
|
159
|
+
|
|
160
|
+
if (seenFolders.has(folder)) {
|
|
161
|
+
throw new Error(
|
|
162
|
+
`Duplicate folder "${entry.folder}" in "${CONFIG_FILE_NAME}". Each actor must have a unique folder.`,
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
seenFolders.add(folder);
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
actorFullName: entry.actorFullName,
|
|
169
|
+
folder,
|
|
170
|
+
tokenEnvVar: entry.tokenEnvVar,
|
|
171
|
+
overrideActorContext: entry.overrideActorContext?.map(stripTrailingSlash),
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// The repo root is spelled "" internally but "." in a config file, so report it the way a reader
|
|
177
|
+
// would have written it.
|
|
178
|
+
const displayFolder = (folder: string): string => folder || '.';
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Stage 4 — resolves one normalized entry against the repo, reading the actor's `.actor/actor.json`
|
|
182
|
+
* for its `dockerContextDir` and deciding which paths count as the actor's context.
|
|
183
|
+
*/
|
|
184
|
+
export const loadActorConfig = (entry: ResolvedActorConfig): ActorConfig => {
|
|
185
|
+
const { folder } = entry;
|
|
186
|
+
const actorJsonPath = folder ? `${folder}/.actor/actor.json` : '.actor/actor.json';
|
|
187
|
+
|
|
188
|
+
const actorJson = safeReadJsonObjectFile(actorJsonPath);
|
|
189
|
+
if (!actorJson.success) {
|
|
190
|
+
throw new Error(
|
|
191
|
+
`Cannot read "${actorJsonPath}". Every actor entry in "${CONFIG_FILE_NAME}" ` +
|
|
192
|
+
`must have a corresponding .actor/actor.json file.`,
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const actorDotDir = folder ? `${folder}/.actor` : '.actor';
|
|
197
|
+
const rawDockerContextDir =
|
|
198
|
+
typeof actorJson.contents.dockerContextDir === 'string' ? actorJson.contents.dockerContextDir : '..';
|
|
199
|
+
const resolved = path.resolve(process.cwd(), actorDotDir, rawDockerContextDir);
|
|
200
|
+
const dockerContextDir = path.relative(process.cwd(), resolved);
|
|
201
|
+
|
|
202
|
+
if (dockerContextDir.startsWith('..')) {
|
|
203
|
+
throw new Error(
|
|
204
|
+
`"dockerContextDir" for folder "${displayFolder(folder)}" resolves outside the repository root. ` +
|
|
205
|
+
`Resolved path: "${dockerContextDir}".`,
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const normalizedDockerContextDir = dockerContextDir === '.' ? '' : dockerContextDir;
|
|
210
|
+
const contextPaths = [...(entry.overrideActorContext ?? [normalizedDockerContextDir])];
|
|
211
|
+
|
|
212
|
+
// The actor's own folder is always part of its context. When an explicit "overrideActorContext"
|
|
213
|
+
// doesn't already cover it, add it automatically instead of failing the workflow.
|
|
214
|
+
if (!contextPaths.some((contextPath) => isPathWithinScope(folder, contextPath))) {
|
|
215
|
+
contextPaths.push(folder);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const overlap = findOverlappingContextPaths(contextPaths);
|
|
219
|
+
if (overlap) {
|
|
220
|
+
throw new Error(
|
|
221
|
+
`Invalid context paths for folder "${displayFolder(folder)}" in "${CONFIG_FILE_NAME}": ` +
|
|
222
|
+
`"${overlap[0]}" and "${overlap[1]}" overlap. Context paths must not be prefixes of one another.`,
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
actorFullName: entry.actorFullName,
|
|
228
|
+
folder,
|
|
229
|
+
tokenEnvVar: entry.tokenEnvVar,
|
|
230
|
+
dockerContextDir: normalizedDockerContextDir,
|
|
231
|
+
contextPaths,
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// #endregion
|
|
236
|
+
|
|
237
|
+
export const readConfigFile = async (selection: { actors: string[]; ignore: string[] }): Promise<ActorConfig[]> => {
|
|
238
|
+
const rawConfig = await readConfigFileContents();
|
|
239
|
+
|
|
240
|
+
// replace this when enabling different file structures
|
|
241
|
+
// some kind of strategy pattern seems appropriate here
|
|
242
|
+
const resolvedConfigs = resolveRawConfig(parseConfigFile(rawConfig));
|
|
243
|
+
|
|
244
|
+
const actorConfigs: ActorConfig[] = [];
|
|
245
|
+
for (const resolved of resolvedConfigs) {
|
|
246
|
+
// Sequential on purpose: the first actor with a problem should be the one reported.
|
|
247
|
+
actorConfigs.push(loadActorConfig(resolved));
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return selectActors(selection, actorConfigs);
|
|
251
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { readFileSync, statSync } from 'node:fs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Why a JSON object could not be produced from a path. Callers that already have their own
|
|
5
|
+
* user-facing wording (e.g. the config file reader) switch on this instead of re-deriving the
|
|
6
|
+
* cause from an error message.
|
|
7
|
+
*/
|
|
8
|
+
export type JsonObjectReadFailureReason = 'not-a-file' | 'unreadable' | 'invalid-json' | 'not-an-object';
|
|
9
|
+
|
|
10
|
+
export type JsonObjectReadResult =
|
|
11
|
+
| { success: true; contents: Record<string, unknown> }
|
|
12
|
+
| { success: false; reason: JsonObjectReadFailureReason; failure: Error };
|
|
13
|
+
|
|
14
|
+
const failed = (reason: JsonObjectReadFailureReason, message: string): JsonObjectReadResult => ({
|
|
15
|
+
success: false,
|
|
16
|
+
reason,
|
|
17
|
+
failure: new Error(message),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Reads a file and parses it as a JSON object, reporting every way that can go wrong as a value
|
|
22
|
+
* instead of a thrown error — the caller decides which failures are fatal and how to word them.
|
|
23
|
+
*/
|
|
24
|
+
export function safeReadJsonObjectFile(path: string): JsonObjectReadResult {
|
|
25
|
+
let file: string;
|
|
26
|
+
try {
|
|
27
|
+
// `stat`, not `lstat`: a symlink must resolve to its target, matching what `readFile` does below.
|
|
28
|
+
const stats = statSync(path);
|
|
29
|
+
if (!stats.isFile()) {
|
|
30
|
+
return failed('not-a-file', `Expected ${path} to be a file`);
|
|
31
|
+
}
|
|
32
|
+
file = readFileSync(path, 'utf8');
|
|
33
|
+
} catch {
|
|
34
|
+
return failed('unreadable', `Expected ${path} to exist or be readable`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let parsed: unknown;
|
|
38
|
+
try {
|
|
39
|
+
parsed = JSON.parse(file);
|
|
40
|
+
} catch (err) {
|
|
41
|
+
return failed('invalid-json', `Failed to parse ${path}: ${err}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (parsed === null) {
|
|
45
|
+
return failed('not-an-object', `Expected ${path} to be a JSON object, not null`);
|
|
46
|
+
}
|
|
47
|
+
if (Array.isArray(parsed)) {
|
|
48
|
+
return failed('not-an-object', `Expected ${path} to be a JSON object, not an array`);
|
|
49
|
+
}
|
|
50
|
+
if (typeof parsed !== 'object') {
|
|
51
|
+
return failed('not-an-object', `Expected ${path} to be a JSON object`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return { success: true, contents: parsed as Record<string, unknown> };
|
|
55
|
+
}
|
package/bin/utils.ts
CHANGED
|
@@ -6,10 +6,6 @@ import type { ActorVersionSourceFile } from 'apify-client';
|
|
|
6
6
|
|
|
7
7
|
import { SOURCE_FILE_FORMATS } from '@apify/consts';
|
|
8
8
|
|
|
9
|
-
import { selectActors } from './actor-filtering.js';
|
|
10
|
-
import { isPathWithinScope } from './path-utils.js';
|
|
11
|
-
import type { ActorConfig, ActorConfigFile } from './types.js';
|
|
12
|
-
|
|
13
9
|
// Returns true when `childPath` is not inside `parentPath`.
|
|
14
10
|
// Used to detect monorepo actors whose dockerContextDir escapes the actor directory.
|
|
15
11
|
export const isOutsideDir = (childPath: string, parentPath: string): boolean =>
|
|
@@ -95,140 +91,6 @@ export const getEnvVar = (varName: string, defaultValue?: string): string => {
|
|
|
95
91
|
return value;
|
|
96
92
|
};
|
|
97
93
|
|
|
98
|
-
export const CONFIG_FILE_NAME = 'apify-test-tools.config.json';
|
|
99
|
-
|
|
100
|
-
// Strips a trailing slash so config-declared paths ("actors/shopify/" vs "actors/shopify") compare equal.
|
|
101
|
-
const stripTrailingSlash = (pathValue: string): string => pathValue.replace(/\/+$/, '');
|
|
102
|
-
|
|
103
|
-
const findOverlappingContextPaths = (contextPaths: string[]): [string, string] | undefined => {
|
|
104
|
-
for (let i = 0; i < contextPaths.length; i++) {
|
|
105
|
-
for (let j = i + 1; j < contextPaths.length; j++) {
|
|
106
|
-
if (
|
|
107
|
-
isPathWithinScope(contextPaths[i], contextPaths[j]) ||
|
|
108
|
-
isPathWithinScope(contextPaths[j], contextPaths[i])
|
|
109
|
-
) {
|
|
110
|
-
return [contextPaths[i], contextPaths[j]];
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return undefined;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
export const readConfigFile = async (selection: { actors: string[]; ignore: string[] }): Promise<ActorConfig[]> => {
|
|
118
|
-
let raw: string;
|
|
119
|
-
try {
|
|
120
|
-
raw = await fs.readFile(CONFIG_FILE_NAME, 'utf-8');
|
|
121
|
-
} catch {
|
|
122
|
-
throw new Error(
|
|
123
|
-
`Config file "${CONFIG_FILE_NAME}" not found in the current directory. ` +
|
|
124
|
-
`Please create one with the required actor entries.`,
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
let config: ActorConfigFile;
|
|
129
|
-
try {
|
|
130
|
-
config = JSON.parse(raw);
|
|
131
|
-
} catch {
|
|
132
|
-
throw new Error(`Config file "${CONFIG_FILE_NAME}" contains invalid JSON.`);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (!Array.isArray(config.actors)) {
|
|
136
|
-
throw new Error(`Config file "${CONFIG_FILE_NAME}" must have an "actors" array at the top level.`);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const seenFolders = new Set<string>();
|
|
140
|
-
const actorConfigs: ActorConfig[] = [];
|
|
141
|
-
|
|
142
|
-
for (const [index, entry] of config.actors.entries()) {
|
|
143
|
-
if (typeof entry.folder !== 'string') {
|
|
144
|
-
throw new Error(
|
|
145
|
-
`Invalid "folder" for actor entry at index ${index} in "${CONFIG_FILE_NAME}". ` +
|
|
146
|
-
`Must be a string (use "." for a single-actor repo).`,
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const folder = entry.folder === '.' ? '' : stripTrailingSlash(entry.folder);
|
|
151
|
-
|
|
152
|
-
if (seenFolders.has(folder)) {
|
|
153
|
-
throw new Error(
|
|
154
|
-
`Duplicate folder "${entry.folder}" in "${CONFIG_FILE_NAME}". Each actor must have a unique folder.`,
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
seenFolders.add(folder);
|
|
158
|
-
|
|
159
|
-
const nameParts = entry.actorFullName?.split('/');
|
|
160
|
-
if (!nameParts || nameParts.length !== 2 || !nameParts[0] || !nameParts[1]) {
|
|
161
|
-
throw new Error(
|
|
162
|
-
`Invalid "actorFullName" for folder "${entry.folder}" in "${CONFIG_FILE_NAME}". ` +
|
|
163
|
-
`Must be in "owner/name" format (e.g. "apify/web-scraper").`,
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (entry.overrideActorContext !== undefined) {
|
|
168
|
-
if (
|
|
169
|
-
!Array.isArray(entry.overrideActorContext) ||
|
|
170
|
-
!entry.overrideActorContext.every((p) => typeof p === 'string')
|
|
171
|
-
) {
|
|
172
|
-
throw new Error(
|
|
173
|
-
`Invalid "overrideActorContext" for folder "${entry.folder}" in "${CONFIG_FILE_NAME}". ` +
|
|
174
|
-
`Must be an array of strings.`,
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const actorJsonPath = folder ? `${folder}/.actor/actor.json` : '.actor/actor.json';
|
|
180
|
-
|
|
181
|
-
let actorJson: { dockerContextDir?: string };
|
|
182
|
-
try {
|
|
183
|
-
actorJson = JSON.parse(await fs.readFile(actorJsonPath, 'utf-8'));
|
|
184
|
-
} catch {
|
|
185
|
-
throw new Error(
|
|
186
|
-
`Cannot read "${actorJsonPath}". Every actor entry in "${CONFIG_FILE_NAME}" ` +
|
|
187
|
-
`must have a corresponding .actor/actor.json file.`,
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const actorDotDir = folder ? `${folder}/.actor` : '.actor';
|
|
192
|
-
const rawDockerContextDir = actorJson.dockerContextDir ?? '..';
|
|
193
|
-
const resolved = path.resolve(process.cwd(), actorDotDir, rawDockerContextDir);
|
|
194
|
-
const dockerContextDir = path.relative(process.cwd(), resolved);
|
|
195
|
-
|
|
196
|
-
if (dockerContextDir.startsWith('..')) {
|
|
197
|
-
throw new Error(
|
|
198
|
-
`"dockerContextDir" for folder "${entry.folder}" resolves outside the repository root. ` +
|
|
199
|
-
`Resolved path: "${dockerContextDir}".`,
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
const normalizedDockerContextDir = dockerContextDir === '.' ? '' : dockerContextDir;
|
|
204
|
-
const contextPaths = (entry.overrideActorContext ?? [normalizedDockerContextDir]).map(stripTrailingSlash);
|
|
205
|
-
|
|
206
|
-
// The actor's own folder is always part of its context. When an explicit "overrideActorContext"
|
|
207
|
-
// doesn't already cover it, add it automatically instead of failing the workflow.
|
|
208
|
-
if (!contextPaths.some((contextPath) => isPathWithinScope(folder, contextPath))) {
|
|
209
|
-
contextPaths.push(folder);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const overlap = findOverlappingContextPaths(contextPaths);
|
|
213
|
-
if (overlap) {
|
|
214
|
-
throw new Error(
|
|
215
|
-
`Invalid context paths for folder "${entry.folder}" in "${CONFIG_FILE_NAME}": ` +
|
|
216
|
-
`"${overlap[0]}" and "${overlap[1]}" overlap. Context paths must not be prefixes of one another.`,
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
actorConfigs.push({
|
|
221
|
-
actorFullName: entry.actorFullName,
|
|
222
|
-
folder,
|
|
223
|
-
tokenEnvVar: entry.tokenEnvVar,
|
|
224
|
-
dockerContextDir: normalizedDockerContextDir,
|
|
225
|
-
contextPaths,
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return selectActors(selection, actorConfigs);
|
|
230
|
-
};
|
|
231
|
-
|
|
232
94
|
export const setCwd = ({ workspace }: { workspace: string | undefined }) => {
|
|
233
95
|
if (workspace) {
|
|
234
96
|
process.chdir(workspace);
|
package/dist/bin/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../bin/main.ts"],"names":[],"mappings":";AAIA,OAAc,EAAE,KAAK,IAAI,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../bin/main.ts"],"names":[],"mappings":";AAIA,OAAc,EAAE,KAAK,IAAI,EAAE,MAAM,OAAO,CAAC;AAoBzC,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;;;;;;;;EAkBzC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;;;;EAYlD,CAAC"}
|
package/dist/bin/main.js
CHANGED
|
@@ -10,7 +10,8 @@ import { getBranchOnlyChangedFiles, getChangedFiles, getCommits, hasMergeFromTar
|
|
|
10
10
|
import { getPushData } from './github.js';
|
|
11
11
|
import { notifyToSlack } from './slack.js';
|
|
12
12
|
import { reportTestResults } from './test-report.js';
|
|
13
|
-
import {
|
|
13
|
+
import { setCwd, spawnCommandInGhWorkspace } from './utils.js';
|
|
14
|
+
import { readConfigFile } from './utils/config/load-config.js';
|
|
14
15
|
/**
|
|
15
16
|
* Middlewares to be run before every command execution
|
|
16
17
|
*/
|
package/dist/bin/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../bin/main.ts"],"names":[],"mappings":";AAEA,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,gFAAgF;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,E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EAAE,CAAC,CAAC;QACpC,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC;KACD,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC"}
|
package/dist/bin/types.d.ts
CHANGED
|
@@ -76,15 +76,6 @@ export interface GithubCommit {
|
|
|
76
76
|
removed: string[];
|
|
77
77
|
modified: string[];
|
|
78
78
|
}
|
|
79
|
-
export interface ActorConfigFileEntry {
|
|
80
|
-
folder: string;
|
|
81
|
-
actorFullName: string;
|
|
82
|
-
tokenEnvVar: string;
|
|
83
|
-
overrideActorContext?: string[];
|
|
84
|
-
}
|
|
85
|
-
export interface ActorConfigFile {
|
|
86
|
-
actors: ActorConfigFileEntry[];
|
|
87
|
-
}
|
|
88
79
|
export interface BuildData {
|
|
89
80
|
buildId: string;
|
|
90
81
|
actorRawId: string;
|
package/dist/bin/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../bin/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,MAAM,MAAM,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAGF,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,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UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;CAC1B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ActorConfig } from '../../types.js';
|
|
3
|
+
export declare const CONFIG_FILE_NAME = "apify-test-tools.config.json";
|
|
4
|
+
declare const CONFIG_FILE_SCHEMA: z.ZodObject<{
|
|
5
|
+
actors: z.ZodArray<z.ZodObject<{
|
|
6
|
+
folder: z.ZodString;
|
|
7
|
+
actorFullName: z.ZodString;
|
|
8
|
+
tokenEnvVar: z.ZodString;
|
|
9
|
+
overrideActorContext: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
|
+
}, z.core.$strip>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export type ActorConfigFile = z.infer<typeof CONFIG_FILE_SCHEMA>;
|
|
13
|
+
/**
|
|
14
|
+
* The single shape stage 4 understands: an actor entry whose paths have been normalized, with no
|
|
15
|
+
* trace left of which config flavour produced it. Whatever replaces or extends
|
|
16
|
+
* {@link parseConfigFile} and {@link resolveRawConfig} only has to produce this.
|
|
17
|
+
*/
|
|
18
|
+
export interface ResolvedActorConfig {
|
|
19
|
+
actorFullName: string;
|
|
20
|
+
folder: string;
|
|
21
|
+
tokenEnvVar: string;
|
|
22
|
+
overrideActorContext?: string[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Stage 2 — validates the file's shape. Every problem is reported at once rather than only the
|
|
26
|
+
* first one to fail.
|
|
27
|
+
*/
|
|
28
|
+
export declare const parseConfigFile: (contents: Record<string, unknown>) => ActorConfigFile;
|
|
29
|
+
/**
|
|
30
|
+
* Stage 3 — normalizes the paths the user wrote and rejects entries that collide once normalized.
|
|
31
|
+
* The repo root is "" from here on, however it was spelled in the file.
|
|
32
|
+
*/
|
|
33
|
+
export declare const resolveRawConfig: (config: ActorConfigFile) => ResolvedActorConfig[];
|
|
34
|
+
/**
|
|
35
|
+
* Stage 4 — resolves one normalized entry against the repo, reading the actor's `.actor/actor.json`
|
|
36
|
+
* for its `dockerContextDir` and deciding which paths count as the actor's context.
|
|
37
|
+
*/
|
|
38
|
+
export declare const loadActorConfig: (entry: ResolvedActorConfig) => ActorConfig;
|
|
39
|
+
export declare const readConfigFile: (selection: {
|
|
40
|
+
actors: string[];
|
|
41
|
+
ignore: string[];
|
|
42
|
+
}) => Promise<ActorConfig[]>;
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=load-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-config.d.ts","sourceRoot":"","sources":["../../../../bin/utils/config/load-config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,eAAO,MAAM,gBAAgB,iCAAiC,CAAC;AAwB/D,QAAA,MAAM,kBAAkB;;;;;;;iBAEtB,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEjE;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CACnC;AAqFD;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,eASnE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,eAAe,KAAG,mBAAmB,EAoB7E,CAAC;AAMF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,mBAAmB,KAAG,WAiD5D,CAAC;AAIF,eAAO,MAAM,cAAc,GAAU,WAAW;IAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,KAAG,OAAO,CAAC,WAAW,EAAE,CAc7G,CAAC"}
|