apify-test-tools 0.10.2-beta.12 → 0.10.2-beta.14
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 +123 -128
- package/.github/workflows/public_platform-tests-claude-investigate-and-fix.yaml +1 -1
- package/.github/workflows/public_platform-tests.yaml +36 -22
- package/.github/workflows/public_pr-build-test.yaml +7 -6
- package/.github/workflows/public_push-build-latest.yaml +6 -4
- package/.prettierignore +1 -1
- package/CHANGELOG.md +3 -0
- package/CONTRIBUTING.md +8 -6
- package/README.md +10 -11
- package/bin/actor-ids.ts +38 -0
- package/bin/build.ts +1 -1
- package/bin/git.ts +20 -92
- package/bin/main.ts +87 -73
- package/bin/notify.ts +198 -0
- package/bin/run-tests.ts +141 -0
- package/bin/slack.ts +16 -87
- package/bin/stdin-input.ts +98 -7
- package/bin/test-report.ts +141 -140
- package/bin/types.ts +0 -9
- package/dist/bin/actor-ids.d.ts +16 -0
- package/dist/bin/actor-ids.d.ts.map +1 -0
- package/dist/bin/actor-ids.js +24 -0
- package/dist/bin/actor-ids.js.map +1 -0
- package/dist/bin/build.js +1 -1
- package/dist/bin/build.js.map +1 -1
- package/dist/bin/git.d.ts +6 -16
- package/dist/bin/git.d.ts.map +1 -1
- package/dist/bin/git.js +15 -75
- package/dist/bin/git.js.map +1 -1
- package/dist/bin/main.js +80 -51
- package/dist/bin/main.js.map +1 -1
- package/dist/bin/notify.d.ts +35 -0
- package/dist/bin/notify.d.ts.map +1 -0
- package/dist/bin/notify.js +131 -0
- package/dist/bin/notify.js.map +1 -0
- package/dist/bin/run-tests.d.ts +21 -0
- package/dist/bin/run-tests.d.ts.map +1 -0
- package/dist/bin/run-tests.js +116 -0
- package/dist/bin/run-tests.js.map +1 -0
- package/dist/bin/slack.d.ts +2 -17
- package/dist/bin/slack.d.ts.map +1 -1
- package/dist/bin/slack.js +17 -58
- package/dist/bin/slack.js.map +1 -1
- package/dist/bin/stdin-input.d.ts +71 -9
- package/dist/bin/stdin-input.d.ts.map +1 -1
- package/dist/bin/stdin-input.js +76 -6
- package/dist/bin/stdin-input.js.map +1 -1
- package/dist/bin/test-report.d.ts +69 -8
- package/dist/bin/test-report.d.ts.map +1 -1
- package/dist/bin/test-report.js +76 -67
- package/dist/bin/test-report.js.map +1 -1
- package/dist/bin/types.d.ts +0 -8
- package/dist/bin/types.d.ts.map +1 -1
- package/dist/lib/lib.d.ts +0 -3
- package/dist/lib/lib.d.ts.map +1 -1
- package/dist/lib/lib.js +5 -10
- package/dist/lib/lib.js.map +1 -1
- package/dist/test/bundle/cli-bundle.test.js +40 -48
- package/dist/test/bundle/cli-bundle.test.js.map +1 -1
- package/dist/test/e2e/cli-bundle.e2e.test.js +15 -16
- package/dist/test/e2e/cli-bundle.e2e.test.js.map +1 -1
- package/dist/test/e2e/git-build-release.e2e.test.js +2 -2
- package/dist/test/e2e/git-build-release.e2e.test.js.map +1 -1
- package/dist/test/unit/bin/actor-ids.test.d.ts +2 -0
- package/dist/test/unit/bin/actor-ids.test.d.ts.map +1 -0
- package/dist/test/unit/bin/actor-ids.test.js +32 -0
- package/dist/test/unit/bin/actor-ids.test.js.map +1 -0
- package/dist/test/unit/bin/build-cli.test.js +8 -3
- package/dist/test/unit/bin/build-cli.test.js.map +1 -1
- package/dist/test/unit/bin/compiled-cli.d.ts +1 -1
- package/dist/test/unit/bin/compiled-cli.d.ts.map +1 -1
- package/dist/test/unit/bin/compiled-cli.js +12 -5
- package/dist/test/unit/bin/compiled-cli.js.map +1 -1
- package/dist/test/unit/bin/diff-changes.test.js +1 -1
- package/dist/test/unit/bin/diff-changes.test.js.map +1 -1
- package/dist/test/unit/bin/git.test.js +4 -142
- package/dist/test/unit/bin/git.test.js.map +1 -1
- package/dist/test/unit/bin/notify.test.d.ts +2 -0
- package/dist/test/unit/bin/notify.test.d.ts.map +1 -0
- package/dist/test/unit/bin/notify.test.js +222 -0
- package/dist/test/unit/bin/notify.test.js.map +1 -0
- package/dist/test/unit/bin/stdin-input.test.js +51 -9
- package/dist/test/unit/bin/stdin-input.test.js.map +1 -1
- package/dist/test/unit/bin/test-cli.test.d.ts +2 -0
- package/dist/test/unit/bin/test-cli.test.d.ts.map +1 -0
- package/dist/test/unit/bin/test-cli.test.js +115 -0
- package/dist/test/unit/bin/test-cli.test.js.map +1 -0
- package/dist/test/unit/bin/test-report.test.d.ts +2 -0
- package/dist/test/unit/bin/test-report.test.d.ts.map +1 -0
- package/dist/test/unit/bin/test-report.test.js +100 -0
- package/dist/test/unit/bin/test-report.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/cli.md +131 -53
- package/docs/lib.md +21 -16
- package/docs/workflows.md +24 -23
- package/eslint.config.mjs +1 -1
- package/lib/lib.ts +5 -10
- package/package.json +1 -1
- package/test/bundle/cli-bundle.test.ts +47 -60
- package/test/e2e/cli-bundle.e2e.test.ts +18 -25
- package/test/e2e/git-build-release.e2e.test.ts +2 -2
- package/test/unit/bin/actor-ids.test.ts +43 -0
- package/test/unit/bin/build-cli.test.ts +9 -3
- package/test/unit/bin/compiled-cli.ts +11 -5
- package/test/unit/bin/diff-changes.test.ts +1 -1
- package/test/unit/bin/git.test.ts +3 -197
- package/test/unit/bin/notify.test.ts +299 -0
- package/test/unit/bin/stdin-input.test.ts +68 -9
- package/test/unit/bin/test-cli.test.ts +137 -0
- package/test/unit/bin/test-report.test.ts +118 -0
- package/dist/test/unit/bin/logging.test.d.ts +0 -2
- package/dist/test/unit/bin/logging.test.d.ts.map +0 -1
- package/dist/test/unit/bin/logging.test.js +0 -43
- package/dist/test/unit/bin/logging.test.js.map +0 -1
- package/dist/test/unit/bin/slack.test.d.ts +0 -2
- package/dist/test/unit/bin/slack.test.d.ts.map +0 -1
- package/dist/test/unit/bin/slack.test.js +0 -71
- package/dist/test/unit/bin/slack.test.js.map +0 -1
- package/test/unit/bin/logging.test.ts +0 -52
- package/test/unit/bin/slack.test.ts +0 -84
package/dist/bin/git.js
CHANGED
|
@@ -5,17 +5,6 @@ const GIT_LOG_FORMAT = ['%H', '%aN<%aE>', '%aD', '%s'].join(GIT_FORMAT_SEPARATOR
|
|
|
5
5
|
// Lists the changed paths. With rename detection (on by default) a moved file is listed only under its new path,
|
|
6
6
|
// so the Actor whose context it left wouldn't count as changed. --no-renames lists it as deleted and added instead.
|
|
7
7
|
const LIST_CHANGED_PATHS = ['--name-only', '--no-renames'];
|
|
8
|
-
/**
|
|
9
|
-
* Gets the list of changed files between the given commits (inclusive), so it diffs from the parent of the oldest.
|
|
10
|
-
*/
|
|
11
|
-
export const getChangedFiles = async (commits) => {
|
|
12
|
-
// getCommits never returns an empty list (it throws on an empty range, and the rerun check returns all
|
|
13
|
-
// commits when the base commit is the branch HEAD), so this signals a programmer error
|
|
14
|
-
if (commits.length === 0) {
|
|
15
|
-
throw new Error('Cannot get changed files: the commit list is empty. This should never happen.');
|
|
16
|
-
}
|
|
17
|
-
return getChangedFilesBetween(`${commits[0].sha}~`, commits[commits.length - 1].sha);
|
|
18
|
-
};
|
|
19
8
|
/**
|
|
20
9
|
* Files that differ between two commits, i.e. changed by the commits in the range (fromRef, toRef]. fromRef's own
|
|
21
10
|
* changes are not included: to include them, pass its parent, `${sha}~` (as getChangedFiles does).
|
|
@@ -45,27 +34,6 @@ export const findCommitSha = async (ref) => runGitCommand(['rev-parse', '--verif
|
|
|
45
34
|
return undefined;
|
|
46
35
|
throw error;
|
|
47
36
|
});
|
|
48
|
-
const SHA_REGEX = /^[0-9a-f]{40}$/i;
|
|
49
|
-
/**
|
|
50
|
-
*
|
|
51
|
-
* @param shaOrCommit Supports both a SHA string or a Commit object in JSON format. Can be empty.
|
|
52
|
-
* @returns The SHA string if valid, otherwise throws an error.
|
|
53
|
-
*/
|
|
54
|
-
export const parseBaseCommit = (shaOrCommit) => {
|
|
55
|
-
if (!shaOrCommit)
|
|
56
|
-
return undefined;
|
|
57
|
-
let sha;
|
|
58
|
-
if (shaOrCommit.startsWith('{')) {
|
|
59
|
-
sha = JSON.parse(shaOrCommit).sha;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
sha = shaOrCommit;
|
|
63
|
-
}
|
|
64
|
-
if (!SHA_REGEX.test(sha)) {
|
|
65
|
-
throw new Error(`Invalid base commit SHA: "${sha}". It should be a 40-character hexadecimal string, instead got input: "${shaOrCommit}".`);
|
|
66
|
-
}
|
|
67
|
-
return sha;
|
|
68
|
-
};
|
|
69
37
|
/**
|
|
70
38
|
* Commits reachable from toRef but not from fromRef, oldest first: the range (fromRef, toRef], so fromRef itself is
|
|
71
39
|
* not included. To include it, pass its parent, `${sha}~`.
|
|
@@ -79,36 +47,6 @@ export const getCommitsBetween = async (fromRef, toRef) => {
|
|
|
79
47
|
commits.reverse();
|
|
80
48
|
return commits;
|
|
81
49
|
};
|
|
82
|
-
/**
|
|
83
|
-
* Gets the commits between sourceBranch and targetBranch (exclusive).
|
|
84
|
-
* - If baseCommit is provided, only returns commits after the baseCommit.
|
|
85
|
-
*/
|
|
86
|
-
export const getCommits = async ({ sourceBranch, targetBranch, baseCommit, }) => {
|
|
87
|
-
const baseCommitSha = parseBaseCommit(baseCommit);
|
|
88
|
-
const commits = await getCommitsBetween(targetBranch, sourceBranch);
|
|
89
|
-
if (commits.length === 0) {
|
|
90
|
-
throw new Error(`${sourceBranch} has no commits that are not on ${targetBranch}.`);
|
|
91
|
-
}
|
|
92
|
-
// The last validated (base) commit being the branch HEAD means nothing new was pushed since the last
|
|
93
|
-
// validation — the dev reran the workflow (or force-pushed to the same state) to trigger a clean test
|
|
94
|
-
const headSha = commits[commits.length - 1]?.sha;
|
|
95
|
-
if (baseCommitSha !== undefined && baseCommitSha === headSha) {
|
|
96
|
-
logger.info(`Detected rerun with the same commit that we already validated. This usually means the user wants to rerun the Action from scratch, ignoring last validated commit ${baseCommitSha} and returning all commits`);
|
|
97
|
-
logger.info(`Commits being returned: ${commits.map((c) => c.sha).join(', ')}`);
|
|
98
|
-
return commits;
|
|
99
|
-
}
|
|
100
|
-
const baseCommitIndex = commits.findIndex((commit) => commit.sha === baseCommitSha);
|
|
101
|
-
const hasBaseCommit = baseCommitIndex !== -1;
|
|
102
|
-
if (hasBaseCommit) {
|
|
103
|
-
const commitsUpToBaseCommit = commits.slice(baseCommitIndex + 1);
|
|
104
|
-
logger.info(`Found base commit ${baseCommitSha} at index ${baseCommitIndex}, returning ${commitsUpToBaseCommit.length} commits after it`);
|
|
105
|
-
logger.info(`Commits being returned: ${commitsUpToBaseCommit.map((c) => c.sha).join(', ')}`);
|
|
106
|
-
return commitsUpToBaseCommit;
|
|
107
|
-
}
|
|
108
|
-
logger.info(`Base commit ${baseCommitSha} not found in the commit range, returning all ${commits.length} commits`);
|
|
109
|
-
logger.info(`Commits being returned: ${commits.map((c) => c.sha).join(', ')}`);
|
|
110
|
-
return commits;
|
|
111
|
-
};
|
|
112
50
|
export const parseCommit = (commitString) => {
|
|
113
51
|
const splits = commitString.split(GIT_FORMAT_SEPARATOR);
|
|
114
52
|
if (splits.length !== 4) {
|
|
@@ -173,10 +111,19 @@ export const normalizeRepoUrl = (repoUrl) => {
|
|
|
173
111
|
.replace(/\.git$/, '')
|
|
174
112
|
.toLowerCase();
|
|
175
113
|
};
|
|
114
|
+
/**
|
|
115
|
+
* Web link to a commit, e.g. https://github.com/apify-store/google-maps/commit/<sha>. Null for hosts other than
|
|
116
|
+
* GitHub, whose commit pages live under other paths.
|
|
117
|
+
*/
|
|
118
|
+
export const getCommitUrl = (repoUrl, sha) => {
|
|
119
|
+
const repository = normalizeRepoUrl(repoUrl);
|
|
120
|
+
return repository.startsWith('github.com/') ? `https://${repository}/commit/${sha}` : null;
|
|
121
|
+
};
|
|
176
122
|
/** Repository name from its URL, e.g. `google-maps` for git@github.com:apify-store/google-maps.git */
|
|
177
123
|
export const getRepoName = (repoUrl) => {
|
|
178
124
|
return normalizeRepoUrl(repoUrl).split('/').pop();
|
|
179
125
|
};
|
|
126
|
+
const SHA_REGEX = /^[0-9a-f]{40}$/i;
|
|
180
127
|
// Sent by e.g. GitHub as the "before" commit of a push that created the branch
|
|
181
128
|
const ZERO_SHA_REGEX = /^0{40}$/;
|
|
182
129
|
/**
|
|
@@ -185,28 +132,21 @@ const ZERO_SHA_REGEX = /^0{40}$/;
|
|
|
185
132
|
* would rebuild the latest build of every Actor and post it to Slack, so every problem is an error.
|
|
186
133
|
*/
|
|
187
134
|
export const resolveReleaseBaseCommit = async (baseCommit, head = 'HEAD') => {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
135
|
+
if (!SHA_REGEX.test(baseCommit)) {
|
|
136
|
+
throw new Error(`Invalid base commit SHA: "${baseCommit}". It should be a 40-character hexadecimal string. ` +
|
|
137
|
+
'See the "Releasing Actors" section of docs/cli.md.');
|
|
191
138
|
}
|
|
139
|
+
const sha = baseCommit;
|
|
192
140
|
if (ZERO_SHA_REGEX.test(sha)) {
|
|
193
141
|
throw new Error(`Base commit is ${sha}, which means the branch was just created and there is no previous release to diff against. ` +
|
|
194
142
|
`Rerun with the base commit set to the last commit before the changes you want to release.`);
|
|
195
143
|
}
|
|
196
|
-
|
|
197
|
-
const verifiedSha = await runGitCommand(['rev-parse', '--verify', '--quiet', `${sha}^{commit}`], {
|
|
198
|
-
operation: 'verify the release base commit in local Git history',
|
|
199
|
-
}).catch((error) => {
|
|
200
|
-
if (error instanceof GitCommandError && error.exitCode === 1)
|
|
201
|
-
return '';
|
|
202
|
-
throw error;
|
|
203
|
-
});
|
|
204
|
-
if (!verifiedSha) {
|
|
144
|
+
if (!(await findCommitSha(sha))) {
|
|
205
145
|
throw new Error(`Base commit ${sha} is not in the local git history. Either the checkout is shallow ` +
|
|
206
146
|
`(fetch the full history, e.g. fetch-depth: 0 in actions/checkout) or the branch was force-pushed.`);
|
|
207
147
|
}
|
|
208
148
|
// git merge-base A B outputs the common ancestor. If that equals A, then A is an ancestor of B.
|
|
209
|
-
const mergeBase = await runGitCommand(['merge-base',
|
|
149
|
+
const mergeBase = await runGitCommand(['merge-base', sha, head], {
|
|
210
150
|
operation: `check whether the release base commit is an ancestor of ${head}`,
|
|
211
151
|
}).catch((error) => {
|
|
212
152
|
if (error instanceof GitCommandError && error.exitCode === 1)
|
package/dist/bin/git.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../bin/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE5D,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAC1C,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;AAElF,iHAAiH;AACjH,oHAAoH;AACpH,MAAM,kBAAkB,GAAG,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;AAE3D
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../bin/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE5D,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAC1C,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;AAElF,iHAAiH;AACjH,oHAAoH;AACpH,MAAM,kBAAkB,GAAG,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAAE,OAAe,EAAE,KAAa,EAAE,EAAE;IAC3E,MAAM,kBAAkB,GAAG,MAAM,aAAa,CAAC,CAAC,MAAM,EAAE,GAAG,kBA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,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YACrC,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;AACnC,CAAC,CAAC"}
|
package/dist/bin/main.js
CHANGED
|
@@ -6,12 +6,11 @@ import { hideBin } from 'yargs/helpers';
|
|
|
6
6
|
import { getAffectedActors } from './affected-actors.js';
|
|
7
7
|
import { buildActors, DEFAULT_VERSION_KEYWORD, deleteOldBuilds } from './build.js';
|
|
8
8
|
import { runBuildsFromLocal } from './build-from-local.js';
|
|
9
|
-
import { getChangedFiles, getCommits } from './git.js';
|
|
10
9
|
import { logger, logLevels } from './logger.js';
|
|
10
|
+
import { notify, notifyOnChoices } from './notify.js';
|
|
11
11
|
import { writeJson } from './output.js';
|
|
12
|
-
import {
|
|
13
|
-
import { parseBuildInput,
|
|
14
|
-
import { reportTestResults } from './test-report.js';
|
|
12
|
+
import { runTests } from './run-tests.js';
|
|
13
|
+
import { parseBuildInput, parseNotifyInput, parseTestTargets, readStdin } from './stdin-input.js';
|
|
15
14
|
import { readConfigFile } from './utils/config/load-config.js';
|
|
16
15
|
/**
|
|
17
16
|
* Middlewares to be run before every command execution
|
|
@@ -19,16 +18,10 @@ import { readConfigFile } from './utils/config/load-config.js';
|
|
|
19
18
|
const middlewares = [(args) => logger.setLevel(args.logLevel)];
|
|
20
19
|
/*
|
|
21
20
|
* Option groups shared across commands. Each is a plain object passed to `.options()`, so a command's
|
|
22
|
-
* builder composes them by chaining (`y.options(
|
|
21
|
+
* builder composes them by chaining (`y.options(affectedRangeOptions).options(actorSelectionOptions)`)
|
|
23
22
|
* instead of nesting wrapper functions. `as const` keeps literals like `demandOption: true` so yargs
|
|
24
23
|
* can infer non-optional types; `satisfies` validates the shape without widening it.
|
|
25
24
|
*/
|
|
26
|
-
/** Commit range to inspect: everything on `source-branch` since it diverged from `target-branch`. */
|
|
27
|
-
const gitRangeOptions = {
|
|
28
|
-
'target-branch': { type: 'string', demandOption: true },
|
|
29
|
-
'source-branch': { type: 'string', demandOption: true },
|
|
30
|
-
'base-commit': { type: 'string', demandOption: false },
|
|
31
|
-
};
|
|
32
25
|
/**
|
|
33
26
|
* Where to build the Actors from. Defaults to the `origin` remote, which is then checked against each
|
|
34
27
|
* Actor's default version. Passing it explicitly skips that check (see assertRepoUrlMatchesDefaultVersion).
|
|
@@ -39,8 +32,7 @@ const repoUrlOptions = {
|
|
|
39
32
|
/**
|
|
40
33
|
* Actor-selection flags, applied to every command that reads the actor config so a caller can
|
|
41
34
|
* narrow the set it operates on (e.g. two-stage releases: `--ignore X`, then `--actors X`).
|
|
42
|
-
*
|
|
43
|
-
*/
|
|
35
|
+
* */
|
|
44
36
|
const actorSelectionOptions = {
|
|
45
37
|
actors: { type: 'string', array: true, default: [] },
|
|
46
38
|
ignore: { type: 'string', array: true, default: [] },
|
|
@@ -95,10 +87,52 @@ const envVarsSyncOptions = {
|
|
|
95
87
|
describe: "Fail unless the built version's env var names match the default version's",
|
|
96
88
|
},
|
|
97
89
|
};
|
|
98
|
-
/**
|
|
99
|
-
const
|
|
100
|
-
'
|
|
101
|
-
|
|
90
|
+
/** Flags of `test`, which runs the repository's vitest on the Actors piped in, e.g. the builds from `build`. */
|
|
91
|
+
const testOptions = {
|
|
92
|
+
'vitest-output-file': { type: 'string', describe: "Also keep vitest's own JSON report there, e.g. to upload it" },
|
|
93
|
+
reporter: {
|
|
94
|
+
type: 'string',
|
|
95
|
+
describe: 'Vitest reporter (https://vitest.dev/guide/reporters) to add to `default` and `json`, which are always on, ' +
|
|
96
|
+
'e.g. github-actions. Repeat it for more',
|
|
97
|
+
// A plain string, not `array: true`: yargs would fill an array option with the arguments after it too, so
|
|
98
|
+
// `test --reporter github-actions test/platform` would take the test path as a reporter. A repeated flag
|
|
99
|
+
// still comes as an array, a single one as a string, so both are normalized to an array.
|
|
100
|
+
coerce: (value) => (value === undefined ? [] : [value].flat()),
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Flags of `notify`, one target per call: posting to more places is calling it again. Some flags only fit one kind
|
|
105
|
+
* of input; `notify` fails on the others rather than ignoring them.
|
|
106
|
+
*/
|
|
107
|
+
const notifyOptions = {
|
|
108
|
+
'slack-channel': {
|
|
109
|
+
type: 'string',
|
|
110
|
+
describe: 'Slack channel to post to',
|
|
111
|
+
// yargs collects a repeated flag into an array, which would reach Slack as one comma-joined channel
|
|
112
|
+
coerce: (value) => {
|
|
113
|
+
if (Array.isArray(value)) {
|
|
114
|
+
throw new Error('--slack-channel takes one channel, call notify once for each channel');
|
|
115
|
+
}
|
|
116
|
+
return value;
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
on: {
|
|
120
|
+
choices: notifyOnChoices,
|
|
121
|
+
default: 'failure',
|
|
122
|
+
describe: 'Tests only: notify only when tests fail, or always',
|
|
123
|
+
},
|
|
124
|
+
title: {
|
|
125
|
+
type: 'string',
|
|
126
|
+
describe: 'Tests only: what the message calls the run, e.g. the CI workflow name',
|
|
127
|
+
},
|
|
128
|
+
'job-url': {
|
|
129
|
+
type: 'string',
|
|
130
|
+
describe: 'Tests only: link to the CI job, included in the message',
|
|
131
|
+
},
|
|
132
|
+
'repo-url': {
|
|
133
|
+
type: 'string',
|
|
134
|
+
describe: 'Releases only: the repository the release is named after. Defaults to the origin remote',
|
|
135
|
+
},
|
|
102
136
|
};
|
|
103
137
|
/** Global flags, available to every command. */
|
|
104
138
|
const globalOptions = {
|
|
@@ -113,21 +147,6 @@ await yargs()
|
|
|
113
147
|
.scriptName('public-actors-utils')
|
|
114
148
|
.options(globalOptions)
|
|
115
149
|
.middleware(middlewares)
|
|
116
|
-
.command('get-commits', '', (y) => y.options(gitRangeOptions), async (args) => {
|
|
117
|
-
const commits = await getCommits(args);
|
|
118
|
-
writeJson(commits);
|
|
119
|
-
})
|
|
120
|
-
.command('get-latest-commit', '', (y) => y.options(gitRangeOptions), async (args) => {
|
|
121
|
-
const commits = await getCommits(args);
|
|
122
|
-
if (commits.length > 0) {
|
|
123
|
-
writeJson(commits[commits.length - 1]);
|
|
124
|
-
}
|
|
125
|
-
})
|
|
126
|
-
.command('get-changed-files', '', (y) => y.options(gitRangeOptions), async (args) => {
|
|
127
|
-
const commits = await getCommits(args);
|
|
128
|
-
const changedFiles = await getChangedFiles(commits);
|
|
129
|
-
writeJson(changedFiles);
|
|
130
|
-
})
|
|
131
150
|
.command('get-actor-configs', '', (y) => y.options(actorSelectionOptions), async ({ actors, ignore }) => {
|
|
132
151
|
const actorConfigs = await readConfigFile({ actors, ignore });
|
|
133
152
|
writeJson(actorConfigs);
|
|
@@ -135,13 +154,35 @@ await yargs()
|
|
|
135
154
|
.command('get-affected-actors', 'Find the Actors whose context changed in a commit range ending at the checked-out HEAD', (y) => y.options(affectedRangeOptions).options(actorSelectionOptions), async (args) => {
|
|
136
155
|
writeJson(await getAffectedActors(args));
|
|
137
156
|
})
|
|
138
|
-
.command('
|
|
139
|
-
.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
157
|
+
.command('test [filters..]', 'Run the tests of the Actors listed on stdin (builds from build, or get-actor-configs for default builds), and print a report for notify', (y) => y
|
|
158
|
+
.positional('filters', {
|
|
159
|
+
type: 'string',
|
|
160
|
+
array: true,
|
|
161
|
+
default: ['test/platform'],
|
|
162
|
+
describe: 'Test files to run, as vitest filters',
|
|
163
|
+
})
|
|
164
|
+
.options(testOptions), async (args) => {
|
|
165
|
+
const report = await runTests({
|
|
166
|
+
filters: args.filters,
|
|
167
|
+
targets: parseTestTargets(await readStdin()),
|
|
168
|
+
vitestOutputFile: args.vitestOutputFile,
|
|
169
|
+
reporters: args.reporter,
|
|
170
|
+
});
|
|
171
|
+
writeJson(report);
|
|
172
|
+
// The report is printed either way, so `notify` later in the pipe still hears about the failure
|
|
173
|
+
if (!report.success)
|
|
174
|
+
process.exitCode = 1;
|
|
175
|
+
})
|
|
176
|
+
.command('notify', 'Tell the target about a test run (the output of test) or a release (of get-affected-actors) on stdin', (y) => y.options(notifyOptions).options(dryRunOptions), async (args) => {
|
|
177
|
+
await notify({
|
|
178
|
+
input: parseNotifyInput(await readStdin()),
|
|
179
|
+
slackChannel: args.slackChannel,
|
|
180
|
+
on: args.on,
|
|
181
|
+
title: args.title,
|
|
182
|
+
jobUrl: args.jobUrl,
|
|
183
|
+
repoUrl: args.repoUrl,
|
|
184
|
+
dryRun: args.dryRun,
|
|
185
|
+
});
|
|
145
186
|
})
|
|
146
187
|
.command('build', 'Build the Actors listed on stdin, as {"actors": [{"actorFullName": ...}]}, from the checked-out branch', (y) => y.options(buildOptions).options(repoUrlOptions).options(envVarsSyncOptions).options(dryRunOptions), async (args) => {
|
|
147
188
|
const input = parseBuildInput(await readStdin());
|
|
@@ -156,18 +197,6 @@ await yargs()
|
|
|
156
197
|
requireEnvVarsInSync: args.requireEnvVarsInSync,
|
|
157
198
|
});
|
|
158
199
|
writeJson(builds);
|
|
159
|
-
})
|
|
160
|
-
.command('notify-release', 'Announce a release on Slack, from the get-affected-actors output on stdin', (y) => y.options(releaseSlackOptions).options(repoUrlOptions).options(dryRunOptions), async (args) => {
|
|
161
|
-
const { commits, changedFiles, changelog } = parseReleaseChanges(await readStdin());
|
|
162
|
-
await notifyToSlack({
|
|
163
|
-
commits,
|
|
164
|
-
changedFiles,
|
|
165
|
-
changelog,
|
|
166
|
-
repoUrl: args.repoUrl,
|
|
167
|
-
dryRun: args.dryRun,
|
|
168
|
-
reportSlackChannel: args.reportSlackChannel,
|
|
169
|
-
releaseSlackChannel: args.releaseSlackChannel,
|
|
170
|
-
});
|
|
171
200
|
})
|
|
172
201
|
.command('build-from-local', '', (y) => y.options(actorSelectionOptions).options(envVarsSyncOptions).options(dryRunOptions), async ({ actors, ignore, dryRun, requireEnvVarsInSync }) => {
|
|
173
202
|
const actorConfigs = await readConfigFile({ actors, ignore });
|
package/dist/bin/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../bin/main.ts"],"names":[],"mappings":";AAEA,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,KAAuB,MAAM,OAAO,CAAC;AAC5C,gFAAgF;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../bin/main.ts"],"names":[],"mappings":";AAEA,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,KAAuB,MAAM,OAAO,CAAC;AAC5C,gFAAgF;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,GAAG,CAAC,CAAC,IAA8C,E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AE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE;IACjC,MAAM,YAAY,GAAG,MAAM,cAAc,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9D,MAAM,eAAe,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AACpD,CAAC,CACJ;KACA,cAAc,EAAE;KAChB,aAAa,CAAC,CAAC,EAAE,qBAAqB,CAAC;KACvC,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,aAAa,EAAE,EAAE;IAC9B,2FAA2F;IAC3F,yFAAyF;IACzF,yFAAyF;IACzF,IAAI,GAAG,EAAE,CAAC;QACN,MAAM,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5C,CAAC;SAAM,CAAC;QACJ,kEAAkE;QAClE,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;QACnC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC;KACD,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { NotifyInput, ReleaseChanges } from './stdin-input.js';
|
|
2
|
+
import type { TestReport } from './test-report.js';
|
|
3
|
+
export declare const notifyOnChoices: readonly ["failure", "always"];
|
|
4
|
+
type NotifyOn = (typeof notifyOnChoices)[number];
|
|
5
|
+
interface NotifyOptions {
|
|
6
|
+
input: NotifyInput;
|
|
7
|
+
slackChannel?: string;
|
|
8
|
+
/** Tests only */
|
|
9
|
+
on: NotifyOn;
|
|
10
|
+
/** Tests only: what the message calls the run, e.g. the CI workflow name */
|
|
11
|
+
title?: string;
|
|
12
|
+
/** Tests only: link to the CI job, included in the message */
|
|
13
|
+
jobUrl?: string;
|
|
14
|
+
/** Releases only, names the release. Defaults to the `origin` remote, see resolveRepoUrl */
|
|
15
|
+
repoUrl?: string;
|
|
16
|
+
dryRun: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** Tells the target about what is on stdin: a test run (the output of `test`) or a release (of `get-affected-actors`). */
|
|
19
|
+
export declare const notify: (options: NotifyOptions) => Promise<void>;
|
|
20
|
+
/** The release, named after the repository and the author of its newest commit, the pushed head. */
|
|
21
|
+
export declare const formatReleaseMessage: ({ commits, changelog }: ReleaseChanges, repoUrl: string) => string;
|
|
22
|
+
/**
|
|
23
|
+
* The message is the outcome and the first failure; the other failures go to its thread, so a channel with many
|
|
24
|
+
* failing runs stays readable.
|
|
25
|
+
*/
|
|
26
|
+
export declare const formatTestMessage: ({ report, title, jobUrl, }: {
|
|
27
|
+
report: TestReport;
|
|
28
|
+
title: string;
|
|
29
|
+
jobUrl?: string;
|
|
30
|
+
}) => {
|
|
31
|
+
text: string;
|
|
32
|
+
details: string[];
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=notify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notify.d.ts","sourceRoot":"","sources":["../../bin/notify.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnE,eAAO,MAAM,eAAe,gCAAiC,CAAC;AAC9D,KAAK,QAAQ,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAuBjD,UAAU,aAAa;IACnB,KAAK,EAAE,WAAW,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB;IACjB,EAAE,EAAE,QAAQ,CAAC;IACb,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4FAA4F;IAC5F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACnB;AAED,0HAA0H;AAC1H,eAAO,MAAM,MAAM,GAAU,SAAS,aAAa,kBAgBlD,CAAC;AA6DF,oGAAoG;AACpG,eAAO,MAAM,oBAAoB,GAAI,wBAAwB,cAAc,EAAE,SAAS,MAAM,WAiB3F,CAAC;AA6BF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,4BAI/B;IACC,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;;;CAgBA,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { getCommitUrl, getRepoName, resolveRepoUrl } from './git.js';
|
|
2
|
+
import { logger } from './logger.js';
|
|
3
|
+
import { getSlackClient, sendingLabel, sendSlackMessage } from './slack.js';
|
|
4
|
+
export const notifyOnChoices = ['failure', 'always'];
|
|
5
|
+
const SLACK_TOKEN_ENV_VAR = 'SLACK_BOT_TOKEN';
|
|
6
|
+
// Long enough for any sensible commit title, short enough that one runaway title doesn't swamp the message
|
|
7
|
+
const MAX_COMMIT_TITLE_LENGTH = 200;
|
|
8
|
+
/** Tells the target about what is on stdin: a test run (the output of `test`) or a release (of `get-affected-actors`). */
|
|
9
|
+
export const notify = async (options) => {
|
|
10
|
+
assertFlagsFitInput(options);
|
|
11
|
+
const { input, slackChannel, dryRun } = options;
|
|
12
|
+
// A target is created only once we know a message may go out, so a release with no commits needs no token
|
|
13
|
+
const createTarget = async () => {
|
|
14
|
+
if (!slackChannel) {
|
|
15
|
+
logger.info('Skipping notification, no --slack-channel passed');
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return createSlackTarget(SLACK_TOKEN_ENV_VAR, slackChannel, dryRun);
|
|
19
|
+
};
|
|
20
|
+
if (input.kind === 'tests') {
|
|
21
|
+
await notifyTestReport({ ...options, report: input.report, createTarget });
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
await notifyRelease({ ...options, changes: input.changes, createTarget });
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
/** A flag the input has no use for would be dropped silently, so it fails instead: the caller meant something by it. */
|
|
28
|
+
const assertFlagsFitInput = ({ input, on, title, jobUrl, repoUrl }) => {
|
|
29
|
+
const misfits = input.kind === 'tests'
|
|
30
|
+
? [repoUrl && '--repo-url']
|
|
31
|
+
: [on !== 'failure' && '--on', title && '--title', jobUrl && '--job-url'];
|
|
32
|
+
const passed = misfits.filter(Boolean);
|
|
33
|
+
if (passed.length > 0) {
|
|
34
|
+
const what = input.kind === 'tests'
|
|
35
|
+
? 'a test report (the output of test)'
|
|
36
|
+
: 'a release (the output of get-affected-actors)';
|
|
37
|
+
throw new Error(`${passed.join(', ')} can't be used with ${what} on stdin`);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
/** How a test run went: by default only when it failed, with `on: 'always'` always. */
|
|
41
|
+
const notifyTestReport = async ({ report, on, title, jobUrl, createTarget, }) => {
|
|
42
|
+
const target = await createTarget();
|
|
43
|
+
if (!target)
|
|
44
|
+
return;
|
|
45
|
+
if (report.success && on === 'failure') {
|
|
46
|
+
logger.info('The tests passed, so there is nothing to notify about (pass --on always to notify anyway)');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
await target.send(formatTestMessage({ report, title: title ?? '-', jobUrl }));
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* What a release changed: its changelog additions, then its commits, each linked to its commit page. Posts nothing
|
|
53
|
+
* when there are no commits, which means there is nothing new to release.
|
|
54
|
+
*/
|
|
55
|
+
const notifyRelease = async ({ changes: { commits, changelog }, repoUrl, createTarget, }) => {
|
|
56
|
+
if (commits.length === 0) {
|
|
57
|
+
logger.info('No new commits, so there is no release to announce');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (!changelog) {
|
|
61
|
+
logger.warn('No new changelog entries found, did you forget to update it?');
|
|
62
|
+
}
|
|
63
|
+
const target = await createTarget();
|
|
64
|
+
if (!target)
|
|
65
|
+
return;
|
|
66
|
+
const resolvedRepoUrl = (await resolveRepoUrl(repoUrl)).repoUrl;
|
|
67
|
+
await target.send({ text: formatReleaseMessage({ commits, changelog }, resolvedRepoUrl), details: [] });
|
|
68
|
+
};
|
|
69
|
+
/** The release, named after the repository and the author of its newest commit, the pushed head. */
|
|
70
|
+
export const formatReleaseMessage = ({ commits, changelog }, repoUrl) => {
|
|
71
|
+
const { author } = commits[commits.length - 1];
|
|
72
|
+
let text = `*${getRepoName(repoUrl)}* – New release (by ${displayName(author)}):\n\n`;
|
|
73
|
+
if (changelog)
|
|
74
|
+
text += `${changelog.trim()}\n\n`;
|
|
75
|
+
text += '*Commits*:\n';
|
|
76
|
+
text += commits
|
|
77
|
+
.map(({ sha, author: commitAuthor, message }, index) => {
|
|
78
|
+
const title = message.length > MAX_COMMIT_TITLE_LENGTH
|
|
79
|
+
? `${message.slice(0, MAX_COMMIT_TITLE_LENGTH - 1)}…`
|
|
80
|
+
: message;
|
|
81
|
+
const url = getCommitUrl(repoUrl, sha);
|
|
82
|
+
const linked = url ? `<${url}|${escapeSlack(title)}>` : escapeSlack(title);
|
|
83
|
+
return `${index + 1}. ${linked} – ${displayName(commitAuthor)}`;
|
|
84
|
+
})
|
|
85
|
+
.join('\n');
|
|
86
|
+
return text;
|
|
87
|
+
};
|
|
88
|
+
// Git authors come as "Name<email>", Slack only needs the name
|
|
89
|
+
const displayName = (author) => author.replace(/\s*<[^>]*>$/, '');
|
|
90
|
+
const createSlackTarget = async (tokenEnvVar, channel, dryRun) => {
|
|
91
|
+
const slack = await getSlackClient(tokenEnvVar, dryRun);
|
|
92
|
+
return {
|
|
93
|
+
async send({ text, details }) {
|
|
94
|
+
logger.info(`${sendingLabel(dryRun)} slack message to channel ${channel}:\n${text}`);
|
|
95
|
+
if (details.length > 0)
|
|
96
|
+
logger.info(`\tin its thread:\n\t${details.join('\n\t')}`);
|
|
97
|
+
if (!dryRun)
|
|
98
|
+
await sendSlackMessage(slack, channel, text, details);
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
// Slack reads these as markup, so they have to be escaped wherever text comes from the tests
|
|
103
|
+
const escapeSlack = (text) => text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
104
|
+
/** One line per failure message, linked to the run that failed, if the test started one. */
|
|
105
|
+
const formatFailures = ({ failureMessages, run }) => {
|
|
106
|
+
const link = run ? ` --- <${run.runLink}|${escapeSlack(run.actorId)}>` : '';
|
|
107
|
+
return failureMessages.map((message) => `${escapeSlack(message)}${link}`);
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* The message is the outcome and the first failure; the other failures go to its thread, so a channel with many
|
|
111
|
+
* failing runs stays readable.
|
|
112
|
+
*/
|
|
113
|
+
export const formatTestMessage = ({ report, title, jobUrl, }) => {
|
|
114
|
+
const { total, failed, passed } = report.summary;
|
|
115
|
+
const failedAssertions = report.tests.filter(({ status }) => status === 'failed').flatMap(formatFailures);
|
|
116
|
+
const failures = [...failedAssertions, ...report.errors.map((error) => `Error: ${escapeSlack(error)}`)];
|
|
117
|
+
const jobLink = jobUrl ? ` Check <${jobUrl}|the job>.` : '';
|
|
118
|
+
let text = `\`${escapeSlack(title)}\``;
|
|
119
|
+
if (report.success) {
|
|
120
|
+
text += `: all ${passed} tests passed.${jobLink}`;
|
|
121
|
+
return { text, details: [] };
|
|
122
|
+
}
|
|
123
|
+
text += `: has ${failedAssertions.length} failed assertions. Failing test suites: ${failed}/${total}.`;
|
|
124
|
+
if (report.errors.length > 0)
|
|
125
|
+
text += ` Errors outside of tests: ${report.errors.length}.`;
|
|
126
|
+
text += jobLink;
|
|
127
|
+
if (failures.length > 0)
|
|
128
|
+
text += `\n\n${failures[0]}`;
|
|
129
|
+
return { text, details: failures.slice(1).map((failure) => `• ${failure}`) };
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=notify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notify.js","sourceRoot":"","sources":["../../bin/notify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAI5E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAU,CAAC;AAmB9D,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAE9C,2GAA2G;AAC3G,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAgBpC,0HAA0H;AAC1H,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,EAAE,OAAsB,EAAE,EAAE;IACnD,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC7B,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAChD,0GAA0G;IAC1G,MAAM,YAAY,GAAG,KAAK,IAAI,EAAE;QAC5B,IAAI,CAAC,YAAY,EAAE,CAAC;YAChB,MAAM,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAC;YAChE,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,iBAAiB,CAAC,mBAAmB,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;IACxE,CAAC,CAAC;IACF,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QACzB,MAAM,gBAAgB,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IAC/E,CAAC;SAAM,CAAC;QACJ,MAAM,aAAa,CAAC,EAAE,GAAG,OAAO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AC,KAAK,EAAE,EAAE,CAAC,UAAU,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IACxG,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,WAAW,MAAM,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAE5D,IAAI,IAAI,GAAG,KAAK,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC;IACvC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACjB,IAAI,IAAI,SAAS,MAAM,iBAAiB,OAAO,EAAE,CAAC;QAClD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACjC,CAAC;IACD,IAAI,IAAI,SAAS,gBAAgB,CAAC,MAAM,4CAA4C,MAAM,IAAI,KAAK,GAAG,CAAC;IACvG,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,IAAI,IAAI,6BAA6B,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;IAC3F,IAAI,IAAI,OAAO,CAAC;IAChB,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,IAAI,IAAI,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IACtD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,OAAO,EAAE,CAAC,EAAE,CAAC;AACjF,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TestTarget } from './stdin-input.js';
|
|
2
|
+
import { type TestReport } from './test-report.js';
|
|
3
|
+
interface RunTestsOptions {
|
|
4
|
+
/** Vitest file filters, e.g. `test/platform/core` */
|
|
5
|
+
filters: string[];
|
|
6
|
+
/** The Actors to test, each with its build or, without one, its default build */
|
|
7
|
+
targets: TestTarget[];
|
|
8
|
+
/** Keeps vitest's own JSON report there, e.g. to upload it */
|
|
9
|
+
vitestOutputFile?: string;
|
|
10
|
+
/** Vitest reporters to add to the default one and the JSON one the report is read from, e.g. `github-actions` */
|
|
11
|
+
reporters?: string[];
|
|
12
|
+
cwd?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Runs the repository's vitest on the given builds and returns what happened as a `TestReport`. Vitest's own output
|
|
16
|
+
* goes to stderr, so stdout stays free for the report. A failing test or a crashing vitest is a failed report, not
|
|
17
|
+
* an error: the report is how the failure gets to `notify`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const runTests: ({ filters, targets, vitestOutputFile, reporters, cwd, }: RunTestsOptions) => Promise<TestReport>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=run-tests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-tests.d.ts","sourceRoot":"","sources":["../../bin/run-tests.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAkC,KAAK,UAAU,EAAuC,MAAM,kBAAkB,CAAC;AAoBxH,UAAU,eAAe;IACrB,qDAAqD;IACrD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,iFAAiF;IACjF,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,8DAA8D;IAC9D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iHAAiH;IACjH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAU,yDAM5B,eAAe,KAAG,OAAO,CAAC,UAAU,CA2DtC,CAAC"}
|