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
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { selectActors } from '../../actor-filtering.js';
|
|
4
|
+
import { isPathWithinScope } from '../../path-utils.js';
|
|
5
|
+
import { safeReadJsonObjectFile } from '../json-file.js';
|
|
6
|
+
export const CONFIG_FILE_NAME = 'apify-test-tools.config.json';
|
|
7
|
+
// Reading the config happens in four stages, each one swappable on its own:
|
|
8
|
+
//
|
|
9
|
+
// 1. file -> plain object (safeReadJsonObjectFile)
|
|
10
|
+
// 2. plain object -> ActorConfigFile (parseConfigFile — the schema, swap point for new flavours)
|
|
11
|
+
// 3. ActorConfigFile -> ResolvedActorConfig[] (resolveRawConfig — one normalized shape for everyone)
|
|
12
|
+
// 4. ResolvedActorConfig -> ActorConfig (loadActorConfig — merges in .actor/actor.json)
|
|
13
|
+
//
|
|
14
|
+
// Stages 1-3 are the "what did the user write" half and stage 4 the "what does the repo look like"
|
|
15
|
+
// half. A differently shaped config file only has to reach stage 3's output to work with the rest
|
|
16
|
+
// of the tool.
|
|
17
|
+
// #region schema (soon to be moved)
|
|
18
|
+
const ACTOR_ENTRY_SCHEMA = z.object({
|
|
19
|
+
folder: z.string(),
|
|
20
|
+
// "owner/name", with neither half empty — deliberately permissive about what characters those
|
|
21
|
+
// halves may contain, the platform is the authority on that.
|
|
22
|
+
actorFullName: z.string().regex(/^[^/]+\/[^/]+$/),
|
|
23
|
+
tokenEnvVar: z.string(),
|
|
24
|
+
overrideActorContext: z.array(z.string()).optional(),
|
|
25
|
+
});
|
|
26
|
+
const CONFIG_FILE_SCHEMA = z.object({
|
|
27
|
+
actors: z.array(ACTOR_ENTRY_SCHEMA),
|
|
28
|
+
});
|
|
29
|
+
// #endregion
|
|
30
|
+
// #region utils
|
|
31
|
+
// Strips a trailing slash so config-declared paths ("actors/shopify/" vs "actors/shopify") compare equal.
|
|
32
|
+
const stripTrailingSlash = (pathValue) => pathValue.replace(/\/+$/, '');
|
|
33
|
+
const findOverlappingContextPaths = (contextPaths) => {
|
|
34
|
+
for (let i = 0; i < contextPaths.length; i++) {
|
|
35
|
+
for (let j = i + 1; j < contextPaths.length; j++) {
|
|
36
|
+
if (isPathWithinScope(contextPaths[i], contextPaths[j]) ||
|
|
37
|
+
isPathWithinScope(contextPaths[j], contextPaths[i])) {
|
|
38
|
+
return [contextPaths[i], contextPaths[j]];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
};
|
|
44
|
+
// Restates a schema violation in the wording this config file has always used, so error output
|
|
45
|
+
// stays recognizable now that the hand-rolled checks are gone.
|
|
46
|
+
const describeIssue = (issue, rawActors) => {
|
|
47
|
+
const [, index, field] = issue.path;
|
|
48
|
+
if (typeof index !== 'number') {
|
|
49
|
+
return `Config file "${CONFIG_FILE_NAME}" must have an "actors" array at the top level.`;
|
|
50
|
+
}
|
|
51
|
+
const folder = rawActors[index]?.folder;
|
|
52
|
+
switch (field) {
|
|
53
|
+
case 'folder':
|
|
54
|
+
return (`Invalid "folder" for actor entry at index ${index} in "${CONFIG_FILE_NAME}". ` +
|
|
55
|
+
`Must be a string (use "." for a single-actor repo).`);
|
|
56
|
+
case 'actorFullName':
|
|
57
|
+
return (`Invalid "actorFullName" for folder "${folder}" in "${CONFIG_FILE_NAME}". ` +
|
|
58
|
+
`Must be in "owner/name" format (e.g. "apify/web-scraper").`);
|
|
59
|
+
case 'tokenEnvVar':
|
|
60
|
+
return `Invalid "tokenEnvVar" for folder "${folder}" in "${CONFIG_FILE_NAME}". Must be a string.`;
|
|
61
|
+
case 'overrideActorContext':
|
|
62
|
+
return (`Invalid "overrideActorContext" for folder "${folder}" in "${CONFIG_FILE_NAME}". ` +
|
|
63
|
+
`Must be an array of strings.`);
|
|
64
|
+
default:
|
|
65
|
+
return `Invalid actor entry at index ${index} in "${CONFIG_FILE_NAME}": ${issue.message}`;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
// #endregion
|
|
69
|
+
// #region stages
|
|
70
|
+
/** Stage 1 — the config file as a plain object, or a failure phrased for whoever wrote it. */
|
|
71
|
+
const readConfigFileContents = async () => {
|
|
72
|
+
const file = safeReadJsonObjectFile(CONFIG_FILE_NAME);
|
|
73
|
+
if (file.success) {
|
|
74
|
+
return file.contents;
|
|
75
|
+
}
|
|
76
|
+
switch (file.reason) {
|
|
77
|
+
case 'invalid-json':
|
|
78
|
+
// TODO: support .jsonc
|
|
79
|
+
throw new Error(`Config file "${CONFIG_FILE_NAME}" contains invalid JSON and cannot be parsed.`);
|
|
80
|
+
// Valid JSON that isn't an object can't carry an "actors" array either.
|
|
81
|
+
case 'not-an-object':
|
|
82
|
+
throw new Error(`Config file "${CONFIG_FILE_NAME}" must have an "actors" array at the top level.`);
|
|
83
|
+
default:
|
|
84
|
+
throw new Error(`Config file "${CONFIG_FILE_NAME}" not found in the current directory. ` +
|
|
85
|
+
`Please create one with the required actor entries.`);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Stage 2 — validates the file's shape. Every problem is reported at once rather than only the
|
|
90
|
+
* first one to fail.
|
|
91
|
+
*/
|
|
92
|
+
export const parseConfigFile = (contents) => {
|
|
93
|
+
const parsed = CONFIG_FILE_SCHEMA.safeParse(contents);
|
|
94
|
+
if (parsed.success) {
|
|
95
|
+
return parsed.data;
|
|
96
|
+
}
|
|
97
|
+
const rawActors = Array.isArray(contents.actors) ? contents.actors : [];
|
|
98
|
+
const messages = new Set(parsed.error.issues.map((issue) => describeIssue(issue, rawActors)));
|
|
99
|
+
throw new Error([...messages].join('\n'));
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Stage 3 — normalizes the paths the user wrote and rejects entries that collide once normalized.
|
|
103
|
+
* The repo root is "" from here on, however it was spelled in the file.
|
|
104
|
+
*/
|
|
105
|
+
export const resolveRawConfig = (config) => {
|
|
106
|
+
const seenFolders = new Set();
|
|
107
|
+
return config.actors.map((entry) => {
|
|
108
|
+
const folder = entry.folder === '.' ? '' : stripTrailingSlash(entry.folder);
|
|
109
|
+
if (seenFolders.has(folder)) {
|
|
110
|
+
throw new Error(`Duplicate folder "${entry.folder}" in "${CONFIG_FILE_NAME}". Each actor must have a unique folder.`);
|
|
111
|
+
}
|
|
112
|
+
seenFolders.add(folder);
|
|
113
|
+
return {
|
|
114
|
+
actorFullName: entry.actorFullName,
|
|
115
|
+
folder,
|
|
116
|
+
tokenEnvVar: entry.tokenEnvVar,
|
|
117
|
+
overrideActorContext: entry.overrideActorContext?.map(stripTrailingSlash),
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
// The repo root is spelled "" internally but "." in a config file, so report it the way a reader
|
|
122
|
+
// would have written it.
|
|
123
|
+
const displayFolder = (folder) => folder || '.';
|
|
124
|
+
/**
|
|
125
|
+
* Stage 4 — resolves one normalized entry against the repo, reading the actor's `.actor/actor.json`
|
|
126
|
+
* for its `dockerContextDir` and deciding which paths count as the actor's context.
|
|
127
|
+
*/
|
|
128
|
+
export const loadActorConfig = (entry) => {
|
|
129
|
+
const { folder } = entry;
|
|
130
|
+
const actorJsonPath = folder ? `${folder}/.actor/actor.json` : '.actor/actor.json';
|
|
131
|
+
const actorJson = safeReadJsonObjectFile(actorJsonPath);
|
|
132
|
+
if (!actorJson.success) {
|
|
133
|
+
throw new Error(`Cannot read "${actorJsonPath}". Every actor entry in "${CONFIG_FILE_NAME}" ` +
|
|
134
|
+
`must have a corresponding .actor/actor.json file.`);
|
|
135
|
+
}
|
|
136
|
+
const actorDotDir = folder ? `${folder}/.actor` : '.actor';
|
|
137
|
+
const rawDockerContextDir = typeof actorJson.contents.dockerContextDir === 'string' ? actorJson.contents.dockerContextDir : '..';
|
|
138
|
+
const resolved = path.resolve(process.cwd(), actorDotDir, rawDockerContextDir);
|
|
139
|
+
const dockerContextDir = path.relative(process.cwd(), resolved);
|
|
140
|
+
if (dockerContextDir.startsWith('..')) {
|
|
141
|
+
throw new Error(`"dockerContextDir" for folder "${displayFolder(folder)}" resolves outside the repository root. ` +
|
|
142
|
+
`Resolved path: "${dockerContextDir}".`);
|
|
143
|
+
}
|
|
144
|
+
const normalizedDockerContextDir = dockerContextDir === '.' ? '' : dockerContextDir;
|
|
145
|
+
const contextPaths = [...(entry.overrideActorContext ?? [normalizedDockerContextDir])];
|
|
146
|
+
// The actor's own folder is always part of its context. When an explicit "overrideActorContext"
|
|
147
|
+
// doesn't already cover it, add it automatically instead of failing the workflow.
|
|
148
|
+
if (!contextPaths.some((contextPath) => isPathWithinScope(folder, contextPath))) {
|
|
149
|
+
contextPaths.push(folder);
|
|
150
|
+
}
|
|
151
|
+
const overlap = findOverlappingContextPaths(contextPaths);
|
|
152
|
+
if (overlap) {
|
|
153
|
+
throw new Error(`Invalid context paths for folder "${displayFolder(folder)}" in "${CONFIG_FILE_NAME}": ` +
|
|
154
|
+
`"${overlap[0]}" and "${overlap[1]}" overlap. Context paths must not be prefixes of one another.`);
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
actorFullName: entry.actorFullName,
|
|
158
|
+
folder,
|
|
159
|
+
tokenEnvVar: entry.tokenEnvVar,
|
|
160
|
+
dockerContextDir: normalizedDockerContextDir,
|
|
161
|
+
contextPaths,
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
// #endregion
|
|
165
|
+
export const readConfigFile = async (selection) => {
|
|
166
|
+
const rawConfig = await readConfigFileContents();
|
|
167
|
+
// replace this when enabling different file structures
|
|
168
|
+
// some kind of strategy pattern seems appropriate here
|
|
169
|
+
const resolvedConfigs = resolveRawConfig(parseConfigFile(rawConfig));
|
|
170
|
+
const actorConfigs = [];
|
|
171
|
+
for (const resolved of resolvedConfigs) {
|
|
172
|
+
// Sequential on purpose: the first actor with a problem should be the one reported.
|
|
173
|
+
actorConfigs.push(loadActorConfig(resolved));
|
|
174
|
+
}
|
|
175
|
+
return selectActors(selection, actorConfigs);
|
|
176
|
+
};
|
|
177
|
+
//# sourceMappingURL=load-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-config.js","sourceRoot":"","sources":["../../../../bin/utils/config/load-config.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE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AC,CAAC;IAC1D,IAAI,OAAO,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACX,qCAAqC,aAAa,CAAC,MAAM,CAAC,SAAS,gBAAgB,KAAK;YACpF,IAAI,OAAO,CAAC,CAAC,CAAC,UAAU,OAAO,CAAC,CAAC,CAAC,+DAA+D,CACxG,CAAC;IACN,CAAC;IAED,OAAO;QACH,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,MAAM;QACN,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,gBAAgB,EAAE,0BAA0B;QAC5C,YAAY;KACf,CAAC;AACN,CAAC,CAAC;AAEF,aAAa;AAEb,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,SAAiD,EAA0B,EAAE;IAC9G,MAAM,SAAS,GAAG,MAAM,sBAAsB,EAAE,CAAC;IAEjD,uDAAuD;IACvD,uDAAuD;IACvD,MAAM,eAAe,GAAG,gBAAgB,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;IAErE,MAAM,YAAY,GAAkB,EAAE,CAAC;IACvC,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE,CAAC;QACrC,oFAAoF;QACpF,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AACjD,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why a JSON object could not be produced from a path. Callers that already have their own
|
|
3
|
+
* user-facing wording (e.g. the config file reader) switch on this instead of re-deriving the
|
|
4
|
+
* cause from an error message.
|
|
5
|
+
*/
|
|
6
|
+
export type JsonObjectReadFailureReason = 'not-a-file' | 'unreadable' | 'invalid-json' | 'not-an-object';
|
|
7
|
+
export type JsonObjectReadResult = {
|
|
8
|
+
success: true;
|
|
9
|
+
contents: Record<string, unknown>;
|
|
10
|
+
} | {
|
|
11
|
+
success: false;
|
|
12
|
+
reason: JsonObjectReadFailureReason;
|
|
13
|
+
failure: Error;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Reads a file and parses it as a JSON object, reporting every way that can go wrong as a value
|
|
17
|
+
* instead of a thrown error — the caller decides which failures are fatal and how to word them.
|
|
18
|
+
*/
|
|
19
|
+
export declare function safeReadJsonObjectFile(path: string): JsonObjectReadResult;
|
|
20
|
+
//# sourceMappingURL=json-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-file.d.ts","sourceRoot":"","sources":["../../../bin/utils/json-file.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG,YAAY,GAAG,YAAY,GAAG,cAAc,GAAG,eAAe,CAAC;AAEzG,MAAM,MAAM,oBAAoB,GAC1B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACpD;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,2BAA2B,CAAC;IAAC,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;AAQ9E;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,CA+BzE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { readFileSync, statSync } from 'node:fs';
|
|
2
|
+
const failed = (reason, message) => ({
|
|
3
|
+
success: false,
|
|
4
|
+
reason,
|
|
5
|
+
failure: new Error(message),
|
|
6
|
+
});
|
|
7
|
+
/**
|
|
8
|
+
* Reads a file and parses it as a JSON object, reporting every way that can go wrong as a value
|
|
9
|
+
* instead of a thrown error — the caller decides which failures are fatal and how to word them.
|
|
10
|
+
*/
|
|
11
|
+
export function safeReadJsonObjectFile(path) {
|
|
12
|
+
let file;
|
|
13
|
+
try {
|
|
14
|
+
// `stat`, not `lstat`: a symlink must resolve to its target, matching what `readFile` does below.
|
|
15
|
+
const stats = statSync(path);
|
|
16
|
+
if (!stats.isFile()) {
|
|
17
|
+
return failed('not-a-file', `Expected ${path} to be a file`);
|
|
18
|
+
}
|
|
19
|
+
file = readFileSync(path, 'utf8');
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return failed('unreadable', `Expected ${path} to exist or be readable`);
|
|
23
|
+
}
|
|
24
|
+
let parsed;
|
|
25
|
+
try {
|
|
26
|
+
parsed = JSON.parse(file);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
return failed('invalid-json', `Failed to parse ${path}: ${err}`);
|
|
30
|
+
}
|
|
31
|
+
if (parsed === null) {
|
|
32
|
+
return failed('not-an-object', `Expected ${path} to be a JSON object, not null`);
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(parsed)) {
|
|
35
|
+
return failed('not-an-object', `Expected ${path} to be a JSON object, not an array`);
|
|
36
|
+
}
|
|
37
|
+
if (typeof parsed !== 'object') {
|
|
38
|
+
return failed('not-an-object', `Expected ${path} to be a JSON object`);
|
|
39
|
+
}
|
|
40
|
+
return { success: true, contents: parsed };
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=json-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-file.js","sourceRoot":"","sources":["../../../bin/utils/json-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAajD,MAAM,MAAM,GAAG,CAAC,MAAmC,EAAE,OAAe,EAAwB,EAAE,CAAC,CAAC;IAC5F,OAAO,EAAE,KAAK;IACd,MAAM;IACN,OAAO,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC;CAC9B,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY;IAC/C,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACD,kGAAkG;QAClG,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YAClB,OAAO,MAAM,CAAC,YAAY,EAAE,YAAY,IAAI,eAAe,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,MAAM,CAAC,YAAY,EAAE,YAAY,IAAI,0BAA0B,CAAC,CAAC;IAC5E,CAAC;IAED,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACD,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,OAAO,MAAM,CAAC,cAAc,EAAE,mBAAmB,IAAI,KAAK,GAAG,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC,eAAe,EAAE,YAAY,IAAI,gCAAgC,CAAC,CAAC;IACrF,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,eAAe,EAAE,YAAY,IAAI,oCAAoC,CAAC,CAAC;IACzF,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC,eAAe,EAAE,YAAY,IAAI,sBAAsB,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAiC,EAAE,CAAC;AAC1E,CAAC"}
|
package/dist/bin/utils.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ActorVersionSourceFile } from 'apify-client';
|
|
2
|
-
import type { ActorConfig } from './types.js';
|
|
3
2
|
export declare const isOutsideDir: (childPath: string, parentPath: string) => boolean;
|
|
4
3
|
/**
|
|
5
4
|
* Lists every file under `subDir` (paths relative to `repoRoot`) that's either tracked by git or
|
|
@@ -19,11 +18,6 @@ export declare const getGitignoredPaths: (relativePaths: string[]) => Set<string
|
|
|
19
18
|
export declare const toActorVersionSourceFile: (absPath: string, rootDir: string) => Promise<ActorVersionSourceFile>;
|
|
20
19
|
export declare const spawnCommandInGhWorkspace: (command: string, args?: string[]) => string;
|
|
21
20
|
export declare const getEnvVar: (varName: string, defaultValue?: string) => string;
|
|
22
|
-
export declare const CONFIG_FILE_NAME = "apify-test-tools.config.json";
|
|
23
|
-
export declare const readConfigFile: (selection: {
|
|
24
|
-
actors: string[];
|
|
25
|
-
ignore: string[];
|
|
26
|
-
}) => Promise<ActorConfig[]>;
|
|
27
21
|
export declare const setCwd: ({ workspace }: {
|
|
28
22
|
workspace: string | undefined;
|
|
29
23
|
}) => void;
|
package/dist/bin/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../bin/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAM3D,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../bin/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAM3D,eAAO,MAAM,YAAY,GAAI,WAAW,MAAM,EAAE,YAAY,MAAM,KAAG,OACZ,CAAC;AAE1D;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,EAAE,QAAQ,MAAM,KAAG,MAAM,EAY1E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,eAAe,MAAM,EAAE,KAAG,GAAG,CAAC,MAAM,CAetE,CAAC;AAIF,eAAO,MAAM,wBAAwB,GAAU,SAAS,MAAM,EAAE,SAAS,MAAM,KAAG,OAAO,CAAC,sBAAsB,CAM/G,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAI,SAAS,MAAM,EAAE,OAAM,MAAM,EAAO,WAgB7E,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,SAAS,MAAM,EAAE,eAAe,MAAM,KAAG,MAMlE,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,eAAe;IAAE,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,SAOtE,CAAC"}
|
package/dist/bin/utils.js
CHANGED
|
@@ -2,8 +2,6 @@ import { spawnSync } from 'node:child_process';
|
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { SOURCE_FILE_FORMATS } from '@apify/consts';
|
|
5
|
-
import { selectActors } from './actor-filtering.js';
|
|
6
|
-
import { isPathWithinScope } from './path-utils.js';
|
|
7
5
|
// Returns true when `childPath` is not inside `parentPath`.
|
|
8
6
|
// Used to detect monorepo actors whose dockerContextDir escapes the actor directory.
|
|
9
7
|
export const isOutsideDir = (childPath, parentPath) => path.relative(parentPath, childPath).startsWith('..');
|
|
@@ -74,102 +72,6 @@ export const getEnvVar = (varName, defaultValue) => {
|
|
|
74
72
|
}
|
|
75
73
|
return value;
|
|
76
74
|
};
|
|
77
|
-
export const CONFIG_FILE_NAME = 'apify-test-tools.config.json';
|
|
78
|
-
// Strips a trailing slash so config-declared paths ("actors/shopify/" vs "actors/shopify") compare equal.
|
|
79
|
-
const stripTrailingSlash = (pathValue) => pathValue.replace(/\/+$/, '');
|
|
80
|
-
const findOverlappingContextPaths = (contextPaths) => {
|
|
81
|
-
for (let i = 0; i < contextPaths.length; i++) {
|
|
82
|
-
for (let j = i + 1; j < contextPaths.length; j++) {
|
|
83
|
-
if (isPathWithinScope(contextPaths[i], contextPaths[j]) ||
|
|
84
|
-
isPathWithinScope(contextPaths[j], contextPaths[i])) {
|
|
85
|
-
return [contextPaths[i], contextPaths[j]];
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return undefined;
|
|
90
|
-
};
|
|
91
|
-
export const readConfigFile = async (selection) => {
|
|
92
|
-
let raw;
|
|
93
|
-
try {
|
|
94
|
-
raw = await fs.readFile(CONFIG_FILE_NAME, 'utf-8');
|
|
95
|
-
}
|
|
96
|
-
catch {
|
|
97
|
-
throw new Error(`Config file "${CONFIG_FILE_NAME}" not found in the current directory. ` +
|
|
98
|
-
`Please create one with the required actor entries.`);
|
|
99
|
-
}
|
|
100
|
-
let config;
|
|
101
|
-
try {
|
|
102
|
-
config = JSON.parse(raw);
|
|
103
|
-
}
|
|
104
|
-
catch {
|
|
105
|
-
throw new Error(`Config file "${CONFIG_FILE_NAME}" contains invalid JSON.`);
|
|
106
|
-
}
|
|
107
|
-
if (!Array.isArray(config.actors)) {
|
|
108
|
-
throw new Error(`Config file "${CONFIG_FILE_NAME}" must have an "actors" array at the top level.`);
|
|
109
|
-
}
|
|
110
|
-
const seenFolders = new Set();
|
|
111
|
-
const actorConfigs = [];
|
|
112
|
-
for (const [index, entry] of config.actors.entries()) {
|
|
113
|
-
if (typeof entry.folder !== 'string') {
|
|
114
|
-
throw new Error(`Invalid "folder" for actor entry at index ${index} in "${CONFIG_FILE_NAME}". ` +
|
|
115
|
-
`Must be a string (use "." for a single-actor repo).`);
|
|
116
|
-
}
|
|
117
|
-
const folder = entry.folder === '.' ? '' : stripTrailingSlash(entry.folder);
|
|
118
|
-
if (seenFolders.has(folder)) {
|
|
119
|
-
throw new Error(`Duplicate folder "${entry.folder}" in "${CONFIG_FILE_NAME}". Each actor must have a unique folder.`);
|
|
120
|
-
}
|
|
121
|
-
seenFolders.add(folder);
|
|
122
|
-
const nameParts = entry.actorFullName?.split('/');
|
|
123
|
-
if (!nameParts || nameParts.length !== 2 || !nameParts[0] || !nameParts[1]) {
|
|
124
|
-
throw new Error(`Invalid "actorFullName" for folder "${entry.folder}" in "${CONFIG_FILE_NAME}". ` +
|
|
125
|
-
`Must be in "owner/name" format (e.g. "apify/web-scraper").`);
|
|
126
|
-
}
|
|
127
|
-
if (entry.overrideActorContext !== undefined) {
|
|
128
|
-
if (!Array.isArray(entry.overrideActorContext) ||
|
|
129
|
-
!entry.overrideActorContext.every((p) => typeof p === 'string')) {
|
|
130
|
-
throw new Error(`Invalid "overrideActorContext" for folder "${entry.folder}" in "${CONFIG_FILE_NAME}". ` +
|
|
131
|
-
`Must be an array of strings.`);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
const actorJsonPath = folder ? `${folder}/.actor/actor.json` : '.actor/actor.json';
|
|
135
|
-
let actorJson;
|
|
136
|
-
try {
|
|
137
|
-
actorJson = JSON.parse(await fs.readFile(actorJsonPath, 'utf-8'));
|
|
138
|
-
}
|
|
139
|
-
catch {
|
|
140
|
-
throw new Error(`Cannot read "${actorJsonPath}". Every actor entry in "${CONFIG_FILE_NAME}" ` +
|
|
141
|
-
`must have a corresponding .actor/actor.json file.`);
|
|
142
|
-
}
|
|
143
|
-
const actorDotDir = folder ? `${folder}/.actor` : '.actor';
|
|
144
|
-
const rawDockerContextDir = actorJson.dockerContextDir ?? '..';
|
|
145
|
-
const resolved = path.resolve(process.cwd(), actorDotDir, rawDockerContextDir);
|
|
146
|
-
const dockerContextDir = path.relative(process.cwd(), resolved);
|
|
147
|
-
if (dockerContextDir.startsWith('..')) {
|
|
148
|
-
throw new Error(`"dockerContextDir" for folder "${entry.folder}" resolves outside the repository root. ` +
|
|
149
|
-
`Resolved path: "${dockerContextDir}".`);
|
|
150
|
-
}
|
|
151
|
-
const normalizedDockerContextDir = dockerContextDir === '.' ? '' : dockerContextDir;
|
|
152
|
-
const contextPaths = (entry.overrideActorContext ?? [normalizedDockerContextDir]).map(stripTrailingSlash);
|
|
153
|
-
// The actor's own folder is always part of its context. When an explicit "overrideActorContext"
|
|
154
|
-
// doesn't already cover it, add it automatically instead of failing the workflow.
|
|
155
|
-
if (!contextPaths.some((contextPath) => isPathWithinScope(folder, contextPath))) {
|
|
156
|
-
contextPaths.push(folder);
|
|
157
|
-
}
|
|
158
|
-
const overlap = findOverlappingContextPaths(contextPaths);
|
|
159
|
-
if (overlap) {
|
|
160
|
-
throw new Error(`Invalid context paths for folder "${entry.folder}" in "${CONFIG_FILE_NAME}": ` +
|
|
161
|
-
`"${overlap[0]}" and "${overlap[1]}" overlap. Context paths must not be prefixes of one another.`);
|
|
162
|
-
}
|
|
163
|
-
actorConfigs.push({
|
|
164
|
-
actorFullName: entry.actorFullName,
|
|
165
|
-
folder,
|
|
166
|
-
tokenEnvVar: entry.tokenEnvVar,
|
|
167
|
-
dockerContextDir: normalizedDockerContextDir,
|
|
168
|
-
contextPaths,
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
return selectActors(selection, actorConfigs);
|
|
172
|
-
};
|
|
173
75
|
export const setCwd = ({ workspace }) => {
|
|
174
76
|
if (workspace) {
|
|
175
77
|
process.chdir(workspace);
|
package/dist/bin/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../bin/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../bin/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,4DAA4D;AAC5D,qFAAqF;AACrF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,SAAiB,EAAE,UAAkB,EAAW,EAAE,CAC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IACX,CAAC;IACD,MAAM,WAAW,GAAG,SAAS,CAAC,kBAAkB,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACjE,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AAC/B,CAAC,CAAC"}
|
package/dist/lib/consts.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const TO_FINISH_WITH_OPTIONS: ToFinishWithOptionsWithDefaults;
|
|
|
4
4
|
* Both the test runs and the vitest test specs should finish in this time - 1 hour
|
|
5
5
|
*/
|
|
6
6
|
export declare const DEFAULT_TEST_RUN_DURATION_MS: number;
|
|
7
|
+
export declare const DEFAULT_TEST_ACTOR_TIMEOUT_SECS: number;
|
|
7
8
|
/**
|
|
8
9
|
* Delay before checking the dataset and statistics after a run finishes to resolve eventual consistency.
|
|
9
10
|
* - This value should ensure that the dataset and statistics are fully updated before any assertions are made.
|
package/dist/lib/consts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../lib/consts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAC;AAElE,eAAO,MAAM,sBAAsB,EAAE,+BAUpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,QAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../lib/consts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAC;AAElE,eAAO,MAAM,sBAAsB,EAAE,+BAUpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,QAAiB,CAAC;AAI3D,eAAO,MAAM,+BAA+B,QAA2C,CAAC;AAExF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAY,CAAC"}
|
package/dist/lib/consts.js
CHANGED
|
@@ -13,6 +13,9 @@ export const TO_FINISH_WITH_OPTIONS = {
|
|
|
13
13
|
* Both the test runs and the vitest test specs should finish in this time - 1 hour
|
|
14
14
|
*/
|
|
15
15
|
export const DEFAULT_TEST_RUN_DURATION_MS = 60 * 60 * 1000; // 1 hour
|
|
16
|
+
// Prevent orphaned runs - timeout the Actor 1 minute before the test does so everything is logged correctly.
|
|
17
|
+
// - Otherwise the run link URL can get lost.
|
|
18
|
+
export const DEFAULT_TEST_ACTOR_TIMEOUT_SECS = DEFAULT_TEST_RUN_DURATION_MS / 1000 - 60;
|
|
16
19
|
/**
|
|
17
20
|
* Delay before checking the dataset and statistics after a run finishes to resolve eventual consistency.
|
|
18
21
|
* - This value should ensure that the dataset and statistics are fully updated before any assertions are made.
|
package/dist/lib/consts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../../lib/consts.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,sBAAsB,GAAoC;IACnE,MAAM,EAAE,WAAW;IACnB,QAAQ,EAAE;QACN,GAAG,EAAE,GAAG,EAAE,UAAU;QACpB,GAAG,EAAE,OAAO,EAAE,SAAS;KAC1B;IACD,cAAc,EAAE,CAAC;IACjB,eAAe,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE;IAC3B,oBAAoB,EAAE,IAAI;IAC1B,aAAa,EAAE,CAAC,gBAAgB,EAAE,WAAW,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,SAAS;AAErE;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa"}
|
|
1
|
+
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../../lib/consts.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,sBAAsB,GAAoC;IACnE,MAAM,EAAE,WAAW;IACnB,QAAQ,EAAE;QACN,GAAG,EAAE,GAAG,EAAE,UAAU;QACpB,GAAG,EAAE,OAAO,EAAE,SAAS;KAC1B;IACD,cAAc,EAAE,CAAC;IACjB,eAAe,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE;IAC3B,oBAAoB,EAAE,IAAI;IAC1B,aAAa,EAAE,CAAC,gBAAgB,EAAE,WAAW,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,SAAS;AAErE,6GAA6G;AAC7G,kDAAkD;AAClD,MAAM,CAAC,MAAM,+BAA+B,GAAG,4BAA4B,GAAG,IAAI,GAAG,EAAE,CAAC;AAExF;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa"}
|
package/dist/lib/lib.d.ts
CHANGED
|
@@ -51,4 +51,8 @@ interface StandbyTask {
|
|
|
51
51
|
taskId: string;
|
|
52
52
|
}
|
|
53
53
|
declare const createStartRunFn: <T>(actorId: string, testContext: TestContext) => (runOptions: RunOptions<T>) => Promise<RunTestResult>;
|
|
54
|
+
/** Used for unit testing */
|
|
55
|
+
export declare const _private: {
|
|
56
|
+
readonly createStartRunFn: <T>(actorId: string, testContext: TestContext) => (runOptions: RunOptions<T>) => Promise<RunTestResult>;
|
|
57
|
+
};
|
|
54
58
|
//# sourceMappingURL=lib.d.ts.map
|
package/dist/lib/lib.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../lib/lib.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtE,OAAO,EAA8B,YAAY,EAAsB,MAAM,QAAQ,CAAC;AAItF,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAc,gB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,CAAC,CAAC,CAAC,CAAA;CAAE,CAAC,SAYpE,CAAC;AAEF,eAAO,MAAM,EAAE,GArFW,CAAC,WACd,MAAM,YACL,MAAM,MACZ,YAAY,CAAC;IAAE,GAAG,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAA;CAAE,CAAC,gBACnD,gBAAgB,SAiFP,CAAC;AAE5B;;;GAGG;AACH,QAAA,MAAM,oBAAoB,GAAI,CAAC,EAAE,CAAC,EAAE,aAAa,WAAW,EAAE,cAAc,WAAW,EAAE,UAAU,MAAM,MAmBvF,2BAIX,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE;;;;EAmBxF,CAAC;AAEF,UAAU,WAAW;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAClB;AA6DD,QAAA,MAAM,gBAAgB,GAAI,CAAC,EAAE,SAAS,MAAM,EAAE,aAAa,WAAW,MAKpD,YAAY,UAAU,CAAC,CAAC,CAAC,2BAwC1C,CAAC;AAMF,4BAA4B;AAE5B,eAAO,MAAM,QAAQ;gCArDK,CAAC,WAAW,MAAM,eAAe,WAAW,MAKpD,YAAY,UAAU,CAAC,CAAC,CAAC;CAgDU,CAAC"}
|
package/dist/lib/lib.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApifyClient } from 'apify-client';
|
|
2
2
|
import { describe as vitestDescribe, test as vitestTest } from 'vitest';
|
|
3
|
-
import { DATASET_SYNC_DELAY_MS, DEFAULT_TEST_RUN_DURATION_MS } from './consts.js';
|
|
3
|
+
import { DATASET_SYNC_DELAY_MS, DEFAULT_TEST_ACTOR_TIMEOUT_SECS, DEFAULT_TEST_RUN_DURATION_MS } from './consts.js';
|
|
4
4
|
import { extendExpect } from './extend-expect.js';
|
|
5
5
|
import { RunTestResult } from './run-test-result.js';
|
|
6
6
|
import { getActorPrefilledInput, sleep } from './utils.js';
|
|
@@ -30,6 +30,7 @@ const DEFAULT_TEST_OPTIONS = {
|
|
|
30
30
|
concurrent: true,
|
|
31
31
|
// test should finish within 1 hour
|
|
32
32
|
timeout: DEFAULT_TEST_RUN_DURATION_MS,
|
|
33
|
+
retry: 1,
|
|
33
34
|
};
|
|
34
35
|
/**
|
|
35
36
|
* Platform tests need `TESTER_APIFY_TOKEN` to talk to the platform, so without it we skip them altogether.
|
|
@@ -40,19 +41,11 @@ const DEFAULT_TEST_OPTIONS = {
|
|
|
40
41
|
export const describe = (name, fn, options = DEFAULT_TEST_OPTIONS) => {
|
|
41
42
|
vitestDescribe.runIf(!!TESTER_APIFY_TOKEN || !!RUN_ALL_PLATFORM_TESTS)(name, options, fn);
|
|
42
43
|
};
|
|
43
|
-
const DEFAULT_TEST_ACTOR_OPTIONS = {
|
|
44
|
-
retry: 1,
|
|
45
|
-
// prevent orphaned runs
|
|
46
|
-
timeout: DEFAULT_TEST_RUN_DURATION_MS,
|
|
47
|
-
};
|
|
48
44
|
/**
|
|
49
45
|
* @param actorId - The actor's raw platform ID or its full name (`owner/name`, e.g. `"apify/web-scraper"`).
|
|
50
46
|
*/
|
|
51
47
|
export const testActor = (actorId, testName, fn, testOptions) => {
|
|
52
|
-
const options = {
|
|
53
|
-
...DEFAULT_TEST_ACTOR_OPTIONS,
|
|
54
|
-
...testOptions,
|
|
55
|
-
};
|
|
48
|
+
const options = { ...DEFAULT_TEST_OPTIONS, ...testOptions };
|
|
56
49
|
const name = `${actorId}: ${testName}`;
|
|
57
50
|
// `RUN_ALL_PLATFORM_TESTS` is needed for the scheduled tests, which have no `ACTOR_BUILDS` to match the
|
|
58
51
|
// tests against - without it, every test would be filtered out as an actor we didn't build.
|
|
@@ -77,10 +70,7 @@ export const testActor = (actorId, testName, fn, testOptions) => {
|
|
|
77
70
|
*/
|
|
78
71
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
72
|
export const testStandbyActor = (actorId, testName, fn, testOptions) => {
|
|
80
|
-
const options = {
|
|
81
|
-
...DEFAULT_TEST_ACTOR_OPTIONS,
|
|
82
|
-
...testOptions,
|
|
83
|
-
};
|
|
73
|
+
const options = { ...DEFAULT_TEST_OPTIONS, ...testOptions };
|
|
84
74
|
const name = `${actorId}: ${testName}`;
|
|
85
75
|
// `RUN_ALL_PLATFORM_TESTS` is needed for the scheduled tests, which have no `ACTOR_BUILDS` to match the
|
|
86
76
|
// tests against - without it, every test would be filtered out as an actor we didn't build.
|
|
@@ -224,12 +214,15 @@ const createStartRunFn = (actorId, testContext) => {
|
|
|
224
214
|
}
|
|
225
215
|
return new RunTestResult(apifyClient, run);
|
|
226
216
|
}
|
|
227
|
-
const actor = apifyClient.actor(actorId);
|
|
228
217
|
const actorInput = {
|
|
229
218
|
...(prefilledInput && (await getActorPrefilledInput(apifyClient, actorId, buildId))),
|
|
230
219
|
...input,
|
|
231
220
|
};
|
|
232
|
-
const
|
|
221
|
+
const actor = apifyClient.actor(actorId);
|
|
222
|
+
const actorInfo = await actor.get();
|
|
223
|
+
const timeout = Math.min(actorInfo?.defaultRunOptions?.timeoutSecs ?? DEFAULT_TEST_ACTOR_TIMEOUT_SECS, DEFAULT_TEST_ACTOR_TIMEOUT_SECS);
|
|
224
|
+
const actorOptions = { timeout, build, log: null, ...options };
|
|
225
|
+
const run = await actor.call(actorInput, actorOptions);
|
|
233
226
|
const runLink = generateRunLink(run);
|
|
234
227
|
await annotate(`${task.name} - ${runLink}`, 'run_link');
|
|
235
228
|
// @ts-expect-error: `TaskMeta` cannot be retyped
|
|
@@ -246,4 +239,7 @@ const createStartRunFn = (actorId, testContext) => {
|
|
|
246
239
|
const generateRunLink = (run) => {
|
|
247
240
|
return `https://console.apify.com/view/runs/${run.id}`;
|
|
248
241
|
};
|
|
242
|
+
/** Used for unit testing */
|
|
243
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
244
|
+
export const _private = { createStartRunFn };
|
|
249
245
|
//# sourceMappingURL=lib.js.map
|
package/dist/lib/lib.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../lib/lib.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAgB,IAAI,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEtF,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../lib/lib.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAgB,IAAI,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEtF,OAAO,EAAE,qBAAqB,EAAE,+BAA+B,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AACnH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAE3D,MAAM,YAAY,GAAG,cAAc,CAAC;AACpC,IAAI,WAAW,GAAiB,EAAE,CAAC;AACnC,IAAI,CAAC;IACD,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACjD,IAAI,cAAc,EAAE,CAAC;QACjB,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,GAAG,YAAY,kDAAkD,OAAO,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C;AAEF,4BAA4B;AAC5B,gDAAgD;AAChD,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,gBAAgB,EAAW,CAAC"}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -8,7 +8,15 @@ export type ActorBuild = {
|
|
|
8
8
|
};
|
|
9
9
|
export type RunOptions<T> = {
|
|
10
10
|
input: Omit<T, 'actorName'>;
|
|
11
|
-
options?: ActorCallOptions
|
|
11
|
+
options?: Omit<ActorCallOptions, 'timeout'> & {
|
|
12
|
+
/**
|
|
13
|
+
* Timeout for the actor run in seconds. Zero value means there is no timeout.
|
|
14
|
+
* - If `undefined`, the run uses timeout of the default Actor run configuration.
|
|
15
|
+
*
|
|
16
|
+
* @default 3540 // 59 minutes (finish the run before the test)
|
|
17
|
+
*/
|
|
18
|
+
timeout?: number;
|
|
19
|
+
};
|
|
12
20
|
prefilledInput?: boolean;
|
|
13
21
|
/**
|
|
14
22
|
* If you specify `runId`, all the other options will be ignored and this run's data will
|
|
@@ -115,8 +123,8 @@ export type ActorTestOptions = Omit<TestOptions, 'retry' | 'timeout'> & {
|
|
|
115
123
|
*/
|
|
116
124
|
retry?: TestOptions['retry'];
|
|
117
125
|
/**
|
|
118
|
-
* Timeout for the
|
|
119
|
-
* - If `undefined`, the run uses timeout of the default
|
|
126
|
+
* Timeout for the test in milliseconds. Zero value means there is no timeout.
|
|
127
|
+
* - If `undefined`, the run uses timeout of the default test configuration.
|
|
120
128
|
*
|
|
121
129
|
* @default 60 * 60 * 1000 // 1 hour
|
|
122
130
|
*/
|