apify-test-tools 0.10.2-beta.3 → 0.10.2-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/.github/cli/apify-test-tools.mjs +117 -118
- package/.github/scripts/run-with-apify-tokens.mjs +1 -1
- package/.github/workflows/public_pr-build-test.yaml +25 -25
- package/.github/workflows/public_push-build-latest.yaml +20 -4
- package/CHANGELOG.md +6 -0
- package/CONTRIBUTING.md +4 -1
- package/README.md +104 -56
- package/bin/affected-actors.ts +135 -103
- package/bin/build.ts +53 -38
- package/bin/diff-changes.ts +7 -6
- package/bin/diff-json-schema.ts +5 -6
- package/bin/git.ts +24 -69
- package/bin/main.ts +46 -80
- package/bin/slack.ts +15 -4
- package/bin/stdin-input.ts +65 -0
- package/bin/types.ts +6 -0
- package/dist/bin/affected-actors.d.ts +23 -27
- package/dist/bin/affected-actors.d.ts.map +1 -1
- package/dist/bin/affected-actors.js +111 -65
- package/dist/bin/affected-actors.js.map +1 -1
- package/dist/bin/build.d.ts +11 -5
- package/dist/bin/build.d.ts.map +1 -1
- package/dist/bin/build.js +43 -23
- package/dist/bin/build.js.map +1 -1
- package/dist/bin/diff-changes.d.ts +4 -3
- package/dist/bin/diff-changes.d.ts.map +1 -1
- package/dist/bin/diff-changes.js +4 -4
- package/dist/bin/diff-changes.js.map +1 -1
- package/dist/bin/diff-json-schema.d.ts +2 -2
- package/dist/bin/diff-json-schema.d.ts.map +1 -1
- package/dist/bin/diff-json-schema.js +1 -4
- package/dist/bin/diff-json-schema.js.map +1 -1
- package/dist/bin/git.d.ts +7 -15
- package/dist/bin/git.d.ts.map +1 -1
- package/dist/bin/git.js +23 -61
- package/dist/bin/git.js.map +1 -1
- package/dist/bin/main.js +39 -71
- package/dist/bin/main.js.map +1 -1
- package/dist/bin/slack.d.ts +6 -3
- package/dist/bin/slack.d.ts.map +1 -1
- package/dist/bin/slack.js +13 -1
- package/dist/bin/slack.js.map +1 -1
- package/dist/bin/stdin-input.d.ts +17 -0
- package/dist/bin/stdin-input.d.ts.map +1 -0
- package/dist/bin/stdin-input.js +54 -0
- package/dist/bin/stdin-input.js.map +1 -0
- package/dist/bin/types.d.ts +5 -0
- package/dist/bin/types.d.ts.map +1 -1
- package/dist/test/bundle/cli-bundle.test.js +32 -11
- package/dist/test/bundle/cli-bundle.test.js.map +1 -1
- package/dist/test/e2e/cli-bundle.e2e.test.js +23 -57
- package/dist/test/e2e/cli-bundle.e2e.test.js.map +1 -1
- package/dist/test/e2e/git-build-release.e2e.test.d.ts +2 -0
- package/dist/test/e2e/git-build-release.e2e.test.d.ts.map +1 -0
- package/dist/test/e2e/git-build-release.e2e.test.js +87 -0
- package/dist/test/e2e/git-build-release.e2e.test.js.map +1 -0
- package/dist/test/e2e/helpers.d.ts +37 -0
- package/dist/test/e2e/helpers.d.ts.map +1 -0
- package/dist/test/e2e/helpers.js +57 -0
- package/dist/test/e2e/helpers.js.map +1 -0
- package/dist/test/unit/bin/affected-actors-cli.test.d.ts +2 -0
- package/dist/test/unit/bin/affected-actors-cli.test.d.ts.map +1 -0
- package/dist/test/unit/bin/affected-actors-cli.test.js +161 -0
- package/dist/test/unit/bin/affected-actors-cli.test.js.map +1 -0
- package/dist/test/unit/bin/affected-actors.test.js +68 -87
- package/dist/test/unit/bin/affected-actors.test.js.map +1 -1
- package/dist/test/unit/bin/build-cli.test.d.ts +2 -0
- package/dist/test/unit/bin/build-cli.test.d.ts.map +1 -0
- package/dist/test/unit/bin/build-cli.test.js +44 -0
- package/dist/test/unit/bin/build-cli.test.js.map +1 -0
- package/dist/test/unit/bin/build.test.js +61 -4
- package/dist/test/unit/bin/build.test.js.map +1 -1
- package/dist/test/unit/bin/compiled-cli.d.ts +6 -0
- package/dist/test/unit/bin/compiled-cli.d.ts.map +1 -0
- package/dist/test/unit/bin/compiled-cli.js +16 -0
- package/dist/test/unit/bin/compiled-cli.js.map +1 -0
- package/dist/test/unit/bin/diff-changes.test.js +55 -55
- package/dist/test/unit/bin/diff-changes.test.js.map +1 -1
- package/dist/test/unit/bin/diff.test.js +25 -28
- package/dist/test/unit/bin/diff.test.js.map +1 -1
- package/dist/test/unit/bin/git.test.js +28 -108
- package/dist/test/unit/bin/git.test.js.map +1 -1
- package/dist/test/unit/bin/slack.test.js +19 -2
- package/dist/test/unit/bin/slack.test.js.map +1 -1
- package/dist/test/unit/bin/stdin-input.test.d.ts +2 -0
- package/dist/test/unit/bin/stdin-input.test.d.ts.map +1 -0
- package/dist/test/unit/bin/stdin-input.test.js +50 -0
- package/dist/test/unit/bin/stdin-input.test.js.map +1 -0
- package/dist/test/unit/should-built-and-test.test.js +18 -21
- 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/bundle/cli-bundle.test.ts +47 -11
- package/test/e2e/cli-bundle.e2e.test.ts +47 -77
- package/test/e2e/git-build-release.e2e.test.ts +113 -0
- package/test/e2e/helpers.ts +82 -0
- package/test/unit/bin/affected-actors-cli.test.ts +193 -0
- package/test/unit/bin/affected-actors.test.ts +86 -94
- package/test/unit/bin/build-cli.test.ts +55 -0
- package/test/unit/bin/build.test.ts +71 -3
- package/test/unit/bin/compiled-cli.ts +17 -0
- package/test/unit/bin/diff-changes.test.ts +55 -55
- package/test/unit/bin/diff.test.ts +25 -28
- package/test/unit/bin/git.test.ts +35 -132
- package/test/unit/bin/slack.test.ts +21 -2
- package/test/unit/bin/stdin-input.test.ts +61 -0
- package/test/unit/should-built-and-test.test.ts +19 -22
|
@@ -2,17 +2,15 @@ import type { MockInstance } from 'vitest';
|
|
|
2
2
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
findCommitSha,
|
|
6
6
|
getChangedFiles,
|
|
7
7
|
getChangedFilesBetween,
|
|
8
8
|
getCommits,
|
|
9
9
|
getCommitsBetween,
|
|
10
10
|
getCurrentBranch,
|
|
11
11
|
getRepoName,
|
|
12
|
-
hasMergeFromTarget,
|
|
13
12
|
normalizeRepoUrl,
|
|
14
13
|
parseBaseCommit,
|
|
15
|
-
resolveBranchName,
|
|
16
14
|
resolveCommitSha,
|
|
17
15
|
resolveReleaseBaseCommit,
|
|
18
16
|
resolveRepoUrl,
|
|
@@ -170,124 +168,6 @@ describe('getChangedFiles', () => {
|
|
|
170
168
|
});
|
|
171
169
|
});
|
|
172
170
|
|
|
173
|
-
describe('hasMergeFromTarget', () => {
|
|
174
|
-
const sourceBranch = 'feature-branch';
|
|
175
|
-
const targetBranch = 'main';
|
|
176
|
-
const mergeSha = 'f'.repeat(40);
|
|
177
|
-
const branchParentSha = 'b'.repeat(40);
|
|
178
|
-
const targetParentSha = 't'.repeat(40);
|
|
179
|
-
const differentMergeBase = '0'.repeat(40);
|
|
180
|
-
|
|
181
|
-
let gitCommandSpy: MockInstance;
|
|
182
|
-
|
|
183
|
-
beforeEach(() => {
|
|
184
|
-
gitCommandSpy = vi.spyOn(Utils, 'runGitCommand');
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it('should return false when there are no merge commits on the branch', async () => {
|
|
188
|
-
gitCommandSpy.mockImplementation(async (args: string[]) => {
|
|
189
|
-
if (args.includes('--merges')) return '';
|
|
190
|
-
return '';
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
await expect(hasMergeFromTarget(sourceBranch, targetBranch)).resolves.toBe(false);
|
|
194
|
-
expect(gitCommandSpy).toHaveBeenCalledWith(
|
|
195
|
-
['log', '--merges', '--pretty=format:%H', `${targetBranch}..${sourceBranch}`],
|
|
196
|
-
{ operation: 'find merge commits on the source branch that are absent from the target branch' },
|
|
197
|
-
);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it('should return true when a merge commit has a parent reachable from targetBranch', async () => {
|
|
201
|
-
gitCommandSpy.mockImplementation(async (args: string[]) => {
|
|
202
|
-
if (args.includes('--merges')) return mergeSha;
|
|
203
|
-
if (args.includes('--pretty=format:%P')) return `${branchParentSha} ${targetParentSha}`;
|
|
204
|
-
if (args[0] === 'merge-base' && args[1] === branchParentSha) return differentMergeBase;
|
|
205
|
-
if (args[0] === 'merge-base' && args[1] === targetParentSha) return targetParentSha;
|
|
206
|
-
return '';
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
await expect(hasMergeFromTarget(sourceBranch, targetBranch)).resolves.toBe(true);
|
|
210
|
-
expect(gitCommandSpy).toHaveBeenCalledWith(['merge-base', targetParentSha, targetBranch], {
|
|
211
|
-
operation: 'check whether a merge parent is reachable from the target branch',
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
it('should return false when the merge commit parent is not reachable from targetBranch (unrelated branch merge)', async () => {
|
|
216
|
-
const unrelatedSha = 'e'.repeat(40);
|
|
217
|
-
gitCommandSpy.mockImplementation(async (args: string[]) => {
|
|
218
|
-
if (args.includes('--merges')) return mergeSha;
|
|
219
|
-
if (args.includes('--pretty=format:%P')) return `${branchParentSha} ${unrelatedSha}`;
|
|
220
|
-
// merge-base returns something other than the parent — not an ancestor
|
|
221
|
-
if (args[0] === 'merge-base') return differentMergeBase;
|
|
222
|
-
return '';
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
await expect(hasMergeFromTarget(sourceBranch, targetBranch)).resolves.toBe(false);
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it('continues after merge-base reports unrelated histories', async () => {
|
|
229
|
-
gitCommandSpy.mockImplementation(async (args: string[]) => {
|
|
230
|
-
if (args.includes('--merges')) return mergeSha;
|
|
231
|
-
if (args.includes('--pretty=format:%P')) return `${branchParentSha} ${targetParentSha}`;
|
|
232
|
-
if (args[0] === 'merge-base' && args[1] === branchParentSha) {
|
|
233
|
-
throw new Utils.GitCommandError(args, Object.assign(new Error('no common ancestor'), { code: 1 }));
|
|
234
|
-
}
|
|
235
|
-
if (args[0] === 'merge-base' && args[1] === targetParentSha) return targetParentSha;
|
|
236
|
-
return '';
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
await expect(hasMergeFromTarget(sourceBranch, targetBranch)).resolves.toBe(true);
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
it('propagates unexpected Git failures', async () => {
|
|
243
|
-
gitCommandSpy.mockImplementation(
|
|
244
|
-
async (args: string[], options?: Parameters<typeof Utils.runGitCommand>[1]) => {
|
|
245
|
-
if (args.includes('--merges')) return mergeSha;
|
|
246
|
-
if (args.includes('--pretty=format:%P')) return `${branchParentSha} ${targetParentSha}`;
|
|
247
|
-
throw new Utils.GitCommandError(
|
|
248
|
-
args,
|
|
249
|
-
Object.assign(new Error('Git failed'), { code: 128 }),
|
|
250
|
-
options?.operation,
|
|
251
|
-
);
|
|
252
|
-
},
|
|
253
|
-
);
|
|
254
|
-
|
|
255
|
-
await expect(hasMergeFromTarget(sourceBranch, targetBranch)).rejects.toThrow(
|
|
256
|
-
'Failed to check whether a merge parent is reachable from the target branch.\n' +
|
|
257
|
-
'Command: git "merge-base"',
|
|
258
|
-
);
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
describe('getBranchOnlyChangedFiles', () => {
|
|
263
|
-
const sourceBranch = 'feature-branch';
|
|
264
|
-
const targetBranch = 'main';
|
|
265
|
-
|
|
266
|
-
let gitCommandSpy: MockInstance;
|
|
267
|
-
|
|
268
|
-
beforeEach(() => {
|
|
269
|
-
gitCommandSpy = vi.spyOn(Utils, 'runGitCommand');
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
it('should return files touched by non-merge commits', async () => {
|
|
273
|
-
gitCommandSpy.mockResolvedValue('README.md\n\nactors/foo_bar/src/main.ts\n');
|
|
274
|
-
|
|
275
|
-
const result = await getBranchOnlyChangedFiles(sourceBranch, targetBranch);
|
|
276
|
-
|
|
277
|
-
expect(result).toStrictEqual(['README.md', 'actors/foo_bar/src/main.ts']);
|
|
278
|
-
expect(gitCommandSpy).toHaveBeenCalledWith(
|
|
279
|
-
['log', '--no-merges', '--name-only', '--pretty=format:', `${targetBranch}..${sourceBranch}`],
|
|
280
|
-
{ operation: 'list files changed by non-merge commits on the source branch' },
|
|
281
|
-
);
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
it('should return empty array when there are no non-merge commits', async () => {
|
|
285
|
-
gitCommandSpy.mockResolvedValue('');
|
|
286
|
-
|
|
287
|
-
await expect(getBranchOnlyChangedFiles(sourceBranch, targetBranch)).resolves.toStrictEqual([]);
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
|
|
291
171
|
const VALID_SHA = 'a'.repeat(40);
|
|
292
172
|
const VALID_JSON = JSON.stringify({ sha: VALID_SHA, author: 'test', date: 'now', message: 'msg' });
|
|
293
173
|
|
|
@@ -323,7 +203,7 @@ describe('getCurrentBranch', () => {
|
|
|
323
203
|
const gitCommandSpy = vi.spyOn(Utils, 'runGitCommand').mockResolvedValue('master');
|
|
324
204
|
await expect(getCurrentBranch()).resolves.toBe('master');
|
|
325
205
|
expect(gitCommandSpy).toHaveBeenCalledWith(['rev-parse', '--abbrev-ref', 'HEAD'], {
|
|
326
|
-
operation: 'determine the
|
|
206
|
+
operation: 'determine the checked-out branch',
|
|
327
207
|
});
|
|
328
208
|
});
|
|
329
209
|
|
|
@@ -507,6 +387,22 @@ describe('getCommitsBetween', () => {
|
|
|
507
387
|
});
|
|
508
388
|
});
|
|
509
389
|
});
|
|
390
|
+
describe('empty commit ranges', () => {
|
|
391
|
+
// Real git on this repository's own history: HEAD..HEAD has no commits
|
|
392
|
+
beforeEach(() => {
|
|
393
|
+
vi.restoreAllMocks();
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
it('getCommitsBetween returns no commits', async () => {
|
|
397
|
+
await expect(getCommitsBetween('HEAD', 'HEAD')).resolves.toStrictEqual([]);
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
it('getCommits fails clearly, since the commands built on it need at least one commit', async () => {
|
|
401
|
+
await expect(getCommits({ sourceBranch: 'HEAD', targetBranch: 'HEAD' })).rejects.toThrow(
|
|
402
|
+
'HEAD has no commits that are not on HEAD.',
|
|
403
|
+
);
|
|
404
|
+
});
|
|
405
|
+
});
|
|
510
406
|
|
|
511
407
|
describe('getChangedFilesBetween', () => {
|
|
512
408
|
it('diffs the two endpoints directly', async () => {
|
|
@@ -533,15 +429,22 @@ describe('resolveCommitSha', () => {
|
|
|
533
429
|
});
|
|
534
430
|
});
|
|
535
431
|
|
|
536
|
-
describe('
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
432
|
+
describe('findCommitSha', () => {
|
|
433
|
+
// Real git on this repository's own history, since what matters is how git answers
|
|
434
|
+
beforeEach(() => {
|
|
435
|
+
vi.restoreAllMocks();
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
it('resolves a ref in the local history to its commit', async () => {
|
|
439
|
+
await expect(findCommitSha('HEAD')).resolves.toMatch(/^[0-9a-f]{40}$/);
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
it('returns undefined for a commit missing from the local history', async () => {
|
|
443
|
+
await expect(findCommitSha('d'.repeat(40))).resolves.toBeUndefined();
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
it('rethrows other git failures', async () => {
|
|
447
|
+
vi.spyOn(Utils, 'runGitCommand').mockRejectedValue(new Error('not a git repository'));
|
|
448
|
+
await expect(findCommitSha('HEAD')).rejects.toThrow('not a git repository');
|
|
546
449
|
});
|
|
547
450
|
});
|
|
@@ -11,11 +11,10 @@ const authTest = vi.fn();
|
|
|
11
11
|
|
|
12
12
|
const notify = async (overrides: Partial<Parameters<typeof notifyToSlack>[0]> = {}) =>
|
|
13
13
|
notifyToSlack({
|
|
14
|
-
|
|
14
|
+
repoUrl: 'git@github.com:owner/repo',
|
|
15
15
|
changedFiles: ['src/main.ts'],
|
|
16
16
|
changelog: '- Fixed a bug',
|
|
17
17
|
commits: [{ sha: '1', author: 'Test<test@example.com>', date: '', message: 'fix: bug' }],
|
|
18
|
-
author: 'Test<test@example.com>',
|
|
19
18
|
dryRun: true,
|
|
20
19
|
releaseSlackChannel: '#releases',
|
|
21
20
|
reportSlackChannel: '#notif',
|
|
@@ -62,4 +61,24 @@ describe('notifyToSlack', () => {
|
|
|
62
61
|
expect(authTest).not.toHaveBeenCalled();
|
|
63
62
|
expect(postMessage).toHaveBeenCalledTimes(2);
|
|
64
63
|
});
|
|
64
|
+
|
|
65
|
+
it('should announce nothing, and need no token, when there are no new commits', async () => {
|
|
66
|
+
vi.stubEnv(TOKEN_ENV_VAR, '');
|
|
67
|
+
await notify({ commits: [], dryRun: false });
|
|
68
|
+
expect(WebClient).not.toHaveBeenCalled();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should announce the release by the author of the newest commit, named after the repository', async () => {
|
|
72
|
+
const commit = (author: string, message: string) => ({ sha: '1', author, date: '', message });
|
|
73
|
+
await notify({
|
|
74
|
+
commits: [commit('Old<old@example.com>', 'fix: older'), commit('New<new@example.com>', 'feat: newer')],
|
|
75
|
+
repoUrl: 'git@github.com:owner/my-repo',
|
|
76
|
+
dryRun: false,
|
|
77
|
+
releaseSlackChannel: undefined,
|
|
78
|
+
});
|
|
79
|
+
expect(postMessage).toHaveBeenCalledWith({
|
|
80
|
+
channel: '#notif',
|
|
81
|
+
text: expect.stringContaining('*my-repo* – New release (by New)'),
|
|
82
|
+
});
|
|
83
|
+
});
|
|
65
84
|
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { parseBuildInput, parseReleaseChanges } from '../../../bin/stdin-input.js';
|
|
4
|
+
|
|
5
|
+
describe('parseBuildInput', () => {
|
|
6
|
+
it('reads the Actors', () => {
|
|
7
|
+
expect(parseBuildInput('{"actors":[{"actorFullName":"owner/a"}]}')).toStrictEqual({
|
|
8
|
+
actors: [{ actorFullName: 'owner/a' }],
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('ignores the other fields, so whole get-affected-actors fields can be passed along', () => {
|
|
13
|
+
const input = { head: 'f'.repeat(40), ref: 'feature', actors: [{ actorFullName: 'owner/a', extra: 1 }] };
|
|
14
|
+
expect(parseBuildInput(JSON.stringify(input))).toStrictEqual({ actors: [{ actorFullName: 'owner/a' }] });
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('accepts an empty list, which builds nothing', () => {
|
|
18
|
+
expect(parseBuildInput('{"actors":[]}')).toStrictEqual({ actors: [] });
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('rejects empty input, which is what a failed command earlier in a pipe leaves behind', () => {
|
|
22
|
+
expect(() => parseBuildInput(' \n')).toThrow('Expected the Actors to build as JSON on stdin, got nothing');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('rejects input that is not JSON', () => {
|
|
26
|
+
expect(() => parseBuildInput('owner/a')).toThrow('not valid JSON');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('rejects JSON that is not a list of Actors, e.g. a whole get-affected-actors document', () => {
|
|
30
|
+
expect(() => parseBuildInput('{"functionallyChangedActors":[{"actorFullName":"owner/a"}]}')).toThrow(
|
|
31
|
+
'is not the Actors to build',
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('parseReleaseChanges', () => {
|
|
37
|
+
const commit = { sha: '1'.repeat(40), author: 'Dev<dev@example.com>', date: 'Date', message: 'feat: foo' };
|
|
38
|
+
|
|
39
|
+
it('reads what changed from a get-affected-actors document, ignoring the rest', () => {
|
|
40
|
+
const document = {
|
|
41
|
+
version: 1,
|
|
42
|
+
ref: 'master',
|
|
43
|
+
head: '1'.repeat(40),
|
|
44
|
+
commits: [commit],
|
|
45
|
+
changedFiles: ['src/main.ts'],
|
|
46
|
+
changelog: '- Added foo',
|
|
47
|
+
functionallyChangedActors: [{ actorFullName: 'owner/a' }],
|
|
48
|
+
cosmeticallyChangedActors: [],
|
|
49
|
+
};
|
|
50
|
+
expect(parseReleaseChanges(JSON.stringify(document))).toStrictEqual({
|
|
51
|
+
commits: [commit],
|
|
52
|
+
changedFiles: ['src/main.ts'],
|
|
53
|
+
changelog: '- Added foo',
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('rejects empty input and input that is not a get-affected-actors document', () => {
|
|
58
|
+
expect(() => parseReleaseChanges('')).toThrow('got nothing');
|
|
59
|
+
expect(() => parseReleaseChanges('{"actors":[]}')).toThrow('not the output of get-affected-actors');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -5,7 +5,7 @@ import path from 'node:path';
|
|
|
5
5
|
import { afterAll, describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { getChangedActors } from '../../bin/diff-changes.js';
|
|
8
|
-
import type { ActorConfig
|
|
8
|
+
import type { ActorConfig } from '../../bin/types.js';
|
|
9
9
|
import { ExistingDir, ExistingFile, RelativeDir, RelativeFile } from '../../bin/utils/path/repo-relative.js';
|
|
10
10
|
|
|
11
11
|
const originalCwd = process.cwd();
|
|
@@ -72,10 +72,7 @@ describe('Should build and test parser', () => {
|
|
|
72
72
|
),
|
|
73
73
|
];
|
|
74
74
|
|
|
75
|
-
const
|
|
76
|
-
{ sha: 'Commit1', author: '', date: '', message: '' },
|
|
77
|
-
{ sha: 'Commit3', author: '', date: '', message: '' },
|
|
78
|
-
];
|
|
75
|
+
const range = { fromRef: 'Commit0', toRef: 'Commit3' };
|
|
79
76
|
|
|
80
77
|
test('Ignores dev-only readme', async () => {
|
|
81
78
|
const FILES = ['README.md', 'code/README.md', 'shared/README.md'];
|
|
@@ -84,7 +81,7 @@ describe('Should build and test parser', () => {
|
|
|
84
81
|
actorConfigs: ACTOR_CONFIGS,
|
|
85
82
|
isLatest: false,
|
|
86
83
|
filepathsChanged: FILES,
|
|
87
|
-
|
|
84
|
+
range,
|
|
88
85
|
});
|
|
89
86
|
|
|
90
87
|
expect(actorsChanged).toEqual([]);
|
|
@@ -97,7 +94,7 @@ describe('Should build and test parser', () => {
|
|
|
97
94
|
actorConfigs: ACTOR_CONFIGS,
|
|
98
95
|
isLatest: false,
|
|
99
96
|
filepathsChanged: FILES,
|
|
100
|
-
|
|
97
|
+
range,
|
|
101
98
|
});
|
|
102
99
|
|
|
103
100
|
expect(actorsChanged).toEqual([]);
|
|
@@ -110,7 +107,7 @@ describe('Should build and test parser', () => {
|
|
|
110
107
|
actorConfigs: ACTOR_CONFIGS,
|
|
111
108
|
isLatest: false,
|
|
112
109
|
filepathsChanged: FILES,
|
|
113
|
-
|
|
110
|
+
range,
|
|
114
111
|
});
|
|
115
112
|
|
|
116
113
|
expect(actorsChanged).toEqual(ACTOR_CONFIGS.slice(0, 2));
|
|
@@ -123,7 +120,7 @@ describe('Should build and test parser', () => {
|
|
|
123
120
|
actorConfigs: ACTOR_CONFIGS,
|
|
124
121
|
isLatest: false,
|
|
125
122
|
filepathsChanged: FILES,
|
|
126
|
-
|
|
123
|
+
range,
|
|
127
124
|
});
|
|
128
125
|
expect(actorsChangedNotLatest).toEqual([]);
|
|
129
126
|
|
|
@@ -131,7 +128,7 @@ describe('Should build and test parser', () => {
|
|
|
131
128
|
actorConfigs: ACTOR_CONFIGS,
|
|
132
129
|
isLatest: true,
|
|
133
130
|
filepathsChanged: FILES,
|
|
134
|
-
|
|
131
|
+
range,
|
|
135
132
|
});
|
|
136
133
|
expect(actorsChangedLatest).toEqual(ACTOR_CONFIGS);
|
|
137
134
|
});
|
|
@@ -143,7 +140,7 @@ describe('Should build and test parser', () => {
|
|
|
143
140
|
actorConfigs: ACTOR_CONFIGS,
|
|
144
141
|
isLatest: true,
|
|
145
142
|
filepathsChanged: FILES,
|
|
146
|
-
|
|
143
|
+
range,
|
|
147
144
|
});
|
|
148
145
|
|
|
149
146
|
expect(actorsChanged).toEqual([ACTOR_CONFIGS[0]]);
|
|
@@ -156,7 +153,7 @@ describe('Should build and test parser', () => {
|
|
|
156
153
|
actorConfigs: ACTOR_CONFIGS,
|
|
157
154
|
isLatest: false,
|
|
158
155
|
filepathsChanged: FILES,
|
|
159
|
-
|
|
156
|
+
range,
|
|
160
157
|
});
|
|
161
158
|
|
|
162
159
|
expect(actorsChanged).toEqual(ACTOR_CONFIGS.slice(0, 2));
|
|
@@ -172,7 +169,7 @@ describe('Should build and test parser', () => {
|
|
|
172
169
|
actorConfigs: ACTOR_CONFIGS,
|
|
173
170
|
isLatest: false,
|
|
174
171
|
filepathsChanged: FILES,
|
|
175
|
-
|
|
172
|
+
range,
|
|
176
173
|
});
|
|
177
174
|
|
|
178
175
|
expect(actorsChanged).toEqual([ACTOR_CONFIGS[0], ACTOR_CONFIGS[2]]);
|
|
@@ -185,7 +182,7 @@ describe('Should build and test parser', () => {
|
|
|
185
182
|
actorConfigs: ACTOR_CONFIGS,
|
|
186
183
|
isLatest: true,
|
|
187
184
|
filepathsChanged: FILES,
|
|
188
|
-
|
|
185
|
+
range,
|
|
189
186
|
});
|
|
190
187
|
|
|
191
188
|
expect(actorsChanged).toEqual(ACTOR_CONFIGS.slice(0, 2));
|
|
@@ -202,7 +199,7 @@ describe('Should build and test parser', () => {
|
|
|
202
199
|
actorConfigs: ACTOR_CONFIGS,
|
|
203
200
|
isLatest: false,
|
|
204
201
|
filepathsChanged: FILES,
|
|
205
|
-
|
|
202
|
+
range,
|
|
206
203
|
});
|
|
207
204
|
|
|
208
205
|
expect(actorsChanged).toEqual(ACTOR_CONFIGS);
|
|
@@ -218,7 +215,7 @@ describe('Should build and test parser', () => {
|
|
|
218
215
|
actorConfigs: ACTOR_CONFIGS,
|
|
219
216
|
isLatest: false,
|
|
220
217
|
filepathsChanged: FILES,
|
|
221
|
-
|
|
218
|
+
range,
|
|
222
219
|
});
|
|
223
220
|
|
|
224
221
|
expect(actorsChanged).toEqual([]);
|
|
@@ -231,7 +228,7 @@ describe('Should build and test parser', () => {
|
|
|
231
228
|
actorConfigs: ACTOR_CONFIGS,
|
|
232
229
|
isLatest: false,
|
|
233
230
|
filepathsChanged: FILES,
|
|
234
|
-
|
|
231
|
+
range,
|
|
235
232
|
});
|
|
236
233
|
|
|
237
234
|
expect(actorsChanged).toEqual([ACTOR_CONFIGS[0]]);
|
|
@@ -244,7 +241,7 @@ describe('Should build and test parser', () => {
|
|
|
244
241
|
actorConfigs: ACTOR_CONFIGS,
|
|
245
242
|
isLatest: true,
|
|
246
243
|
filepathsChanged: FILES,
|
|
247
|
-
|
|
244
|
+
range,
|
|
248
245
|
});
|
|
249
246
|
|
|
250
247
|
expect(actorsChanged).toEqual([ACTOR_CONFIGS[0]]);
|
|
@@ -257,7 +254,7 @@ describe('Should build and test parser', () => {
|
|
|
257
254
|
actorConfigs: ACTOR_CONFIGS,
|
|
258
255
|
isLatest: false,
|
|
259
256
|
filepathsChanged: FILES,
|
|
260
|
-
|
|
257
|
+
range,
|
|
261
258
|
});
|
|
262
259
|
|
|
263
260
|
expect(actorsChanged).toEqual([ACTOR_CONFIGS[0]]);
|
|
@@ -273,7 +270,7 @@ describe('Should build and test parser', () => {
|
|
|
273
270
|
actorConfigs: ACTOR_CONFIGS,
|
|
274
271
|
isLatest: false,
|
|
275
272
|
filepathsChanged: FILES,
|
|
276
|
-
|
|
273
|
+
range,
|
|
277
274
|
});
|
|
278
275
|
|
|
279
276
|
expect(actorsChanged).toEqual(ACTOR_CONFIGS.slice(0, 2));
|
|
@@ -286,7 +283,7 @@ describe('Should build and test parser', () => {
|
|
|
286
283
|
actorConfigs: ACTOR_CONFIGS,
|
|
287
284
|
isLatest: false,
|
|
288
285
|
filepathsChanged: FILES,
|
|
289
|
-
|
|
286
|
+
range,
|
|
290
287
|
});
|
|
291
288
|
|
|
292
289
|
expect(actorsChanged).toEqual([ACTOR_CONFIGS[2]]);
|
|
@@ -345,7 +342,7 @@ describe('Should build and test parser', () => {
|
|
|
345
342
|
actorConfigs: ACTOR_CONFIGS_GOOGLE_MAPS,
|
|
346
343
|
isLatest: false,
|
|
347
344
|
filepathsChanged: FILES,
|
|
348
|
-
|
|
345
|
+
range,
|
|
349
346
|
});
|
|
350
347
|
|
|
351
348
|
expect(actorsChanged).toEqual(ACTOR_CONFIGS_GOOGLE_MAPS.slice(0, 8));
|