apify-test-tools 0.10.1-beta.6 → 0.10.1-beta.7
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/bin/build-from-local.ts +19 -27
- package/bin/build.ts +1 -1
- package/bin/diff-changes.ts +26 -35
- package/bin/dockerignore.ts +24 -17
- package/bin/types.ts +7 -3
- package/bin/utils/config/actor-json.ts +49 -8
- package/bin/utils/config/load-config.ts +4 -24
- package/bin/utils/path/repo-relative.ts +27 -4
- package/dist/bin/build-from-local.d.ts +3 -2
- package/dist/bin/build-from-local.d.ts.map +1 -1
- package/dist/bin/build-from-local.js +16 -23
- package/dist/bin/build-from-local.js.map +1 -1
- package/dist/bin/build.js +1 -1
- package/dist/bin/build.js.map +1 -1
- package/dist/bin/diff-changes.d.ts.map +1 -1
- package/dist/bin/diff-changes.js +26 -29
- package/dist/bin/diff-changes.js.map +1 -1
- package/dist/bin/dockerignore.d.ts +11 -10
- package/dist/bin/dockerignore.d.ts.map +1 -1
- package/dist/bin/dockerignore.js +24 -15
- package/dist/bin/dockerignore.js.map +1 -1
- package/dist/bin/types.d.ts +6 -3
- package/dist/bin/types.d.ts.map +1 -1
- package/dist/bin/utils/config/actor-json.d.ts.map +1 -1
- package/dist/bin/utils/config/actor-json.js +35 -4
- package/dist/bin/utils/config/actor-json.js.map +1 -1
- package/dist/bin/utils/config/load-config.d.ts +1 -11
- package/dist/bin/utils/config/load-config.d.ts.map +1 -1
- package/dist/bin/utils/config/load-config.js +1 -10
- package/dist/bin/utils/config/load-config.js.map +1 -1
- package/dist/bin/utils/path/repo-relative.d.ts +4 -0
- package/dist/bin/utils/path/repo-relative.d.ts.map +1 -1
- package/dist/bin/utils/path/repo-relative.js +24 -5
- package/dist/bin/utils/path/repo-relative.js.map +1 -1
- package/dist/test/unit/bin/actor-filtering.test.js +8 -2
- package/dist/test/unit/bin/actor-filtering.test.js.map +1 -1
- package/dist/test/unit/bin/build-from-local.test.js +53 -5
- package/dist/test/unit/bin/build-from-local.test.js.map +1 -1
- package/dist/test/unit/bin/diff-changes.test.js +98 -132
- package/dist/test/unit/bin/diff-changes.test.js.map +1 -1
- package/dist/test/unit/bin/dockerignore.test.js +27 -24
- package/dist/test/unit/bin/dockerignore.test.js.map +1 -1
- package/dist/test/unit/bin/utils/config/load-config.test.js +40 -4
- package/dist/test/unit/bin/utils/config/load-config.test.js.map +1 -1
- package/dist/test/unit/bin/utils/path/repo-relative.test.js +5 -0
- package/dist/test/unit/bin/utils/path/repo-relative.test.js.map +1 -1
- package/dist/test/unit/should-built-and-test.test.js +55 -116
- package/dist/test/unit/should-built-and-test.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/test/unit/bin/actor-filtering.test.ts +8 -2
- package/test/unit/bin/build-from-local.test.ts +54 -8
- package/test/unit/bin/diff-changes.test.ts +133 -133
- package/test/unit/bin/dockerignore.test.ts +28 -28
- package/test/unit/bin/utils/config/load-config.test.ts +54 -4
- package/test/unit/bin/utils/path/repo-relative.test.ts +6 -0
- package/test/unit/should-built-and-test.test.ts +98 -121
package/package.json
CHANGED
|
@@ -2,12 +2,18 @@ import { describe, expect, it } from 'vitest';
|
|
|
2
2
|
|
|
3
3
|
import { selectActors } from '../../../bin/actor-filtering.js';
|
|
4
4
|
import type { ActorConfig } from '../../../bin/types.js';
|
|
5
|
+
import { ExistingDir, ExistingFile, RelativeDir } from '../../../bin/utils/path/repo-relative.js';
|
|
5
6
|
|
|
6
7
|
const actor = (actorFullName: string): ActorConfig => ({
|
|
7
8
|
actorFullName,
|
|
8
|
-
folder:
|
|
9
|
+
folder: new ExistingDir('.'),
|
|
9
10
|
tokenEnvVar: 'TOKEN',
|
|
10
|
-
|
|
11
|
+
actorJson: {
|
|
12
|
+
// kind of a hack, but its not supposed to be read here
|
|
13
|
+
file: new ExistingFile('package.json'),
|
|
14
|
+
dockerContextDir: RelativeDir.ROOT,
|
|
15
|
+
},
|
|
16
|
+
dockerContextDir: new RelativeDir('.'),
|
|
11
17
|
contextPaths: [],
|
|
12
18
|
});
|
|
13
19
|
|
|
@@ -13,7 +13,9 @@ import {
|
|
|
13
13
|
// @ts-ignore: editor-only TS6059 — test/tsconfig.json's rootDir doesn't span bin/, but the root
|
|
14
14
|
// tsconfig (used for the real build and for eslint's type-aware linting) has no such restriction.
|
|
15
15
|
} from '../../../bin/build-from-local.js';
|
|
16
|
+
import type { ActorConfig } from '../../../bin/types.js';
|
|
16
17
|
import * as Utils from '../../../bin/utils.js';
|
|
18
|
+
import { ExistingDir, ExistingFile, RelativeDir } from '../../../bin/utils/path/repo-relative.js';
|
|
17
19
|
|
|
18
20
|
const mkTempDir = async (prefix: string) => fs.mkdtemp(path.join(os.tmpdir(), prefix));
|
|
19
21
|
|
|
@@ -32,17 +34,53 @@ describe('build-from-local helpers', () => {
|
|
|
32
34
|
|
|
33
35
|
await fs.writeFile(path.join(rootDir, 'main.js'), 'console.log(1)');
|
|
34
36
|
await fs.writeFile(path.join(rootDir, '.env'), 'SECRET=1');
|
|
37
|
+
await fs.writeFile(path.join(rootDir, 'docker-ignored.txt'), 'ignored');
|
|
38
|
+
await fs.writeFile(path.join(rootDir, '.dockerignore'), 'docker-ignored.txt\n');
|
|
35
39
|
await fs.mkdir(path.join(rootDir, 'sub'));
|
|
36
40
|
await fs.writeFile(path.join(rootDir, 'sub', 'ignored.log'), 'log');
|
|
37
41
|
|
|
38
|
-
vi.spyOn(Utils, 'listRepoFilePaths').mockResolvedValue([
|
|
42
|
+
vi.spyOn(Utils, 'listRepoFilePaths').mockResolvedValue([
|
|
43
|
+
'main.js',
|
|
44
|
+
'.env',
|
|
45
|
+
'docker-ignored.txt',
|
|
46
|
+
'sub/ignored.log',
|
|
47
|
+
]);
|
|
39
48
|
vi.spyOn(Utils, 'getGitignoredPaths').mockImplementation(
|
|
40
49
|
async (relativePaths) => new Set(relativePaths.filter((p) => p.endsWith('.log'))),
|
|
41
50
|
);
|
|
42
51
|
|
|
43
|
-
const
|
|
52
|
+
const originalCwd = process.cwd();
|
|
53
|
+
process.chdir(rootDir);
|
|
54
|
+
try {
|
|
55
|
+
expect(await collectNonIgnoredFiles(RelativeDir.ROOT, rootDir)).toStrictEqual([
|
|
56
|
+
path.join(rootDir, 'main.js'),
|
|
57
|
+
]);
|
|
58
|
+
} finally {
|
|
59
|
+
process.chdir(originalCwd);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('matches .dockerignore relative to a nested Docker context', async () => {
|
|
64
|
+
const rootDir = await mkTempDir('apify-test-tools-nested-context-');
|
|
65
|
+
tempDirs.push(rootDir);
|
|
66
|
+
await fs.mkdir(path.join(rootDir, 'actors', 'shopify'), { recursive: true });
|
|
67
|
+
await fs.writeFile(path.join(rootDir, 'actors', 'shopify', '.dockerignore'), 'dist/\n');
|
|
44
68
|
|
|
45
|
-
|
|
69
|
+
vi.spyOn(Utils, 'listRepoFilePaths').mockResolvedValue([
|
|
70
|
+
'actors/shopify/dist/bundle.js',
|
|
71
|
+
'actors/shopify/src/main.ts',
|
|
72
|
+
]);
|
|
73
|
+
vi.spyOn(Utils, 'getGitignoredPaths').mockResolvedValue(new Set());
|
|
74
|
+
|
|
75
|
+
const originalCwd = process.cwd();
|
|
76
|
+
process.chdir(rootDir);
|
|
77
|
+
try {
|
|
78
|
+
expect(await collectNonIgnoredFiles(new RelativeDir('actors/shopify'), rootDir)).toStrictEqual([
|
|
79
|
+
path.join(rootDir, 'actors', 'shopify', 'src', 'main.ts'),
|
|
80
|
+
]);
|
|
81
|
+
} finally {
|
|
82
|
+
process.chdir(originalCwd);
|
|
83
|
+
}
|
|
46
84
|
});
|
|
47
85
|
});
|
|
48
86
|
|
|
@@ -148,11 +186,19 @@ describe('build-from-local helpers', () => {
|
|
|
148
186
|
'actors/owner_actor/.actor/actor.json',
|
|
149
187
|
'package.json',
|
|
150
188
|
]);
|
|
151
|
-
vi.spyOn(Utils, 'getGitignoredPaths').mockResolvedValue(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
189
|
+
vi.spyOn(Utils, 'getGitignoredPaths').mockResolvedValue(new Set());
|
|
190
|
+
const actorConfig: ActorConfig = {
|
|
191
|
+
actorFullName: 'owner/actor',
|
|
192
|
+
folder: new ExistingDir('actors/owner_actor'),
|
|
193
|
+
tokenEnvVar: 'APIFY_TOKEN',
|
|
194
|
+
actorJson: {
|
|
195
|
+
file: new ExistingFile('actors/owner_actor/.actor/actor.json'),
|
|
196
|
+
dockerContextDir: RelativeDir.ROOT,
|
|
197
|
+
},
|
|
198
|
+
dockerContextDir: RelativeDir.ROOT,
|
|
199
|
+
contextPaths: [RelativeDir.ROOT],
|
|
200
|
+
};
|
|
201
|
+
const sourceFiles = await collectSourceFiles(actorConfig);
|
|
156
202
|
expect(sourceFiles.map((file) => file.name)).toContain('.actor/actor.json');
|
|
157
203
|
} finally {
|
|
158
204
|
process.chdir(originalCwd);
|
|
@@ -1,33 +1,63 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
6
|
|
|
3
7
|
import { getChangedActors } from '../../../bin/diff-changes.js';
|
|
4
8
|
import * as DiffJsonSchema from '../../../bin/diff-json-schema.js';
|
|
5
9
|
import * as Dockerignore from '../../../bin/dockerignore.js';
|
|
6
10
|
import { logger } from '../../../bin/logger.js';
|
|
7
11
|
import type { ActorConfig } from '../../../bin/types.js';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
import { ExistingDir, RelativeDir, RelativeFile } from '../../../bin/utils/path/repo-relative.js';
|
|
13
|
+
|
|
14
|
+
const originalCwd = process.cwd();
|
|
15
|
+
const fixtureRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'apify-diff-changes-'));
|
|
16
|
+
process.chdir(fixtureRoot);
|
|
17
|
+
fs.writeFileSync('package.json', '{}');
|
|
18
|
+
|
|
19
|
+
const actorConfig = (
|
|
20
|
+
actorFullName: string,
|
|
21
|
+
folder: string,
|
|
22
|
+
tokenEnvVar: string,
|
|
23
|
+
dockerContextDir: string,
|
|
24
|
+
contextPaths: string[],
|
|
25
|
+
): ActorConfig => {
|
|
26
|
+
const folderPath = folder || '.';
|
|
27
|
+
fs.mkdirSync(folderPath, { recursive: true });
|
|
28
|
+
return {
|
|
29
|
+
actorFullName,
|
|
30
|
+
folder: new ExistingDir(folderPath),
|
|
31
|
+
tokenEnvVar,
|
|
32
|
+
actorJson: {
|
|
33
|
+
file: new RelativeFile(path.join(folderPath, '.actor/actor.json')),
|
|
34
|
+
dockerContextDir: new RelativeDir(dockerContextDir || '.'),
|
|
35
|
+
changelog: new RelativeFile('CHANGELOG.md'),
|
|
36
|
+
},
|
|
37
|
+
dockerContextDir: new RelativeDir(dockerContextDir || '.'),
|
|
38
|
+
contextPaths: contextPaths.map((contextPath) => new RelativeDir(contextPath || '.')),
|
|
39
|
+
};
|
|
22
40
|
};
|
|
41
|
+
|
|
42
|
+
afterAll(() => {
|
|
43
|
+
process.chdir(originalCwd);
|
|
44
|
+
fs.rmSync(fixtureRoot, { recursive: true, force: true });
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const miniActor = actorConfig('foo/bar', 'actors/foo_bar', 'APIFY_TOKEN_FOO', '', ['']);
|
|
48
|
+
const standaloneActor = actorConfig(
|
|
49
|
+
'owner/standalone',
|
|
50
|
+
'standalone-actors/standalone',
|
|
51
|
+
'APIFY_TOKEN_OWNER',
|
|
52
|
+
'standalone-actors/standalone',
|
|
53
|
+
['standalone-actors/standalone'],
|
|
54
|
+
);
|
|
23
55
|
const actorConfigs = [miniActor, standaloneActor];
|
|
24
|
-
const amazonActor
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
contextPaths: ['actors/junglee_Amazon-crawler', 'code', 'shared'],
|
|
30
|
-
};
|
|
56
|
+
const amazonActor = actorConfig('junglee/amazon-crawler', 'actors/junglee_Amazon-crawler', 'APIFY_TOKEN_JUNGLEE', '', [
|
|
57
|
+
'actors/junglee_Amazon-crawler',
|
|
58
|
+
'code',
|
|
59
|
+
'shared',
|
|
60
|
+
]);
|
|
31
61
|
|
|
32
62
|
const commits = [{ sha: 'Commit1', author: '', date: '', message: '' }];
|
|
33
63
|
|
|
@@ -49,6 +79,15 @@ describe('getChangedActors', () => {
|
|
|
49
79
|
expect(result).toEqual([]);
|
|
50
80
|
});
|
|
51
81
|
|
|
82
|
+
it('does not ignore source files whose names contain an ignored file name', async () => {
|
|
83
|
+
const result = await getChangedActors({
|
|
84
|
+
filepathsChanged: ['actors/foo_bar/src/.gitignore-helper.ts'],
|
|
85
|
+
actorConfigs,
|
|
86
|
+
commits,
|
|
87
|
+
});
|
|
88
|
+
expect(result).toEqual([miniActor]);
|
|
89
|
+
});
|
|
90
|
+
|
|
52
91
|
it('returns the actor when a functional file in its folder changes', async () => {
|
|
53
92
|
const result = await getChangedActors({
|
|
54
93
|
filepathsChanged: ['actors/foo_bar/src/main.ts'],
|
|
@@ -101,7 +140,6 @@ describe('getChangedActors', () => {
|
|
|
101
140
|
});
|
|
102
141
|
|
|
103
142
|
it('returns actor when JSON file has functional changes', async () => {
|
|
104
|
-
vi.spyOn(DiffJsonSchema, 'isCosmeticOnlyJsonSchemaChange').mockResolvedValue(false);
|
|
105
143
|
const result = await getChangedActors({
|
|
106
144
|
filepathsChanged: ['actors/foo_bar/.actor/actor.json'],
|
|
107
145
|
actorConfigs,
|
|
@@ -128,9 +166,13 @@ describe('getChangedActors', () => {
|
|
|
128
166
|
filepathsChanged: ['actors/foo_bar/.actor/input_schema.json'],
|
|
129
167
|
actorConfigs,
|
|
130
168
|
commits,
|
|
131
|
-
isLatest:
|
|
169
|
+
isLatest: false,
|
|
132
170
|
});
|
|
133
|
-
expect(result).toEqual([
|
|
171
|
+
expect(result).toEqual([]);
|
|
172
|
+
expect(DiffJsonSchema.isCosmeticOnlyJsonSchemaChange).toHaveBeenCalledWith(
|
|
173
|
+
commits,
|
|
174
|
+
'actors/foo_bar/.actor/input_schema.json',
|
|
175
|
+
);
|
|
134
176
|
});
|
|
135
177
|
|
|
136
178
|
it('does not trigger narrow-context actor when shared file changes', async () => {
|
|
@@ -164,6 +206,30 @@ describe('getChangedActors', () => {
|
|
|
164
206
|
expect(result).toEqual([]);
|
|
165
207
|
});
|
|
166
208
|
|
|
209
|
+
it('treats any changelog filename as cosmetic regardless of configured paths', async () => {
|
|
210
|
+
const result = await getChangedActors({
|
|
211
|
+
filepathsChanged: ['docs/CHANGELOG.md'],
|
|
212
|
+
actorConfigs: [miniActor, standaloneActor],
|
|
213
|
+
commits,
|
|
214
|
+
isLatest: true,
|
|
215
|
+
});
|
|
216
|
+
expect(result).toEqual([miniActor, standaloneActor]);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('does not special-case a configured readme outside the actor context', async () => {
|
|
220
|
+
const configuredActor: ActorConfig = {
|
|
221
|
+
...standaloneActor,
|
|
222
|
+
actorJson: { ...standaloneActor.actorJson, readme: new RelativeFile('docs/guide.md') },
|
|
223
|
+
};
|
|
224
|
+
const result = await getChangedActors({
|
|
225
|
+
filepathsChanged: ['docs/guide.md'],
|
|
226
|
+
actorConfigs: [configuredActor],
|
|
227
|
+
commits,
|
|
228
|
+
isLatest: true,
|
|
229
|
+
});
|
|
230
|
+
expect(result).toEqual([]);
|
|
231
|
+
});
|
|
232
|
+
|
|
167
233
|
it('triggers narrow-context actor when its own folder changes', async () => {
|
|
168
234
|
const result = await getChangedActors({
|
|
169
235
|
filepathsChanged: ['standalone-actors/standalone/src/main.ts'],
|
|
@@ -194,13 +260,7 @@ describe('getChangedActors', () => {
|
|
|
194
260
|
});
|
|
195
261
|
|
|
196
262
|
it('matches folder where folder name differs from actor name', async () => {
|
|
197
|
-
const ownerlessActor
|
|
198
|
-
actorFullName: 'myteam/shopify-scraper',
|
|
199
|
-
folder: 'actors/shopify',
|
|
200
|
-
tokenEnvVar: 'APIFY_TOKEN_MYTEAM',
|
|
201
|
-
dockerContextDir: '',
|
|
202
|
-
contextPaths: [''],
|
|
203
|
-
};
|
|
263
|
+
const ownerlessActor = actorConfig('myteam/shopify-scraper', 'actors/shopify', 'APIFY_TOKEN_MYTEAM', '', ['']);
|
|
204
264
|
const result = await getChangedActors({
|
|
205
265
|
filepathsChanged: ['actors/shopify/src/main.ts'],
|
|
206
266
|
actorConfigs: [ownerlessActor],
|
|
@@ -210,13 +270,7 @@ describe('getChangedActors', () => {
|
|
|
210
270
|
});
|
|
211
271
|
|
|
212
272
|
it('in single-actor repo, .actor/ changes trigger builds', async () => {
|
|
213
|
-
const rootActor
|
|
214
|
-
actorFullName: 'myteam/my-actor',
|
|
215
|
-
folder: '',
|
|
216
|
-
tokenEnvVar: 'BUILDER_APIFY_TOKEN',
|
|
217
|
-
dockerContextDir: '',
|
|
218
|
-
contextPaths: [''],
|
|
219
|
-
};
|
|
273
|
+
const rootActor = actorConfig('myteam/my-actor', '', 'BUILDER_APIFY_TOKEN', '', ['']);
|
|
220
274
|
const result = await getChangedActors({
|
|
221
275
|
filepathsChanged: ['.actor/actor.json'],
|
|
222
276
|
actorConfigs: [rootActor],
|
|
@@ -234,23 +288,26 @@ describe('getChangedActors', () => {
|
|
|
234
288
|
expect(result).toEqual([miniActor]);
|
|
235
289
|
});
|
|
236
290
|
|
|
237
|
-
it('file paths are matched case-
|
|
291
|
+
it('file paths are matched case-sensitively', async () => {
|
|
292
|
+
const narrowActor = actorConfig('foo/bar', 'actors/foo_bar', 'APIFY_TOKEN_FOO', 'actors/foo_bar', [
|
|
293
|
+
'actors/foo_bar',
|
|
294
|
+
]);
|
|
238
295
|
const result = await getChangedActors({
|
|
239
296
|
filepathsChanged: ['Actors/FOO_BAR/Main.ts'],
|
|
240
|
-
actorConfigs,
|
|
297
|
+
actorConfigs: [narrowActor],
|
|
241
298
|
commits,
|
|
242
299
|
});
|
|
243
|
-
expect(result).toEqual([
|
|
300
|
+
expect(result).toEqual([]);
|
|
244
301
|
});
|
|
245
302
|
|
|
246
303
|
it('triggers actor with contextPaths override when file matches an override path', async () => {
|
|
247
|
-
const overrideActor
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
304
|
+
const overrideActor = actorConfig(
|
|
305
|
+
'team/override-actor',
|
|
306
|
+
'actors/override',
|
|
307
|
+
'APIFY_TOKEN_TEAM',
|
|
308
|
+
'actors/override',
|
|
309
|
+
['actors/override', 'packages'],
|
|
310
|
+
);
|
|
254
311
|
const result = await getChangedActors({
|
|
255
312
|
filepathsChanged: ['packages/shared/utils.ts'],
|
|
256
313
|
actorConfigs: [overrideActor],
|
|
@@ -260,13 +317,13 @@ describe('getChangedActors', () => {
|
|
|
260
317
|
});
|
|
261
318
|
|
|
262
319
|
it('does not trigger actor with contextPaths override when file is outside all override paths', async () => {
|
|
263
|
-
const overrideActor
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
320
|
+
const overrideActor = actorConfig(
|
|
321
|
+
'team/override-actor',
|
|
322
|
+
'actors/override',
|
|
323
|
+
'APIFY_TOKEN_TEAM',
|
|
324
|
+
'actors/override',
|
|
325
|
+
['actors/override', 'packages'],
|
|
326
|
+
);
|
|
270
327
|
const result = await getChangedActors({
|
|
271
328
|
filepathsChanged: ['other-dir/file.ts'],
|
|
272
329
|
actorConfigs: [overrideActor],
|
|
@@ -276,20 +333,8 @@ describe('getChangedActors', () => {
|
|
|
276
333
|
});
|
|
277
334
|
|
|
278
335
|
it('broad-context actor skips files in sibling actor folders', async () => {
|
|
279
|
-
const actorA
|
|
280
|
-
|
|
281
|
-
folder: 'actors/a',
|
|
282
|
-
tokenEnvVar: 'APIFY_TOKEN_TEAM',
|
|
283
|
-
dockerContextDir: '',
|
|
284
|
-
contextPaths: [''],
|
|
285
|
-
};
|
|
286
|
-
const actorB: ActorConfig = {
|
|
287
|
-
actorFullName: 'team/actor-b',
|
|
288
|
-
folder: 'actors/b',
|
|
289
|
-
tokenEnvVar: 'APIFY_TOKEN_TEAM',
|
|
290
|
-
dockerContextDir: '',
|
|
291
|
-
contextPaths: [''],
|
|
292
|
-
};
|
|
336
|
+
const actorA = actorConfig('team/actor-a', 'actors/a', 'APIFY_TOKEN_TEAM', '', ['']);
|
|
337
|
+
const actorB = actorConfig('team/actor-b', 'actors/b', 'APIFY_TOKEN_TEAM', '', ['']);
|
|
293
338
|
const result = await getChangedActors({
|
|
294
339
|
filepathsChanged: ['actors/b/src/main.ts'],
|
|
295
340
|
actorConfigs: [actorA, actorB],
|
|
@@ -298,21 +343,11 @@ describe('getChangedActors', () => {
|
|
|
298
343
|
expect(result).toEqual([actorB]);
|
|
299
344
|
});
|
|
300
345
|
|
|
301
|
-
it('root actor
|
|
302
|
-
const rootActor
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
dockerContextDir: '',
|
|
307
|
-
contextPaths: [''],
|
|
308
|
-
};
|
|
309
|
-
const childActor: ActorConfig = {
|
|
310
|
-
actorFullName: 'team/child',
|
|
311
|
-
folder: 'actors/child',
|
|
312
|
-
tokenEnvVar: 'APIFY_TOKEN_TEAM',
|
|
313
|
-
dockerContextDir: 'actors/child',
|
|
314
|
-
contextPaths: ['actors/child'],
|
|
315
|
-
};
|
|
346
|
+
it('root actor is excluded from sibling actor folder files', async () => {
|
|
347
|
+
const rootActor = actorConfig('team/root', '', 'APIFY_TOKEN_TEAM', '', ['']);
|
|
348
|
+
const childActor = actorConfig('team/child', 'actors/child', 'APIFY_TOKEN_TEAM', 'actors/child', [
|
|
349
|
+
'actors/child',
|
|
350
|
+
]);
|
|
316
351
|
const result = await getChangedActors({
|
|
317
352
|
filepathsChanged: ['actors/child/src/main.ts'],
|
|
318
353
|
actorConfigs: [rootActor, childActor],
|
|
@@ -322,21 +357,11 @@ describe('getChangedActors', () => {
|
|
|
322
357
|
expect(result).toContainEqual(childActor);
|
|
323
358
|
});
|
|
324
359
|
|
|
325
|
-
it('root actor
|
|
326
|
-
const rootActor
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
dockerContextDir: '',
|
|
331
|
-
contextPaths: [''],
|
|
332
|
-
};
|
|
333
|
-
const childActor: ActorConfig = {
|
|
334
|
-
actorFullName: 'team/child',
|
|
335
|
-
folder: 'actors/child',
|
|
336
|
-
tokenEnvVar: 'APIFY_TOKEN_TEAM',
|
|
337
|
-
dockerContextDir: 'actors/child',
|
|
338
|
-
contextPaths: ['actors/child'],
|
|
339
|
-
};
|
|
360
|
+
it('root actor sees files outside any actor folder', async () => {
|
|
361
|
+
const rootActor = actorConfig('team/root', '', 'APIFY_TOKEN_TEAM', '', ['']);
|
|
362
|
+
const childActor = actorConfig('team/child', 'actors/child', 'APIFY_TOKEN_TEAM', 'actors/child', [
|
|
363
|
+
'actors/child',
|
|
364
|
+
]);
|
|
340
365
|
const result = await getChangedActors({
|
|
341
366
|
filepathsChanged: ['lib/shared-utils.ts'],
|
|
342
367
|
actorConfigs: [rootActor, childActor],
|
|
@@ -369,7 +394,6 @@ describe('getChangedActors', () => {
|
|
|
369
394
|
});
|
|
370
395
|
|
|
371
396
|
it('JSON file in context but outside actor folder is functional (not checked for cosmetic)', async () => {
|
|
372
|
-
vi.spyOn(DiffJsonSchema, 'isCosmeticOnlyJsonSchemaChange').mockResolvedValue(true);
|
|
373
397
|
const result = await getChangedActors({
|
|
374
398
|
filepathsChanged: ['lib/config.json'],
|
|
375
399
|
actorConfigs: [miniActor],
|
|
@@ -398,7 +422,7 @@ describe('getChangedActors', () => {
|
|
|
398
422
|
expect(result).toEqual([miniActor]);
|
|
399
423
|
});
|
|
400
424
|
|
|
401
|
-
it('
|
|
425
|
+
it('ignores a standalone actor top-level dev file relative to its context', async () => {
|
|
402
426
|
const result = await getChangedActors({
|
|
403
427
|
filepathsChanged: ['standalone-actors/standalone/.eslintrc'],
|
|
404
428
|
actorConfigs,
|
|
@@ -409,7 +433,7 @@ describe('getChangedActors', () => {
|
|
|
409
433
|
|
|
410
434
|
it('does not special-case code/ and shared/ prefixes anymore — must be declared via overrideActorContext', async () => {
|
|
411
435
|
const result = await getChangedActors({
|
|
412
|
-
filepathsChanged: ['code
|
|
436
|
+
filepathsChanged: ['code/some/code.ts'],
|
|
413
437
|
actorConfigs: [miniActor],
|
|
414
438
|
commits,
|
|
415
439
|
});
|
|
@@ -465,20 +489,8 @@ describe('getChangedActors logging', () => {
|
|
|
465
489
|
});
|
|
466
490
|
|
|
467
491
|
it('logs a single "shared" group when two actors are triggered by the exact same file', async () => {
|
|
468
|
-
const actorA
|
|
469
|
-
|
|
470
|
-
folder: 'actors/a',
|
|
471
|
-
tokenEnvVar: 'APIFY_TOKEN_TEAM',
|
|
472
|
-
dockerContextDir: '',
|
|
473
|
-
contextPaths: ['', 'shared'],
|
|
474
|
-
};
|
|
475
|
-
const actorB: ActorConfig = {
|
|
476
|
-
actorFullName: 'team/actor-b',
|
|
477
|
-
folder: 'actors/b',
|
|
478
|
-
tokenEnvVar: 'APIFY_TOKEN_TEAM',
|
|
479
|
-
dockerContextDir: '',
|
|
480
|
-
contextPaths: ['', 'shared'],
|
|
481
|
-
};
|
|
492
|
+
const actorA = actorConfig('team/actor-a', 'actors/a', 'APIFY_TOKEN_TEAM', '', ['', 'shared']);
|
|
493
|
+
const actorB = actorConfig('team/actor-b', 'actors/b', 'APIFY_TOKEN_TEAM', '', ['', 'shared']);
|
|
482
494
|
|
|
483
495
|
await getChangedActors({
|
|
484
496
|
filepathsChanged: ['shared/shared.ts'],
|
|
@@ -494,20 +506,8 @@ describe('getChangedActors logging', () => {
|
|
|
494
506
|
});
|
|
495
507
|
|
|
496
508
|
it('logs shared and specific groups in descending-size order for partial overlap across actors', async () => {
|
|
497
|
-
const actorA
|
|
498
|
-
|
|
499
|
-
folder: 'actors/a',
|
|
500
|
-
tokenEnvVar: 'APIFY_TOKEN_TEAM',
|
|
501
|
-
dockerContextDir: '',
|
|
502
|
-
contextPaths: [''],
|
|
503
|
-
};
|
|
504
|
-
const actorB: ActorConfig = {
|
|
505
|
-
actorFullName: 'team/actor-b',
|
|
506
|
-
folder: 'actors/b',
|
|
507
|
-
tokenEnvVar: 'APIFY_TOKEN_TEAM',
|
|
508
|
-
dockerContextDir: '',
|
|
509
|
-
contextPaths: [''],
|
|
510
|
-
};
|
|
509
|
+
const actorA = actorConfig('team/actor-a', 'actors/a', 'APIFY_TOKEN_TEAM', '', ['']);
|
|
510
|
+
const actorB = actorConfig('team/actor-b', 'actors/b', 'APIFY_TOKEN_TEAM', '', ['']);
|
|
511
511
|
|
|
512
512
|
await getChangedActors({
|
|
513
513
|
filepathsChanged: ['shared.ts', 'actors/a/a-only.ts', 'actors/b/b-only.ts'],
|
|
@@ -515,7 +515,7 @@ describe('getChangedActors logging', () => {
|
|
|
515
515
|
commits,
|
|
516
516
|
});
|
|
517
517
|
|
|
518
|
-
const errorCalls = (logger.info
|
|
518
|
+
const errorCalls = vi.mocked(logger.info).mock.calls.map((call) => call[0]);
|
|
519
519
|
|
|
520
520
|
expect(errorCalls).toEqual([
|
|
521
521
|
'[DIFF]: Shared changes for actors team/actor-a, team/actor-b: shared.ts',
|
|
@@ -527,7 +527,7 @@ describe('getChangedActors logging', () => {
|
|
|
527
527
|
|
|
528
528
|
it('logs no group lines when zero actors changed', async () => {
|
|
529
529
|
await getChangedActors({
|
|
530
|
-
filepathsChanged: ['.gitignore', '
|
|
530
|
+
filepathsChanged: ['.gitignore', '.prettierrc'],
|
|
531
531
|
actorConfigs,
|
|
532
532
|
commits,
|
|
533
533
|
});
|