apify-test-tools 0.5.7-beta.4 → 0.5.7-beta.6
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 -18
- package/.husky/pre-commit +13 -0
- package/CHANGELOG.md +4 -2
- package/CONTRIBUTING.md +5 -0
- package/README.md +39 -43
- package/bin/build.ts +138 -87
- package/bin/diff-changes.ts +52 -23
- package/bin/diff-json-schema.ts +10 -3
- package/bin/git.ts +31 -9
- package/bin/github.ts +7 -6
- package/bin/main.ts +14 -8
- package/bin/slack.ts +6 -2
- package/bin/test-report.ts +55 -44
- package/bin/types.ts +56 -59
- package/bin/utils.ts +17 -12
- 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 +1 -1
- package/dist/bin/diff-changes.d.ts.map +1 -1
- package/dist/bin/diff-changes.js +15 -3
- package/dist/bin/diff-changes.js.map +1 -1
- package/dist/bin/diff-json-schema.d.ts.map +1 -1
- package/dist/bin/diff-json-schema.js +6 -1
- package/dist/bin/diff-json-schema.js.map +1 -1
- package/dist/bin/git.d.ts +7 -2
- package/dist/bin/git.d.ts.map +1 -1
- package/dist/bin/git.js +23 -6
- 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 +7 -1
- 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.map +1 -1
- package/dist/bin/utils.js +11 -7
- 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.js +14 -7
- package/dist/test/unit/bin/diff-changes.test.js.map +1 -1
- package/dist/test/unit/bin/diff.test.js +14 -4
- package/dist/test/unit/bin/diff.test.js.map +1 -1
- 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/should-built-and-test.test.js +75 -18
- 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 +14 -7
- package/test/unit/bin/diff.test.ts +19 -21
- package/test/unit/bin/git.test.ts +59 -20
- package/test/unit/custom-matchers.test.ts +10 -9
- package/test/unit/should-built-and-test.test.ts +77 -20
- 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
package/bin/main.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import process from 'node:process';
|
|
4
4
|
|
|
5
5
|
import yargs, { type Argv } from 'yargs';
|
|
6
|
+
// eslint-disable-next-line import/extensions --- With .js, it cannot find types
|
|
6
7
|
import { hideBin } from 'yargs/helpers';
|
|
7
8
|
|
|
8
9
|
import { runBuilds } from './build.js';
|
|
@@ -11,7 +12,7 @@ import { getChangedFiles, getCommits } from './git.js';
|
|
|
11
12
|
import { getPushData } from './github.js';
|
|
12
13
|
import { notifyToSlack } from './slack.js';
|
|
13
14
|
import { reportTestResults } from './test-report.js';
|
|
14
|
-
import { getRepoActors, setCwd,spawnCommandInGhWorkspace } from './utils.js';
|
|
15
|
+
import { getRepoActors, setCwd, spawnCommandInGhWorkspace } from './utils.js';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Middlewares to be run before every command execution
|
|
@@ -65,13 +66,18 @@ await yargs()
|
|
|
65
66
|
async () => {
|
|
66
67
|
const actorConfigs = await getRepoActors();
|
|
67
68
|
console.log(JSON.stringify(actorConfigs));
|
|
68
|
-
}
|
|
69
|
+
},
|
|
69
70
|
)
|
|
70
71
|
.command('get-affected-actors', '', buildOptions, async (args) => {
|
|
71
72
|
const commits = getCommits(args);
|
|
72
73
|
const changedFiles = getChangedFiles(commits);
|
|
73
74
|
const actorConfigs = await getRepoActors();
|
|
74
|
-
const actorsChanged = getChangedActors({
|
|
75
|
+
const actorsChanged = getChangedActors({
|
|
76
|
+
filepathsChanged: changedFiles,
|
|
77
|
+
actorConfigs,
|
|
78
|
+
isLatest: false,
|
|
79
|
+
commits,
|
|
80
|
+
});
|
|
75
81
|
console.log(JSON.stringify(actorsChanged));
|
|
76
82
|
})
|
|
77
83
|
.command(
|
|
@@ -85,7 +91,7 @@ await yargs()
|
|
|
85
91
|
.option('workflow-name', { type: 'string' }),
|
|
86
92
|
async (args) => {
|
|
87
93
|
await reportTestResults(args);
|
|
88
|
-
}
|
|
94
|
+
},
|
|
89
95
|
)
|
|
90
96
|
.command(
|
|
91
97
|
'build',
|
|
@@ -104,7 +110,7 @@ await yargs()
|
|
|
104
110
|
// git@github.com:apify-store/google-maps#:actors/lukaskrivka_google-maps-with-contact-details
|
|
105
111
|
const repoUrl = spawnCommandInGhWorkspace(`git remote get-url origin`).replace(
|
|
106
112
|
/^https:\/\/github\.com\//,
|
|
107
|
-
'git@github.com:'
|
|
113
|
+
'git@github.com:',
|
|
108
114
|
);
|
|
109
115
|
|
|
110
116
|
const builds = await runBuilds({
|
|
@@ -114,7 +120,7 @@ await yargs()
|
|
|
114
120
|
dryRun: args.dryRun,
|
|
115
121
|
});
|
|
116
122
|
console.log(JSON.stringify(builds));
|
|
117
|
-
}
|
|
123
|
+
},
|
|
118
124
|
)
|
|
119
125
|
.command(
|
|
120
126
|
'release',
|
|
@@ -127,7 +133,7 @@ await yargs()
|
|
|
127
133
|
.option('release-slack-channel', { type: 'string' }),
|
|
128
134
|
async (args) => {
|
|
129
135
|
const { branch, changedFiles, repoUrl, commits, changelog, repository, author } = await getPushData(
|
|
130
|
-
args.pushEventPath
|
|
136
|
+
args.pushEventPath,
|
|
131
137
|
);
|
|
132
138
|
const isLatest = true;
|
|
133
139
|
const actorConfigs = await getRepoActors();
|
|
@@ -158,7 +164,7 @@ await yargs()
|
|
|
158
164
|
reportSlackChannel,
|
|
159
165
|
releaseSlackChannel,
|
|
160
166
|
});
|
|
161
|
-
}
|
|
167
|
+
},
|
|
162
168
|
)
|
|
163
169
|
.strictCommands()
|
|
164
170
|
.demandCommand(1, 'Command is required')
|
package/bin/slack.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WebClient } from '@slack/web-api';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import type { Commit } from './types.js';
|
|
3
4
|
import { getEnvVar } from './utils.js';
|
|
4
5
|
|
|
5
6
|
type NotifyToSlackOptions = {
|
|
@@ -46,7 +47,10 @@ export const notifyToSlack = async ({
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
const commitsMessage = `${commits
|
|
49
|
-
.map(
|
|
50
|
+
.map(
|
|
51
|
+
({ author: commitAuthor, message }, index) =>
|
|
52
|
+
`${index + 1}. Commit message: ${message}\n\tAuthor: ${commitAuthor}.`,
|
|
53
|
+
)
|
|
50
54
|
.join('\n')}`;
|
|
51
55
|
const changedFilesMessage = `**Files changed**: ${changedFiles.join(', ')}`;
|
|
52
56
|
const longMessage = `${shortMessage}\n**Commit list**:\n${commitsMessage}\n\n${changedFilesMessage}`;
|
package/bin/test-report.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
|
|
2
3
|
import { sendSlackMessage } from './slack.js';
|
|
3
4
|
import { getEnvVar } from './utils.js';
|
|
4
5
|
|
|
5
6
|
interface ReportTestResultsOptions {
|
|
6
|
-
reportFile: string
|
|
7
|
-
dryRun: boolean
|
|
8
|
-
reportSlackChannel?: string
|
|
9
|
-
jobUrl?: string
|
|
10
|
-
workflowName?: string
|
|
7
|
+
reportFile: string;
|
|
8
|
+
dryRun: boolean;
|
|
9
|
+
reportSlackChannel?: string;
|
|
10
|
+
jobUrl?: string;
|
|
11
|
+
workflowName?: string;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export const reportTestResults = async ({
|
|
@@ -35,7 +36,7 @@ export const reportTestResults = async ({
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
const failedAssertions: { message: string; runLink: string
|
|
39
|
+
const failedAssertions: { message: string; runLink: string; actorName: string }[] = [];
|
|
39
40
|
|
|
40
41
|
console.error();
|
|
41
42
|
console.error(`PASSED: ${passed.length}, FAILED: ${failed.length}`);
|
|
@@ -57,7 +58,13 @@ export const reportTestResults = async ({
|
|
|
57
58
|
for (const [i, aResult] of failed.entries()) {
|
|
58
59
|
const { failureMessages, fullName, meta } = aResult;
|
|
59
60
|
if (failureMessages) {
|
|
60
|
-
failedAssertions.push(
|
|
61
|
+
failedAssertions.push(
|
|
62
|
+
...failureMessages.map((message) => ({
|
|
63
|
+
message: message.split('\n')?.[0],
|
|
64
|
+
runLink: meta.runLink,
|
|
65
|
+
actorName: meta.actorName,
|
|
66
|
+
})),
|
|
67
|
+
);
|
|
61
68
|
}
|
|
62
69
|
console.error(`${i + 1}) ${fullName} ... ${meta.runLink}`);
|
|
63
70
|
console.error();
|
|
@@ -65,9 +72,11 @@ export const reportTestResults = async ({
|
|
|
65
72
|
console.error();
|
|
66
73
|
console.error(`PASSED: ${passed.length}, FAILED: ${failed.length}`);
|
|
67
74
|
console.error();
|
|
68
|
-
|
|
75
|
+
|
|
69
76
|
if (!reportSlackChannel) {
|
|
70
|
-
console.error(
|
|
77
|
+
console.error(
|
|
78
|
+
`Skipping slack notification. If you want to enable it, add --report-slack-channel flag and make sure SLACK_TOKEN_TESTS_BOT env variable is set.`,
|
|
79
|
+
);
|
|
71
80
|
return;
|
|
72
81
|
}
|
|
73
82
|
|
|
@@ -81,7 +90,9 @@ export const reportTestResults = async ({
|
|
|
81
90
|
let slackMessage = `\`${workflowName ?? '-'}\``;
|
|
82
91
|
slackMessage += `: has ${failedAssertions.length} failed assertions. Failing test suites: ${failed.length}/${total}.${jobLink}`;
|
|
83
92
|
slackMessage += `\n\n${failedAssertions[0].message} --- <${failedAssertions[0].runLink}|${failedAssertions[0].actorName}>`;
|
|
84
|
-
const blocks = failedAssertions
|
|
93
|
+
const blocks = failedAssertions
|
|
94
|
+
.slice(1)
|
|
95
|
+
.map(({ message, runLink, actorName }) => `• ${message} --- <${runLink}|${actorName}>`);
|
|
85
96
|
|
|
86
97
|
console.error('SLACK:', slackMessage);
|
|
87
98
|
console.error('\tblocks:', blocks.join('\n\t\t'));
|
|
@@ -96,52 +107,52 @@ export const reportTestResults = async ({
|
|
|
96
107
|
}
|
|
97
108
|
};
|
|
98
109
|
|
|
99
|
-
type Status = 'passed' | 'failed' | 'skipped' | 'pending' | 'todo' | 'disabled'
|
|
100
|
-
type Milliseconds = number
|
|
110
|
+
type Status = 'passed' | 'failed' | 'skipped' | 'pending' | 'todo' | 'disabled';
|
|
111
|
+
type Milliseconds = number;
|
|
101
112
|
interface Callsite {
|
|
102
|
-
line: number
|
|
103
|
-
column: number
|
|
113
|
+
line: number;
|
|
114
|
+
column: number;
|
|
104
115
|
}
|
|
105
116
|
|
|
106
117
|
interface JsonAssertionResult {
|
|
107
|
-
ancestorTitles:
|
|
108
|
-
fullName: string
|
|
109
|
-
status: Status
|
|
110
|
-
title: string
|
|
118
|
+
ancestorTitles: string[];
|
|
119
|
+
fullName: string;
|
|
120
|
+
status: Status;
|
|
121
|
+
title: string;
|
|
111
122
|
meta: {
|
|
112
|
-
runId: string
|
|
113
|
-
runLink: string
|
|
114
|
-
actorName: string
|
|
115
|
-
}
|
|
116
|
-
duration?: Milliseconds | null
|
|
117
|
-
failureMessages:
|
|
118
|
-
location?: Callsite | null
|
|
123
|
+
runId: string;
|
|
124
|
+
runLink: string;
|
|
125
|
+
actorName: string;
|
|
126
|
+
};
|
|
127
|
+
duration?: Milliseconds | null;
|
|
128
|
+
failureMessages: string[] | null;
|
|
129
|
+
location?: Callsite | null;
|
|
119
130
|
}
|
|
120
131
|
|
|
121
132
|
interface JsonTestResult {
|
|
122
|
-
message: string
|
|
123
|
-
name: string
|
|
124
|
-
status: 'failed' | 'passed'
|
|
125
|
-
startTime: number
|
|
126
|
-
endTime: number
|
|
127
|
-
assertionResults:
|
|
133
|
+
message: string;
|
|
134
|
+
name: string;
|
|
135
|
+
status: 'failed' | 'passed';
|
|
136
|
+
startTime: number;
|
|
137
|
+
endTime: number;
|
|
138
|
+
assertionResults: JsonAssertionResult[];
|
|
128
139
|
// summary: string
|
|
129
140
|
// coverage: unknown
|
|
130
141
|
}
|
|
131
142
|
|
|
132
143
|
interface JsonTestResults {
|
|
133
|
-
numFailedTests: number
|
|
134
|
-
numFailedTestSuites: number
|
|
135
|
-
numPassedTests: number
|
|
136
|
-
numPassedTestSuites: number
|
|
137
|
-
numPendingTests: number
|
|
138
|
-
numPendingTestSuites: number
|
|
139
|
-
numTodoTests: number
|
|
140
|
-
numTotalTests: number
|
|
141
|
-
numTotalTestSuites: number
|
|
142
|
-
startTime: number
|
|
143
|
-
success: boolean
|
|
144
|
-
testResults:
|
|
144
|
+
numFailedTests: number;
|
|
145
|
+
numFailedTestSuites: number;
|
|
146
|
+
numPassedTests: number;
|
|
147
|
+
numPassedTestSuites: number;
|
|
148
|
+
numPendingTests: number;
|
|
149
|
+
numPendingTestSuites: number;
|
|
150
|
+
numTodoTests: number;
|
|
151
|
+
numTotalTests: number;
|
|
152
|
+
numTotalTestSuites: number;
|
|
153
|
+
startTime: number;
|
|
154
|
+
success: boolean;
|
|
155
|
+
testResults: JsonTestResult[];
|
|
145
156
|
// snapshot: SnapshotSummary
|
|
146
157
|
// coverageMap?: CoverageMap | null | undefined
|
|
147
158
|
// numRuntimeErrorTestSuites: number
|
package/bin/types.ts
CHANGED
|
@@ -1,91 +1,88 @@
|
|
|
1
1
|
export interface Config {
|
|
2
|
-
targetBranch: string
|
|
3
|
-
sourceBranch: string
|
|
4
|
-
baseCommit?: string
|
|
5
|
-
workspace?: string
|
|
2
|
+
targetBranch: string;
|
|
3
|
+
sourceBranch: string;
|
|
4
|
+
baseCommit?: string;
|
|
5
|
+
workspace?: string;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export type Commit = {
|
|
9
|
-
sha: string
|
|
10
|
-
author: string
|
|
11
|
-
date: string
|
|
12
|
-
message: string
|
|
13
|
-
}
|
|
9
|
+
sha: string;
|
|
10
|
+
author: string;
|
|
11
|
+
date: string;
|
|
12
|
+
message: string;
|
|
13
|
+
};
|
|
14
14
|
|
|
15
15
|
// NOTE: The GitHub types are incomplete, feel free to add fields/complete (not sure how stable GitHub API is)
|
|
16
16
|
export interface GitHubHeadCommit {
|
|
17
|
-
added: string[]
|
|
18
|
-
removed: string[]
|
|
19
|
-
modified: string[]
|
|
17
|
+
added: string[];
|
|
18
|
+
removed: string[];
|
|
19
|
+
modified: string[];
|
|
20
20
|
author: {
|
|
21
|
-
name: string
|
|
22
|
-
}
|
|
23
|
-
message: string
|
|
24
|
-
id: string
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
23
|
+
message: string;
|
|
24
|
+
id: string;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export interface Repository {
|
|
28
|
-
full_name: string
|
|
29
|
-
name: string
|
|
30
|
-
ssh_url: string
|
|
28
|
+
full_name: string;
|
|
29
|
+
name: string;
|
|
30
|
+
ssh_url: string;
|
|
31
31
|
owner: {
|
|
32
|
-
login: string
|
|
33
|
-
}
|
|
32
|
+
login: string;
|
|
33
|
+
};
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export type GitHubEvent = GitHubEventPullRequest | GitHubEventPush;
|
|
37
37
|
|
|
38
|
-
// All optional type so we check that we have all required fields for each event type
|
|
39
|
-
export type RawGitHubEvent = Partial<Omit<GitHubEventPullRequest, 'type'> & Omit<GitHubEventPush, 'type'>>;
|
|
40
|
-
|
|
41
38
|
export interface GitHubEventPullRequest {
|
|
42
39
|
// Type is our own variable we inject to have discriminated union
|
|
43
40
|
// The rest of the properties are raw from GitHub API
|
|
44
|
-
type: 'pull_request'
|
|
41
|
+
type: 'pull_request';
|
|
45
42
|
pull_request: {
|
|
46
|
-
number: number
|
|
43
|
+
number: number;
|
|
47
44
|
base: {
|
|
48
|
-
ref: string
|
|
49
|
-
sha: string
|
|
50
|
-
}
|
|
45
|
+
ref: string;
|
|
46
|
+
sha: string;
|
|
47
|
+
};
|
|
51
48
|
head: {
|
|
52
|
-
ref: string
|
|
53
|
-
sha: string
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
repository: Repository
|
|
49
|
+
ref: string;
|
|
50
|
+
sha: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
repository: Repository;
|
|
57
54
|
}
|
|
58
55
|
|
|
59
56
|
export interface GitHubEventPush {
|
|
60
|
-
type: 'push'
|
|
61
|
-
head_commit: GitHubHeadCommit
|
|
62
|
-
repository: Repository
|
|
63
|
-
ref: string
|
|
64
|
-
commits: GithubCommit[]
|
|
65
|
-
before: string
|
|
66
|
-
after: string
|
|
57
|
+
type: 'push';
|
|
58
|
+
head_commit: GitHubHeadCommit;
|
|
59
|
+
repository: Repository;
|
|
60
|
+
ref: string;
|
|
61
|
+
commits: GithubCommit[];
|
|
62
|
+
before: string;
|
|
63
|
+
after: string;
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
export interface GithubCommit {
|
|
70
|
-
id: string
|
|
71
|
-
tree_id: string
|
|
72
|
-
distinct: boolean
|
|
73
|
-
message: string
|
|
74
|
-
timestamp: string
|
|
75
|
-
url: string
|
|
67
|
+
id: string;
|
|
68
|
+
tree_id: string;
|
|
69
|
+
distinct: boolean;
|
|
70
|
+
message: string;
|
|
71
|
+
timestamp: string;
|
|
72
|
+
url: string;
|
|
76
73
|
author: {
|
|
77
|
-
name: string
|
|
78
|
-
email: string
|
|
79
|
-
username: string
|
|
80
|
-
}
|
|
74
|
+
name: string;
|
|
75
|
+
email: string;
|
|
76
|
+
username: string;
|
|
77
|
+
};
|
|
81
78
|
committer: {
|
|
82
|
-
name: string
|
|
83
|
-
email: string
|
|
84
|
-
username: string
|
|
85
|
-
}
|
|
86
|
-
added: string[]
|
|
87
|
-
removed: string[]
|
|
88
|
-
modified: string[]
|
|
79
|
+
name: string;
|
|
80
|
+
email: string;
|
|
81
|
+
username: string;
|
|
82
|
+
};
|
|
83
|
+
added: string[];
|
|
84
|
+
removed: string[];
|
|
85
|
+
modified: string[];
|
|
89
86
|
}
|
|
90
87
|
|
|
91
88
|
export interface BuildData {
|
|
@@ -99,5 +96,5 @@ export interface BuildData {
|
|
|
99
96
|
export interface ActorConfig {
|
|
100
97
|
actorName: string;
|
|
101
98
|
folder: string;
|
|
102
|
-
isStandalone: boolean
|
|
99
|
+
isStandalone: boolean;
|
|
103
100
|
}
|
package/bin/utils.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
3
|
|
|
4
|
-
import type {
|
|
5
|
-
ActorConfig,
|
|
6
|
-
GitHubEvent,
|
|
7
|
-
} from './types.js';
|
|
4
|
+
import type { ActorConfig, GitHubEvent } from './types.js';
|
|
8
5
|
|
|
9
6
|
export const spawnCommandInGhWorkspace = (command: string, args: string[] = []) => {
|
|
10
7
|
console.error(command, args.join(' '));
|
|
@@ -49,14 +46,14 @@ export const getRepoActors = async (): Promise<ActorConfig[]> => {
|
|
|
49
46
|
let actorDirs: string[];
|
|
50
47
|
try {
|
|
51
48
|
actorDirs = (await fs.readdir(`./actors`)).map((dir) => `actors/${dir}`);
|
|
52
|
-
} catch
|
|
49
|
+
} catch {
|
|
53
50
|
console.warn(`No /actors directory found in repo`);
|
|
54
51
|
actorDirs = [];
|
|
55
52
|
}
|
|
56
53
|
let standaloneActorDirs: string[];
|
|
57
54
|
try {
|
|
58
55
|
standaloneActorDirs = (await fs.readdir(`./standalone-actors`)).map((dir) => `standalone-actors/${dir}`);
|
|
59
|
-
} catch
|
|
56
|
+
} catch {
|
|
60
57
|
console.warn(`No /standalone-actors directory found in repo`);
|
|
61
58
|
standaloneActorDirs = [];
|
|
62
59
|
}
|
|
@@ -73,8 +70,18 @@ export const getRepoActors = async (): Promise<ActorConfig[]> => {
|
|
|
73
70
|
isStandalone: folderType === 'standalone-actors',
|
|
74
71
|
});
|
|
75
72
|
}
|
|
76
|
-
console.error(
|
|
77
|
-
|
|
73
|
+
console.error(
|
|
74
|
+
`Actors in repo: ${actorConfigs
|
|
75
|
+
.filter(({ isStandalone }) => !isStandalone)
|
|
76
|
+
.map(({ actorName }) => actorName)
|
|
77
|
+
.join(', ')}`,
|
|
78
|
+
);
|
|
79
|
+
console.error(
|
|
80
|
+
`Standalone actors in repo: ${actorConfigs
|
|
81
|
+
.filter(({ isStandalone }) => !!isStandalone)
|
|
82
|
+
.map(({ actorName }) => actorName)
|
|
83
|
+
.join(', ')}`,
|
|
84
|
+
);
|
|
78
85
|
return actorConfigs;
|
|
79
86
|
};
|
|
80
87
|
|
|
@@ -85,10 +92,8 @@ export const setCwd = ({ workspace }: { workspace: string | undefined }) => {
|
|
|
85
92
|
}
|
|
86
93
|
const ghWorkspace = getEnvVar('GITHUB_WORKSPACE', process.cwd());
|
|
87
94
|
process.chdir(ghWorkspace);
|
|
88
|
-
}
|
|
95
|
+
};
|
|
89
96
|
|
|
90
97
|
export const getHeadCommitSha = (githubEvent: GitHubEvent) => {
|
|
91
|
-
return githubEvent.type === 'pull_request'
|
|
92
|
-
? githubEvent.pull_request.head.sha
|
|
93
|
-
: githubEvent.head_commit.id;
|
|
98
|
+
return githubEvent.type === 'pull_request' ? githubEvent.pull_request.head.sha : githubEvent.head_commit.id;
|
|
94
99
|
};
|
package/dist/bin/build.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ type RunBuildsOptions = {
|
|
|
12
12
|
branch: string;
|
|
13
13
|
dryRun: boolean;
|
|
14
14
|
};
|
|
15
|
-
export declare const runBuilds: ({ repoUrl, branch, actorConfigs, isLatest, dryRun
|
|
15
|
+
export declare const runBuilds: ({ repoUrl, branch, actorConfigs, isLatest, dryRun }: RunBuildsOptions) => Promise<BuildPrActorOptions[] | BuildData[]>;
|
|
16
16
|
export declare const deleteOldBuilds: (actorConfigs: ActorConfig[]) => Promise<void>;
|
|
17
17
|
export {};
|
|
18
18
|
//# sourceMappingURL=build.d.ts.map
|
package/dist/bin/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../bin/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../bin/build.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGzD,KAAK,mBAAmB,GAAG;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC;AA+MF,KAAK,gBAAgB,GAAG;IACpB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,SAAS,GAAU,qDAA6D,gBAAgB,iDAsD5G,CAAC;AAEF,eAAO,MAAM,eAAe,GAAU,cAAc,WAAW,EAAE,kBAIhE,CAAC"}
|