apify-test-tools 0.10.2-beta.2 → 0.10.2-beta.20
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/.gitattributes +1 -0
- package/.github/actionlint.yaml +11 -0
- package/.github/actions/checkout-restore-dependencies/action.yaml +58 -6
- package/.github/cli/apify-test-tools.mjs +135 -142
- package/.github/scripts/mask-config-secrets.sh +17 -0
- package/.github/scripts/run-with-apify-tokens.mjs +63 -103
- package/.github/workflows/_check_code.yaml +5 -21
- package/.github/workflows/_move_major_tag.yaml +2 -2
- package/.github/workflows/public_platform-tests-claude-investigate-and-fix.yaml +89 -8
- package/.github/workflows/public_platform-tests.yaml +68 -30
- package/.github/workflows/public_pr-build-test.yaml +77 -38
- package/.github/workflows/public_push-build-latest.yaml +49 -11
- package/.github/workflows/public_review.yaml +5 -4
- package/.github/workflows/public_stale-issues.yaml +51 -0
- package/.husky/pre-commit +4 -4
- package/.prettierignore +2 -1
- package/CHANGELOG.md +22 -0
- package/CONTRIBUTING.md +117 -17
- package/README.md +221 -595
- package/bin/actor-ids.ts +41 -0
- package/bin/affected-actors.ts +211 -0
- package/bin/build-from-local.ts +19 -1
- package/bin/build.ts +105 -39
- package/bin/diff-changes.ts +69 -36
- package/bin/diff-json-schema.ts +5 -6
- package/bin/git.ts +73 -175
- package/bin/main.ts +142 -189
- package/bin/notify.ts +198 -0
- package/bin/run-tests.ts +167 -0
- package/bin/slack.ts +16 -76
- package/bin/stdin-input.ts +156 -0
- package/bin/test-files-glob.ts +126 -0
- package/bin/test-report.ts +141 -140
- package/bin/types.ts +4 -7
- package/bin/utils/config/load-config.ts +20 -2
- package/bin/utils/config/parser.ts +40 -8
- package/bin/utils/config/structures/grouped.ts +2 -2
- package/bin/utils/config/structures/legacy.ts +1 -1
- package/dist/bin/actor-ids.d.ts +15 -0
- package/dist/bin/actor-ids.d.ts.map +1 -0
- package/dist/bin/actor-ids.js +30 -0
- package/dist/bin/actor-ids.js.map +1 -0
- package/dist/bin/affected-actors.d.ts +55 -0
- package/dist/bin/affected-actors.d.ts.map +1 -0
- package/dist/bin/affected-actors.js +142 -0
- package/dist/bin/affected-actors.js.map +1 -0
- package/dist/bin/build-from-local.d.ts +2 -1
- package/dist/bin/build-from-local.d.ts.map +1 -1
- package/dist/bin/build-from-local.js +6 -2
- package/dist/bin/build-from-local.js.map +1 -1
- package/dist/bin/build.d.ts +18 -5
- package/dist/bin/build.d.ts.map +1 -1
- package/dist/bin/build.js +74 -24
- package/dist/bin/build.js.map +1 -1
- package/dist/bin/diff-changes.d.ts +21 -5
- package/dist/bin/diff-changes.d.ts.map +1 -1
- package/dist/bin/diff-changes.js +41 -28
- 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 +26 -34
- package/dist/bin/git.d.ts.map +1 -1
- package/dist/bin/git.js +60 -143
- package/dist/bin/git.js.map +1 -1
- package/dist/bin/main.js +126 -140
- 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 +138 -0
- package/dist/bin/run-tests.js.map +1 -0
- package/dist/bin/slack.d.ts +2 -14
- package/dist/bin/slack.d.ts.map +1 -1
- package/dist/bin/slack.js +17 -46
- package/dist/bin/slack.js.map +1 -1
- package/dist/bin/stdin-input.d.ts +79 -0
- package/dist/bin/stdin-input.d.ts.map +1 -0
- package/dist/bin/stdin-input.js +124 -0
- package/dist/bin/stdin-input.js.map +1 -0
- package/dist/bin/test-files-glob.d.ts +18 -0
- package/dist/bin/test-files-glob.d.ts.map +1 -0
- package/dist/bin/test-files-glob.js +108 -0
- package/dist/bin/test-files-glob.js.map +1 -0
- 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 +4 -7
- package/dist/bin/types.d.ts.map +1 -1
- package/dist/bin/utils/config/load-config.d.ts +8 -0
- package/dist/bin/utils/config/load-config.d.ts.map +1 -1
- package/dist/bin/utils/config/load-config.js +14 -1
- package/dist/bin/utils/config/load-config.js.map +1 -1
- package/dist/bin/utils/config/parser.d.ts +15 -2
- package/dist/bin/utils/config/parser.d.ts.map +1 -1
- package/dist/bin/utils/config/parser.js +29 -8
- package/dist/bin/utils/config/parser.js.map +1 -1
- package/dist/bin/utils/config/structures/grouped.js +2 -2
- package/dist/bin/utils/config/structures/grouped.js.map +1 -1
- package/dist/bin/utils/config/structures/legacy.js +1 -1
- package/dist/bin/utils/config/structures/legacy.js.map +1 -1
- package/dist/lib/extend-expect.d.ts.map +1 -1
- package/dist/lib/extend-expect.js +37 -218
- package/dist/lib/extend-expect.js.map +1 -1
- package/dist/lib/lib.d.ts +1 -5
- package/dist/lib/lib.d.ts.map +1 -1
- package/dist/lib/lib.js +19 -31
- package/dist/lib/lib.js.map +1 -1
- package/dist/lib/run-checks.d.ts +14 -0
- package/dist/lib/run-checks.d.ts.map +1 -0
- package/dist/lib/run-checks.js +82 -0
- package/dist/lib/run-checks.js.map +1 -0
- package/dist/lib/run-test-result.d.ts +3 -6
- package/dist/lib/run-test-result.d.ts.map +1 -1
- package/dist/lib/run-test-result.js +41 -54
- package/dist/lib/run-test-result.js.map +1 -1
- package/dist/test/bundle/cli-bundle.test.js +76 -56
- package/dist/test/bundle/cli-bundle.test.js.map +1 -1
- package/dist/test/bundle/token-wrapper.test.d.ts +2 -0
- package/dist/test/bundle/token-wrapper.test.d.ts.map +1 -0
- package/dist/test/bundle/token-wrapper.test.js +80 -0
- package/dist/test/bundle/token-wrapper.test.js.map +1 -0
- package/dist/test/e2e/cli-bundle.e2e.test.js +33 -68
- 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/actor-filtering.test.js +7 -0
- package/dist/test/unit/bin/actor-filtering.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 +40 -0
- package/dist/test/unit/bin/actor-ids.test.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 +224 -0
- package/dist/test/unit/bin/affected-actors-cli.test.js.map +1 -0
- package/dist/test/unit/bin/affected-actors.test.d.ts +2 -0
- package/dist/test/unit/bin/affected-actors.test.d.ts.map +1 -0
- package/dist/test/unit/bin/affected-actors.test.js +153 -0
- package/dist/test/unit/bin/affected-actors.test.js.map +1 -0
- 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 +49 -0
- package/dist/test/unit/bin/build-cli.test.js.map +1 -0
- package/dist/test/unit/bin/build-from-local.test.js +12 -0
- package/dist/test/unit/bin/build-from-local.test.js.map +1 -1
- package/dist/test/unit/bin/build.test.js +116 -6
- 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 +23 -0
- package/dist/test/unit/bin/compiled-cli.js.map +1 -0
- package/dist/test/unit/bin/diff-changes.test.js +168 -114
- 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 +67 -288
- 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.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 +92 -0
- package/dist/test/unit/bin/stdin-input.test.js.map +1 -0
- 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 +146 -0
- package/dist/test/unit/bin/test-cli.test.js.map +1 -0
- package/dist/test/unit/bin/test-files-glob.test.d.ts +2 -0
- package/dist/test/unit/bin/test-files-glob.test.d.ts.map +1 -0
- package/dist/test/unit/bin/test-files-glob.test.js +102 -0
- package/dist/test/unit/bin/test-files-glob.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/test/unit/bin/utils/config/load-config.test.js +19 -1
- package/dist/test/unit/bin/utils/config/load-config.test.js.map +1 -1
- package/dist/test/unit/bin/utils/config/parser.test.js +36 -4
- package/dist/test/unit/bin/utils/config/parser.test.js.map +1 -1
- package/dist/test/unit/bin/utils/config/structures/grouped.test.js +6 -0
- package/dist/test/unit/bin/utils/config/structures/grouped.test.js.map +1 -1
- package/dist/test/unit/bin/utils/config/structures/legacy.test.js +1 -0
- package/dist/test/unit/bin/utils/config/structures/legacy.test.js.map +1 -1
- package/dist/test/unit/github-scripts/mask-config-secrets.test.d.ts +2 -0
- package/dist/test/unit/github-scripts/mask-config-secrets.test.d.ts.map +1 -0
- package/dist/test/unit/github-scripts/mask-config-secrets.test.js +50 -0
- package/dist/test/unit/github-scripts/mask-config-secrets.test.js.map +1 -0
- package/dist/test/unit/github-scripts/run-with-apify-tokens.test.d.ts +2 -0
- package/dist/test/unit/github-scripts/run-with-apify-tokens.test.d.ts.map +1 -0
- package/dist/test/unit/github-scripts/run-with-apify-tokens.test.js +102 -0
- package/dist/test/unit/github-scripts/run-with-apify-tokens.test.js.map +1 -0
- package/dist/test/unit/run-checks.test.d.ts +2 -0
- package/dist/test/unit/run-checks.test.d.ts.map +1 -0
- package/dist/test/unit/run-checks.test.js +62 -0
- package/dist/test/unit/run-checks.test.js.map +1 -0
- package/dist/test/unit/run-test-result.test.d.ts +2 -0
- package/dist/test/unit/run-test-result.test.d.ts.map +1 -0
- package/dist/test/unit/run-test-result.test.js +34 -0
- package/dist/test/unit/run-test-result.test.js.map +1 -0
- package/dist/test/unit/should-built-and-test.test.js +41 -38
- package/dist/test/unit/should-built-and-test.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/workflow-scripts-src/run-with-apify-tokens.d.ts +3 -0
- package/dist/workflow-scripts-src/run-with-apify-tokens.d.ts.map +1 -0
- package/dist/workflow-scripts-src/run-with-apify-tokens.js +100 -0
- package/dist/workflow-scripts-src/run-with-apify-tokens.js.map +1 -0
- package/docs/cli.md +469 -0
- package/docs/lib.md +276 -0
- package/docs/workflows.md +455 -0
- package/eslint.config.mjs +10 -1
- package/lib/extend-expect.ts +48 -258
- package/lib/lib.ts +25 -34
- package/lib/run-checks.ts +101 -0
- package/lib/run-test-result.ts +45 -55
- package/package.json +4 -2
- package/platform-tests-investigate-and-fix/skills/assess-impact/SKILL.md +42 -0
- package/platform-tests-investigate-and-fix/skills/measure-flakiness/SKILL.md +4 -2
- package/test/bundle/cli-bundle.test.ts +97 -67
- package/test/bundle/token-wrapper.test.ts +110 -0
- package/test/e2e/cli-bundle.e2e.test.ts +60 -93
- package/test/e2e/git-build-release.e2e.test.ts +113 -0
- package/test/e2e/helpers.ts +82 -0
- package/test/unit/bin/actor-filtering.test.ts +8 -0
- package/test/unit/bin/actor-ids.test.ts +47 -0
- package/test/unit/bin/affected-actors-cli.test.ts +271 -0
- package/test/unit/bin/affected-actors.test.ts +221 -0
- package/test/unit/bin/build-cli.test.ts +61 -0
- package/test/unit/bin/build-from-local.test.ts +16 -0
- package/test/unit/bin/build.test.ts +149 -5
- package/test/unit/bin/compiled-cli.ts +23 -0
- package/test/unit/bin/diff-changes.test.ts +181 -114
- package/test/unit/bin/diff.test.ts +25 -28
- package/test/unit/bin/git.test.ts +76 -361
- package/test/unit/bin/notify.test.ts +299 -0
- package/test/unit/bin/stdin-input.test.ts +120 -0
- package/test/unit/bin/test-cli.test.ts +175 -0
- package/test/unit/bin/test-files-glob.test.ts +118 -0
- package/test/unit/bin/test-report.test.ts +118 -0
- package/test/unit/bin/utils/config/load-config.test.ts +26 -1
- package/test/unit/bin/utils/config/parser.test.ts +46 -5
- package/test/unit/bin/utils/config/structures/grouped.test.ts +12 -0
- package/test/unit/bin/utils/config/structures/legacy.test.ts +1 -0
- package/test/unit/github-scripts/mask-config-secrets.test.ts +61 -0
- package/test/unit/github-scripts/run-with-apify-tokens.test.ts +115 -0
- package/test/unit/run-checks.test.ts +76 -0
- package/test/unit/run-test-result.test.ts +44 -0
- package/test/unit/should-built-and-test.test.ts +46 -39
- package/tsconfig.json +1 -1
- package/vitest.config.ts +9 -0
- package/workflow-scripts-src/run-with-apify-tokens.ts +112 -0
- package/.github/scripts/check-major-tag-refs.mjs +0 -72
- 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 -54
- 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 -65
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
|
|
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,O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CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACvB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,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
|
@@ -3,14 +3,14 @@ import process from 'node:process';
|
|
|
3
3
|
import yargs from 'yargs';
|
|
4
4
|
// eslint-disable-next-line import/extensions --- With .js, it cannot find types
|
|
5
5
|
import { hideBin } from 'yargs/helpers';
|
|
6
|
-
import {
|
|
6
|
+
import { getAffectedActors } from './affected-actors.js';
|
|
7
|
+
import { buildActors, DEFAULT_VERSION_KEYWORD, deleteOldBuilds } from './build.js';
|
|
7
8
|
import { runBuildsFromLocal } from './build-from-local.js';
|
|
8
|
-
import { getChangedActors } from './diff-changes.js';
|
|
9
|
-
import { getBranchOnlyChangedFiles, getChangedFiles, getCommits, getCurrentBranch, getReleaseChanges, getRepoName, hasMergeFromTarget, resolveReleaseBaseCommit, resolveRepoUrl, } 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 {
|
|
12
|
+
import { runTests } from './run-tests.js';
|
|
13
|
+
import { parseBuildInput, parseNotifyInput, parseTestTargets, readStdin } from './stdin-input.js';
|
|
14
14
|
import { readConfigFile } from './utils/config/load-config.js';
|
|
15
15
|
/**
|
|
16
16
|
* Middlewares to be run before every command execution
|
|
@@ -18,16 +18,10 @@ import { readConfigFile } from './utils/config/load-config.js';
|
|
|
18
18
|
const middlewares = [(args) => logger.setLevel(args.logLevel)];
|
|
19
19
|
/*
|
|
20
20
|
* Option groups shared across commands. Each is a plain object passed to `.options()`, so a command's
|
|
21
|
-
* builder composes them by chaining (`y.options(
|
|
21
|
+
* builder composes them by chaining (`y.options(affectedRangeOptions).options(actorSelectionOptions)`)
|
|
22
22
|
* instead of nesting wrapper functions. `as const` keeps literals like `demandOption: true` so yargs
|
|
23
23
|
* can infer non-optional types; `satisfies` validates the shape without widening it.
|
|
24
24
|
*/
|
|
25
|
-
/** Commit range to inspect: everything on `source-branch` since it diverged from `target-branch`. */
|
|
26
|
-
const gitRangeOptions = {
|
|
27
|
-
'target-branch': { type: 'string', demandOption: true },
|
|
28
|
-
'source-branch': { type: 'string', demandOption: true },
|
|
29
|
-
'base-commit': { type: 'string', demandOption: false },
|
|
30
|
-
};
|
|
31
25
|
/**
|
|
32
26
|
* Where to build the Actors from. Defaults to the `origin` remote, which is then checked against each
|
|
33
27
|
* Actor's default version. Passing it explicitly skips that check (see assertRepoUrlMatchesDefaultVersion).
|
|
@@ -38,12 +32,23 @@ const repoUrlOptions = {
|
|
|
38
32
|
/**
|
|
39
33
|
* Actor-selection flags, applied to every command that reads the actor config so a caller can
|
|
40
34
|
* narrow the set it operates on (e.g. two-stage releases: `--ignore X`, then `--actors X`).
|
|
41
|
-
*
|
|
42
|
-
*/
|
|
35
|
+
* */
|
|
43
36
|
const actorSelectionOptions = {
|
|
44
37
|
actors: { type: 'string', array: true, default: [] },
|
|
45
38
|
ignore: { type: 'string', array: true, default: [] },
|
|
46
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Commit range for get-affected-actors, which always ends at the checked-out HEAD. `base` and `since` combine:
|
|
42
|
+
* `base` alone is a branch's own commits (a PR), `since` alone is everything after a commit (a release), both is
|
|
43
|
+
* a branch after its last validated commit.
|
|
44
|
+
*/
|
|
45
|
+
const affectedRangeOptions = {
|
|
46
|
+
base: { type: 'string', describe: 'Only count commits on HEAD that are not on this branch' },
|
|
47
|
+
since: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
describe: 'Only count commits after this one. Ignored with --base if it is not on the branch',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
47
52
|
/**
|
|
48
53
|
* For commands that change something (builds, deletes, Slack posts). A dry run still does every read and check
|
|
49
54
|
* the real run does, credentials included, and only skips the writes. So it needs the same tokens, though
|
|
@@ -56,9 +61,78 @@ const dryRunOptions = {
|
|
|
56
61
|
describe: 'Do every read and check (tokens included) but change nothing; print what would be done',
|
|
57
62
|
},
|
|
58
63
|
};
|
|
59
|
-
/** Flags
|
|
64
|
+
/** Flags of `build`, which builds exactly the Actors it is given. */
|
|
60
65
|
const buildOptions = {
|
|
61
|
-
'
|
|
66
|
+
'version-number': {
|
|
67
|
+
type: 'string',
|
|
68
|
+
demandOption: true,
|
|
69
|
+
describe: `Version to build, like 0.1, or "${DEFAULT_VERSION_KEYWORD}" for each Actor's default version`,
|
|
70
|
+
coerce: (value) => {
|
|
71
|
+
if (value !== DEFAULT_VERSION_KEYWORD && !/^\d+\.\d+$/.test(value)) {
|
|
72
|
+
throw new Error(`--version-number must look like 0.1 or be "${DEFAULT_VERSION_KEYWORD}", got "${value}"`);
|
|
73
|
+
}
|
|
74
|
+
return value;
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
/** For the commands that build a version other than the default one, see assertEnvVarsMatchDefaultVersion. */
|
|
79
|
+
const envVarsSyncOptions = {
|
|
80
|
+
'require-env-vars-in-sync': {
|
|
81
|
+
type: 'boolean',
|
|
82
|
+
default: false,
|
|
83
|
+
describe: "Fail unless the built version's env var names match the default version's",
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
/** Flags of `test`, which runs the repository's vitest on the Actors piped in, e.g. the builds from `build`. */
|
|
87
|
+
const testOptions = {
|
|
88
|
+
'test-files-glob': {
|
|
89
|
+
type: 'string',
|
|
90
|
+
default: 'test/platform/**',
|
|
91
|
+
describe: 'Glob (from the repo root) of the test files to run. Quote it, so the shell does not expand it',
|
|
92
|
+
},
|
|
93
|
+
'vitest-output-file': { type: 'string', describe: "Also keep vitest's own JSON report there, e.g. to upload it" },
|
|
94
|
+
reporter: {
|
|
95
|
+
type: 'string',
|
|
96
|
+
describe: 'Vitest reporter (https://vitest.dev/guide/reporters) to add to `default` and `json`, which are always on, ' +
|
|
97
|
+
'e.g. github-actions. Repeat it for more',
|
|
98
|
+
// A plain string, not `array: true`: yargs would fill an array option with the arguments after it too. A
|
|
99
|
+
// repeated flag 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
|
+
},
|
|
62
136
|
};
|
|
63
137
|
/** Global flags, available to every command. */
|
|
64
138
|
const globalOptions = {
|
|
@@ -69,146 +143,58 @@ const globalOptions = {
|
|
|
69
143
|
describe: 'Minimum diagnostic level written to stderr; silent disables logging',
|
|
70
144
|
},
|
|
71
145
|
};
|
|
72
|
-
const resolveChangedActors = async (config, { isLatest }) => {
|
|
73
|
-
const actorConfigs = await readConfigFile(config);
|
|
74
|
-
// This is an optimization for the common case where a branch only has cosmetic changes but had to smerge in
|
|
75
|
-
// functional changes from master (being up-to-date is a CI requirement). Master is already validated, and
|
|
76
|
-
// since the branch has no functional changes of its own, there is nothing new to validate.
|
|
77
|
-
// Exception: if the branch has any functional changes alongside the merge, we must re-test — even
|
|
78
|
-
// individually validated changes can have novel interactions when combined.
|
|
79
|
-
if (await hasMergeFromTarget(config.sourceBranch, config.targetBranch)) {
|
|
80
|
-
logger.info('[MERGE-FROM-TARGET-OPTIMIZATION]: There is merge from target branch, checking if there are no functional changes in our own branch. If so, we can skip tests');
|
|
81
|
-
const branchOnlyFiles = await getBranchOnlyChangedFiles(config.sourceBranch, config.targetBranch);
|
|
82
|
-
// Omit baseCommit to get full branch history. Validated functional commits can still interact with merged ones
|
|
83
|
-
const allBranchCommits = await getCommits({ ...config, baseCommit: undefined });
|
|
84
|
-
const branchOnlyActorsChanged = await getChangedActors({
|
|
85
|
-
filepathsChanged: branchOnlyFiles,
|
|
86
|
-
actorConfigs,
|
|
87
|
-
commits: allBranchCommits,
|
|
88
|
-
testFilesGlob: config.testFilesGlob,
|
|
89
|
-
});
|
|
90
|
-
if (branchOnlyActorsChanged.length === 0) {
|
|
91
|
-
logger.info('[MERGE-FROM-TARGET-OPTIMIZATION]: Branch itself has no functional changes, skipping tests');
|
|
92
|
-
return [];
|
|
93
|
-
}
|
|
94
|
-
logger.info(`[MERGE-FROM-TARGET-OPTIMIZATION]: Branch has ${branchOnlyActorsChanged.length} functional changes, cannot optimize, we continue with full check`);
|
|
95
|
-
}
|
|
96
|
-
// If the optimization doesn't apply, we check all branch commits including merges for full coverage. We don't reuse the merge optimization results because here we can apply baseCommit and check merge commits (they might be functional or just cosmetic)
|
|
97
|
-
const commits = await getCommits(config);
|
|
98
|
-
const changedFiles = await getChangedFiles(commits);
|
|
99
|
-
return getChangedActors({
|
|
100
|
-
filepathsChanged: changedFiles,
|
|
101
|
-
actorConfigs,
|
|
102
|
-
isLatest,
|
|
103
|
-
commits,
|
|
104
|
-
testFilesGlob: config.testFilesGlob,
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
146
|
await yargs()
|
|
108
147
|
.scriptName('public-actors-utils')
|
|
109
148
|
.options(globalOptions)
|
|
110
149
|
.middleware(middlewares)
|
|
111
|
-
.command('get-commits', '', (y) => y.options(gitRangeOptions), async (args) => {
|
|
112
|
-
const commits = await getCommits(args);
|
|
113
|
-
writeJson(commits);
|
|
114
|
-
})
|
|
115
|
-
.command('get-latest-commit', '', (y) => y.options(gitRangeOptions), async (args) => {
|
|
116
|
-
const commits = await getCommits(args);
|
|
117
|
-
if (commits.length > 0) {
|
|
118
|
-
writeJson(commits[commits.length - 1]);
|
|
119
|
-
}
|
|
120
|
-
})
|
|
121
|
-
.command('get-changed-files', '', (y) => y.options(gitRangeOptions), async (args) => {
|
|
122
|
-
const commits = await getCommits(args);
|
|
123
|
-
const changedFiles = await getChangedFiles(commits);
|
|
124
|
-
writeJson(changedFiles);
|
|
125
|
-
})
|
|
126
150
|
.command('get-actor-configs', '', (y) => y.options(actorSelectionOptions), async ({ actors, ignore }) => {
|
|
127
151
|
const actorConfigs = await readConfigFile({ actors, ignore });
|
|
128
152
|
writeJson(actorConfigs);
|
|
129
153
|
})
|
|
130
|
-
.command('get-affected-actors', '', (y) => y.options(
|
|
131
|
-
|
|
132
|
-
writeJson(actorsChanged);
|
|
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) => {
|
|
155
|
+
writeJson(await getAffectedActors(args));
|
|
133
156
|
})
|
|
134
|
-
.command('
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
157
|
+
.command('test', '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.options(testOptions), async (args) => {
|
|
158
|
+
const report = await runTests({
|
|
159
|
+
testFilesGlob: args.testFilesGlob,
|
|
160
|
+
targets: parseTestTargets(await readStdin()),
|
|
161
|
+
vitestOutputFile: args.vitestOutputFile,
|
|
162
|
+
reporters: args.reporter,
|
|
163
|
+
});
|
|
164
|
+
writeJson(report);
|
|
165
|
+
// The report is printed either way, so `notify` later in the pipe still hears about the failure
|
|
166
|
+
if (!report.success)
|
|
167
|
+
process.exitCode = 1;
|
|
141
168
|
})
|
|
142
|
-
.command('
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
...(await resolveRepoUrl(config.repoUrl)),
|
|
152
|
-
actorConfigs: actorsChanged,
|
|
153
|
-
branch: config.sourceBranch.replace('origin/', ''),
|
|
154
|
-
dryRun: config.dryRun,
|
|
155
|
-
useDockerCache: config.useDockerCache,
|
|
169
|
+
.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) => {
|
|
170
|
+
await notify({
|
|
171
|
+
input: parseNotifyInput(await readStdin()),
|
|
172
|
+
slackChannel: args.slackChannel,
|
|
173
|
+
on: args.on,
|
|
174
|
+
title: args.title,
|
|
175
|
+
jobUrl: args.jobUrl,
|
|
176
|
+
repoUrl: args.repoUrl,
|
|
177
|
+
dryRun: args.dryRun,
|
|
156
178
|
});
|
|
157
|
-
writeJson(builds);
|
|
158
179
|
})
|
|
159
|
-
.command('
|
|
160
|
-
|
|
161
|
-
.
|
|
162
|
-
.
|
|
163
|
-
.
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
.option('base-commit', { type: 'string', demandOption: true })
|
|
167
|
-
.option('report-slack-channel', { type: 'string' })
|
|
168
|
-
.option('release-slack-channel', { type: 'string' }), async (args) => {
|
|
169
|
-
const baseSha = await resolveReleaseBaseCommit(args.baseCommit);
|
|
170
|
-
const branch = await getCurrentBranch();
|
|
171
|
-
const changes = await getReleaseChanges(baseSha);
|
|
172
|
-
if (!changes) {
|
|
173
|
-
logger.info(`HEAD is the base commit ${baseSha}, there is nothing new to release`);
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
const { commits, changedFiles, changelog } = changes;
|
|
177
|
-
const { repoUrl, shouldVerifyRepoUrl } = await resolveRepoUrl(args.repoUrl);
|
|
178
|
-
const isLatest = true;
|
|
179
|
-
const actorConfigs = await readConfigFile(args);
|
|
180
|
-
const actorsChanged = await getChangedActors({
|
|
181
|
-
filepathsChanged: changedFiles,
|
|
180
|
+
.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) => {
|
|
181
|
+
const input = parseBuildInput(await readStdin());
|
|
182
|
+
const names = input.actors.map(({ actorFullName }) => actorFullName);
|
|
183
|
+
// An empty --actors selects every Actor, but an empty list here means there is nothing to build. The configs
|
|
184
|
+
// are picked by name, so an Actor listed twice (e.g. in two lists of get-affected-actors) is built once
|
|
185
|
+
const actorConfigs = names.length > 0 ? await readConfigFile({ actors: names, ignore: [] }) : [];
|
|
186
|
+
const builds = await buildActors({
|
|
182
187
|
actorConfigs,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const builds = await runBuilds({
|
|
188
|
-
isLatest,
|
|
189
|
-
repoUrl,
|
|
190
|
-
shouldVerifyRepoUrl,
|
|
191
|
-
actorConfigs: actorsChanged,
|
|
192
|
-
branch,
|
|
193
|
-
dryRun,
|
|
194
|
-
useDockerCache: args.useDockerCache,
|
|
195
|
-
});
|
|
196
|
-
logger.info(JSON.stringify(builds));
|
|
197
|
-
await notifyToSlack({
|
|
198
|
-
changedFiles,
|
|
199
|
-
commits,
|
|
200
|
-
changelog,
|
|
201
|
-
repository: getRepoName(repoUrl),
|
|
202
|
-
dryRun,
|
|
203
|
-
// The newest commit, same as the pushed head commit
|
|
204
|
-
author: commits[commits.length - 1].author,
|
|
205
|
-
reportSlackChannel,
|
|
206
|
-
releaseSlackChannel,
|
|
188
|
+
versionNumber: args.versionNumber,
|
|
189
|
+
repoUrl: args.repoUrl,
|
|
190
|
+
dryRun: args.dryRun,
|
|
191
|
+
requireEnvVarsInSync: args.requireEnvVarsInSync,
|
|
207
192
|
});
|
|
193
|
+
writeJson(builds);
|
|
208
194
|
})
|
|
209
|
-
.command('build-from-local', '', (y) => y.options(actorSelectionOptions).options(dryRunOptions), async ({ actors, ignore, dryRun }) => {
|
|
195
|
+
.command('build-from-local', '', (y) => y.options(actorSelectionOptions).options(envVarsSyncOptions).options(dryRunOptions), async ({ actors, ignore, dryRun, requireEnvVarsInSync }) => {
|
|
210
196
|
const actorConfigs = await readConfigFile({ actors, ignore });
|
|
211
|
-
const builds = await runBuildsFromLocal({ actorConfigs, dryRun });
|
|
197
|
+
const builds = await runBuildsFromLocal({ actorConfigs, dryRun, requireEnvVarsInSync });
|
|
212
198
|
writeJson(builds);
|
|
213
199
|
})
|
|
214
200
|
.command('delete-old-builds', '', (y) => y.options(actorSelectionOptions).options(dryRunOptions), async ({ actors, ignore, dryRun }) => {
|
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,
|
|
1
|
+
{"version":3,"file":"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,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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