apify-test-tools 0.6.0 → 0.6.1
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/.github/workflows/_check_code.yaml +17 -19
- package/.github/workflows/_update_release_metadata.yaml +1 -1
- package/.github/workflows/manual_release_stable.yaml +1 -0
- package/.github/workflows/on_master.yaml +2 -0
- package/.husky/pre-commit +13 -0
- package/CHANGELOG.md +11 -3
- package/CONTRIBUTING.md +5 -0
- package/README.md +39 -43
- package/bin/build.ts +138 -87
- package/bin/diff-changes.ts +156 -0
- package/bin/diff-json-schema.ts +50 -0
- package/bin/git.ts +42 -11
- package/bin/github.ts +7 -6
- package/bin/main.ts +21 -11
- package/bin/slack.ts +6 -2
- package/bin/test-report.ts +55 -44
- package/bin/types.ts +56 -59
- package/bin/utils.ts +19 -131
- package/dist/bin/build.d.ts +1 -1
- package/dist/bin/build.d.ts.map +1 -1
- package/dist/bin/build.js +49 -31
- package/dist/bin/build.js.map +1 -1
- package/dist/bin/diff-changes.d.ts +16 -0
- package/dist/bin/diff-changes.d.ts.map +1 -0
- package/dist/bin/diff-changes.js +103 -0
- package/dist/bin/diff-changes.js.map +1 -0
- package/dist/bin/diff-json-schema.d.ts +7 -0
- package/dist/bin/diff-json-schema.d.ts.map +1 -0
- package/dist/bin/diff-json-schema.js +45 -0
- package/dist/bin/diff-json-schema.js.map +1 -0
- package/dist/bin/git.d.ts +8 -3
- package/dist/bin/git.d.ts.map +1 -1
- package/dist/bin/git.js +35 -10
- package/dist/bin/git.js.map +1 -1
- package/dist/bin/github.d.ts +1 -3
- package/dist/bin/github.d.ts.map +1 -1
- package/dist/bin/github.js +5 -5
- package/dist/bin/github.js.map +1 -1
- package/dist/bin/main.js +14 -5
- package/dist/bin/main.js.map +1 -1
- package/dist/bin/slack.d.ts +1 -1
- package/dist/bin/slack.d.ts.map +1 -1
- package/dist/bin/slack.js +1 -1
- package/dist/bin/slack.js.map +1 -1
- package/dist/bin/test-report.d.ts.map +1 -1
- package/dist/bin/test-report.js +9 -3
- package/dist/bin/test-report.js.map +1 -1
- package/dist/bin/types.d.ts +0 -1
- package/dist/bin/types.d.ts.map +1 -1
- package/dist/bin/utils.d.ts +0 -14
- package/dist/bin/utils.d.ts.map +1 -1
- package/dist/bin/utils.js +12 -95
- package/dist/bin/utils.js.map +1 -1
- package/dist/lib/extend-expect.d.ts.map +1 -1
- package/dist/lib/extend-expect.js +11 -11
- package/dist/lib/extend-expect.js.map +1 -1
- package/dist/lib/lib.d.ts +3 -2
- package/dist/lib/lib.d.ts.map +1 -1
- package/dist/lib/lib.js +7 -3
- package/dist/lib/lib.js.map +1 -1
- package/dist/lib/run-test-result.d.ts +1 -1
- package/dist/lib/run-test-result.d.ts.map +1 -1
- package/dist/lib/run-test-result.js.map +1 -1
- package/dist/lib/types.d.ts +2 -3
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +4 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/test/unit/bin/diff-changes.test.d.ts +2 -0
- package/dist/test/unit/bin/diff-changes.test.d.ts.map +1 -0
- package/dist/test/unit/bin/diff-changes.test.js +159 -0
- package/dist/test/unit/bin/diff-changes.test.js.map +1 -0
- package/dist/test/unit/bin/diff.test.d.ts +2 -0
- package/dist/test/unit/bin/diff.test.d.ts.map +1 -0
- package/dist/test/unit/bin/diff.test.js +143 -0
- package/dist/test/unit/bin/diff.test.js.map +1 -0
- package/dist/test/unit/bin/git.test.js +48 -19
- package/dist/test/unit/bin/git.test.js.map +1 -1
- package/dist/test/unit/custom-matchers.test.js +3 -8
- package/dist/test/unit/custom-matchers.test.js.map +1 -1
- package/dist/test/unit/parse-commit.test.js +1 -1
- package/dist/test/unit/parse-commit.test.js.map +1 -1
- package/dist/test/unit/should-built-and-test.test.js +159 -39
- package/dist/test/unit/should-built-and-test.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eslint.config.mjs +4 -2
- package/knip.json +1 -1
- package/lib/extend-expect.ts +21 -21
- package/lib/lib.ts +17 -17
- package/lib/run-test-result.ts +6 -2
- package/lib/types.ts +5 -8
- package/lib/utils.ts +13 -9
- package/package.json +10 -3
- package/test/tsconfig.json +2 -4
- package/test/unit/bin/diff-changes.test.ts +182 -0
- package/test/unit/bin/diff.test.ts +212 -0
- package/test/unit/bin/git.test.ts +59 -20
- package/test/unit/custom-matchers.test.ts +10 -9
- package/test/unit/parse-commit.test.ts +2 -1
- package/test/unit/should-built-and-test.test.ts +181 -40
- package/bin/consts.ts +0 -6
- package/dist/bin/consts.d.ts +0 -4
- package/dist/bin/consts.d.ts.map +0 -1
- package/dist/bin/consts.js +0 -6
- package/dist/bin/consts.js.map +0 -1
- package/example-github-events/pull-request.json +0 -523
- package/example-github-events/push.json +0 -216
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { MockInstance } from 'vitest';
|
|
2
|
+
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
|
2
3
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
4
|
+
import { getChangedActors } from '../../bin/diff-changes.js';
|
|
5
|
+
import * as DiffJsonSchema from '../../bin/diff-json-schema.js';
|
|
6
|
+
import type { ActorConfig, Commit } from '../../bin/types.js';
|
|
5
7
|
|
|
6
8
|
describe('Should build and test parser', () => {
|
|
7
9
|
// From https://github.com/apify-store/testing-repo-for-github-actions
|
|
@@ -23,89 +25,226 @@ describe('Should build and test parser', () => {
|
|
|
23
25
|
},
|
|
24
26
|
];
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
const commits: Commit[] = [
|
|
29
|
+
{ sha: 'Commit1', author: '', date: '', message: '' },
|
|
30
|
+
{ sha: 'Commit3', author: '', date: '', message: '' },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
let isCosmeticOnlyJsonSchemaSpy: MockInstance;
|
|
34
|
+
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
// Default: JSON changes are functional (triggers build/test)
|
|
37
|
+
isCosmeticOnlyJsonSchemaSpy = vi.spyOn(DiffJsonSchema, 'isCosmeticOnlyJsonSchemaChange').mockReturnValue(false);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('Ignores dev-only readme', () => {
|
|
27
41
|
const FILES = ['README.md', 'code/README.md', 'shared/README.md'];
|
|
28
42
|
|
|
29
|
-
const
|
|
43
|
+
const actorsChanged = getChangedActors({
|
|
44
|
+
actorConfigs: ACTOR_CONFIGS,
|
|
45
|
+
isLatest: false,
|
|
46
|
+
filepathsChanged: FILES,
|
|
47
|
+
commits,
|
|
48
|
+
});
|
|
30
49
|
|
|
31
50
|
expect(actorsChanged).toEqual([]);
|
|
32
|
-
expect(codeChanged).toBe(false);
|
|
33
51
|
});
|
|
34
52
|
|
|
35
|
-
test('Ignores other ignored files and folders',
|
|
53
|
+
test('Ignores other ignored files and folders', () => {
|
|
36
54
|
const FILES = ['.vscode/', '.gitignore', '.husky/', '.eslintrc', '.editorconfig', '.actor/'];
|
|
37
55
|
|
|
38
|
-
const
|
|
56
|
+
const actorsChanged = getChangedActors({
|
|
57
|
+
actorConfigs: ACTOR_CONFIGS,
|
|
58
|
+
isLatest: false,
|
|
59
|
+
filepathsChanged: FILES,
|
|
60
|
+
commits,
|
|
61
|
+
});
|
|
39
62
|
|
|
40
63
|
expect(actorsChanged).toEqual([]);
|
|
41
|
-
expect(codeChanged).toBe(false);
|
|
42
64
|
});
|
|
43
65
|
|
|
44
|
-
test('Only builds latest for all Actors',
|
|
66
|
+
test('Only builds latest for all Actors', () => {
|
|
45
67
|
const FILES = ['shared/CHANGELOG.md', 'CHANGELOG.md'];
|
|
46
68
|
|
|
47
|
-
const
|
|
69
|
+
const actorsChanged = getChangedActors({
|
|
70
|
+
actorConfigs: ACTOR_CONFIGS,
|
|
71
|
+
isLatest: true,
|
|
72
|
+
filepathsChanged: FILES,
|
|
73
|
+
commits,
|
|
74
|
+
});
|
|
48
75
|
|
|
49
76
|
expect(actorsChanged).toEqual(ACTOR_CONFIGS.filter(({ isStandalone }) => !isStandalone));
|
|
50
|
-
expect(codeChanged).toBe(false);
|
|
51
77
|
});
|
|
52
78
|
|
|
53
|
-
test('Code updated, tests miniactors',
|
|
79
|
+
test('Code updated, tests miniactors', () => {
|
|
54
80
|
const FILES = ['code/src/main.ts', 'package.json'];
|
|
55
81
|
|
|
56
|
-
const
|
|
82
|
+
const actorsChanged = getChangedActors({
|
|
83
|
+
actorConfigs: ACTOR_CONFIGS,
|
|
84
|
+
isLatest: false,
|
|
85
|
+
filepathsChanged: FILES,
|
|
86
|
+
commits,
|
|
87
|
+
});
|
|
57
88
|
|
|
58
89
|
expect(actorsChanged).toEqual(ACTOR_CONFIGS.filter(({ isStandalone }) => !isStandalone));
|
|
59
|
-
expect(codeChanged).toBe(true);
|
|
60
90
|
});
|
|
61
91
|
|
|
62
|
-
test('Specific Actor functionality configs updated',
|
|
63
|
-
const FILES = [
|
|
92
|
+
test('Specific Actor functionality configs updated', () => {
|
|
93
|
+
const FILES = [
|
|
94
|
+
'actors/lukaskrivka_testing-github-integration-1/.actor/actor.json',
|
|
95
|
+
'standalone-actors/lukaskrivka_test-standalone/Dockerfile',
|
|
96
|
+
];
|
|
97
|
+
// Default mock returns false = functional change
|
|
64
98
|
|
|
65
|
-
const
|
|
99
|
+
const actorsChanged = getChangedActors({
|
|
100
|
+
actorConfigs: ACTOR_CONFIGS,
|
|
101
|
+
isLatest: false,
|
|
102
|
+
filepathsChanged: FILES,
|
|
103
|
+
commits,
|
|
104
|
+
});
|
|
66
105
|
|
|
67
106
|
expect(actorsChanged).toEqual([ACTOR_CONFIGS[0], ACTOR_CONFIGS[2]]);
|
|
68
|
-
expect(codeChanged).toBe(false);
|
|
69
107
|
});
|
|
70
108
|
|
|
71
|
-
test('src/main.ts updated',
|
|
72
|
-
const FILES = [
|
|
73
|
-
'src/main.ts',
|
|
74
|
-
];
|
|
109
|
+
test('src/main.ts updated', () => {
|
|
110
|
+
const FILES = ['src/main.ts'];
|
|
75
111
|
|
|
76
|
-
const
|
|
112
|
+
const actorsChanged = getChangedActors({
|
|
113
|
+
actorConfigs: ACTOR_CONFIGS,
|
|
114
|
+
isLatest: true,
|
|
115
|
+
filepathsChanged: FILES,
|
|
116
|
+
commits,
|
|
117
|
+
});
|
|
77
118
|
|
|
78
119
|
expect(actorsChanged).toEqual(ACTOR_CONFIGS.slice(0, 2));
|
|
79
|
-
expect(codeChanged).toBe(false);
|
|
80
120
|
});
|
|
81
121
|
|
|
82
|
-
test('Miniactor, Code and standalone actor updated,',
|
|
122
|
+
test('Miniactor, Code and standalone actor updated,', () => {
|
|
83
123
|
const FILES = [
|
|
84
124
|
'actors/lukaskrivka_testing-github-integration-1/.actor/actor.json',
|
|
85
125
|
'code/src/main.ts',
|
|
86
126
|
'standalone-actors/lukaskrivka_test-standalone/Dockerfile',
|
|
87
127
|
];
|
|
128
|
+
// Default mock returns false = functional change for the JSON file
|
|
88
129
|
|
|
89
|
-
const
|
|
130
|
+
const actorsChanged = getChangedActors({
|
|
131
|
+
actorConfigs: ACTOR_CONFIGS,
|
|
132
|
+
isLatest: false,
|
|
133
|
+
filepathsChanged: FILES,
|
|
134
|
+
commits,
|
|
135
|
+
});
|
|
90
136
|
|
|
91
137
|
expect(actorsChanged).toEqual(ACTOR_CONFIGS);
|
|
92
|
-
expect(codeChanged).toBe(true);
|
|
93
138
|
});
|
|
94
139
|
|
|
95
|
-
test('Specific Actor non-functional configs updated',
|
|
96
|
-
const FILES = [
|
|
140
|
+
test('Specific Actor non-functional configs updated', () => {
|
|
141
|
+
const FILES = [
|
|
142
|
+
'actors/lukaskrivka_testing-github-integration-2/.actor/README.md',
|
|
143
|
+
'standalone-actors/lukaskrivka_test-standalone/CHANGELOG.md',
|
|
144
|
+
];
|
|
145
|
+
|
|
146
|
+
const actorsChanged = getChangedActors({
|
|
147
|
+
actorConfigs: ACTOR_CONFIGS,
|
|
148
|
+
isLatest: false,
|
|
149
|
+
filepathsChanged: FILES,
|
|
150
|
+
commits,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
expect(actorsChanged).toEqual([]);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test('JSON file with cosmetic-only changes in PR context (isLatest=false) skips tests', () => {
|
|
157
|
+
const FILES = ['actors/lukaskrivka_testing-github-integration-1/.actor/actor.json'];
|
|
158
|
+
isCosmeticOnlyJsonSchemaSpy.mockReturnValue(true);
|
|
159
|
+
|
|
160
|
+
const actorsChanged = getChangedActors({
|
|
161
|
+
actorConfigs: ACTOR_CONFIGS,
|
|
162
|
+
isLatest: false,
|
|
163
|
+
filepathsChanged: FILES,
|
|
164
|
+
commits,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
expect(actorsChanged).toEqual([]);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test('JSON file with cosmetic-only changes in latest context still triggers build', () => {
|
|
171
|
+
const FILES = ['actors/lukaskrivka_testing-github-integration-1/.actor/actor.json'];
|
|
172
|
+
isCosmeticOnlyJsonSchemaSpy.mockReturnValue(true);
|
|
173
|
+
|
|
174
|
+
const actorsChanged = getChangedActors({
|
|
175
|
+
actorConfigs: ACTOR_CONFIGS,
|
|
176
|
+
isLatest: true,
|
|
177
|
+
filepathsChanged: FILES,
|
|
178
|
+
commits,
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
expect(actorsChanged).toEqual([ACTOR_CONFIGS[0]]);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test('JSON file with functional changes triggers tests', () => {
|
|
185
|
+
const FILES = ['actors/lukaskrivka_testing-github-integration-1/.actor/actor.json'];
|
|
186
|
+
// Default mock returns false = functional change
|
|
97
187
|
|
|
98
|
-
const
|
|
188
|
+
const actorsChanged = getChangedActors({
|
|
189
|
+
actorConfigs: ACTOR_CONFIGS,
|
|
190
|
+
isLatest: false,
|
|
191
|
+
filepathsChanged: FILES,
|
|
192
|
+
commits,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
expect(actorsChanged).toEqual([ACTOR_CONFIGS[0]]);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test('Mix: one actor has cosmetic-only JSON change, another has functional JSON change', () => {
|
|
199
|
+
const FILES = [
|
|
200
|
+
'actors/lukaskrivka_testing-github-integration-1/.actor/actor.json',
|
|
201
|
+
'actors/lukaskrivka_testing-github-integration-2/.actor/input_schema.json',
|
|
202
|
+
];
|
|
203
|
+
// Actor 1 JSON is cosmetic-only, actor 2 JSON is functional
|
|
204
|
+
isCosmeticOnlyJsonSchemaSpy.mockImplementation(
|
|
205
|
+
(_commits, filepath: string) => !filepath.includes('input_schema.json'),
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
const actorsChanged = getChangedActors({
|
|
209
|
+
actorConfigs: ACTOR_CONFIGS,
|
|
210
|
+
isLatest: false,
|
|
211
|
+
filepathsChanged: FILES,
|
|
212
|
+
commits,
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// Only the second actor (functional change) should be built and tested
|
|
216
|
+
expect(actorsChanged).toEqual([ACTOR_CONFIGS[1]]);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
test('Standalone actor with cosmetic-only JSON change in PR context skips tests', () => {
|
|
220
|
+
const FILES = ['standalone-actors/lukaskrivka_test-standalone/.actor/actor.json'];
|
|
221
|
+
isCosmeticOnlyJsonSchemaSpy.mockReturnValue(true);
|
|
222
|
+
|
|
223
|
+
const actorsChanged = getChangedActors({
|
|
224
|
+
actorConfigs: ACTOR_CONFIGS,
|
|
225
|
+
isLatest: false,
|
|
226
|
+
filepathsChanged: FILES,
|
|
227
|
+
commits,
|
|
228
|
+
});
|
|
99
229
|
|
|
100
230
|
expect(actorsChanged).toEqual([]);
|
|
101
|
-
expect(codeChanged).toBe(false);
|
|
102
231
|
});
|
|
103
232
|
|
|
104
|
-
test('Google Maps real user-case that had undefined',
|
|
105
|
-
const FILES = [
|
|
106
|
-
'
|
|
107
|
-
'
|
|
108
|
-
'code/src/
|
|
233
|
+
test('Google Maps real user-case that had undefined', () => {
|
|
234
|
+
const FILES = [
|
|
235
|
+
'actors/compass_Google-Maps-Reviews-Scraper/.actor/INPUT_SCHEMA.json',
|
|
236
|
+
'actors/compass_crawler-google-places/.actor/INPUT_SCHEMA.json',
|
|
237
|
+
'code/src/consts.ts',
|
|
238
|
+
'code/src/crawlers/cheerio/routes.ts',
|
|
239
|
+
'code/src/detail_page_handle.ts',
|
|
240
|
+
'code/src/enqueue_places.ts',
|
|
241
|
+
'code/src/helper-classes/initialize-all.ts',
|
|
242
|
+
'code/src/helper-classes/stats.ts',
|
|
243
|
+
'code/src/helper-classes/unmatched-categories.ts',
|
|
244
|
+
'code/src/main.ts',
|
|
245
|
+
'code/src/typedefs/general.ts',
|
|
246
|
+
'code/src/utils/background-enqueue.ts',
|
|
247
|
+
];
|
|
109
248
|
|
|
110
249
|
const ACTOR_CONFIGS_GOOGLE_MAPS: ActorConfig[] = [
|
|
111
250
|
{
|
|
@@ -156,11 +295,13 @@ describe('Should build and test parser', () => {
|
|
|
156
295
|
},
|
|
157
296
|
];
|
|
158
297
|
|
|
159
|
-
const
|
|
160
|
-
actorConfigs: ACTOR_CONFIGS_GOOGLE_MAPS,
|
|
298
|
+
const actorsChanged = getChangedActors({
|
|
299
|
+
actorConfigs: ACTOR_CONFIGS_GOOGLE_MAPS,
|
|
300
|
+
isLatest: false,
|
|
301
|
+
filepathsChanged: FILES,
|
|
302
|
+
commits,
|
|
161
303
|
});
|
|
162
304
|
|
|
163
305
|
expect(actorsChanged).toEqual(ACTOR_CONFIGS_GOOGLE_MAPS.filter(({ isStandalone }) => !isStandalone));
|
|
164
|
-
expect(codeChanged).toBe(true);
|
|
165
306
|
});
|
|
166
307
|
});
|
package/bin/consts.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// Technically, upgrades in shared or packages might not need impact every actor
|
|
2
|
-
// but we cannot really know that
|
|
3
|
-
export const DEFAULT_BUILD_ALL_FOLDERS = ['code', 'shared', 'packages'];
|
|
4
|
-
|
|
5
|
-
export const PERSISTED_GH_JOBS_KVS_ID = 'XIBdO8EJePdD0KiAI';
|
|
6
|
-
export const MINIACTORS_LIST_STORE_ID = 'ftXklt2f2mN30Oc3y';
|
package/dist/bin/consts.d.ts
DELETED
package/dist/bin/consts.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../bin/consts.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,yBAAyB,UAAiC,CAAC;AAExE,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAC5D,eAAO,MAAM,wBAAwB,sBAAsB,CAAC"}
|
package/dist/bin/consts.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// Technically, upgrades in shared or packages might not need impact every actor
|
|
2
|
-
// but we cannot really know that
|
|
3
|
-
export const DEFAULT_BUILD_ALL_FOLDERS = ['code', 'shared', 'packages'];
|
|
4
|
-
export const PERSISTED_GH_JOBS_KVS_ID = 'XIBdO8EJePdD0KiAI';
|
|
5
|
-
export const MINIACTORS_LIST_STORE_ID = 'ftXklt2f2mN30Oc3y';
|
|
6
|
-
//# sourceMappingURL=consts.js.map
|
package/dist/bin/consts.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../../bin/consts.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,iCAAiC;AACjC,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AAExE,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAC5D,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC"}
|