@piwitests/reporter 0.71.0 → 0.73.0
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/dist/cli/index.js +34 -12
- package/dist/index.js +258 -86
- package/dist/internal/capture/capture-fixtures.d.ts +2 -0
- package/dist/internal/capture/capture-fixtures.js +202 -60
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -3988,10 +3988,10 @@ async function planRequest(url, init, apiKey, what) {
|
|
|
3988
3988
|
}
|
|
3989
3989
|
return await res.json();
|
|
3990
3990
|
}
|
|
3991
|
-
function fetchPlanSources(options, projectId, selection, playwrightVersion) {
|
|
3991
|
+
function fetchPlanSources(options, projectId, selection, playwrightVersion, environment) {
|
|
3992
3992
|
return planRequest(
|
|
3993
3993
|
`${options.serverUrl}/api/projects/${projectId}/run-plans/sources`,
|
|
3994
|
-
{ method: "POST", body: JSON.stringify({ selection, playwrightVersion }) },
|
|
3994
|
+
{ method: "POST", body: JSON.stringify({ selection, playwrightVersion, environment }) },
|
|
3995
3995
|
options.apiKey,
|
|
3996
3996
|
"finding the passes to reuse"
|
|
3997
3997
|
);
|
|
@@ -8399,6 +8399,8 @@ Pass reuse (experimental, run only):
|
|
|
8399
8399
|
--reuse Skip each test whose code has not changed since it last
|
|
8400
8400
|
passed (see piwi plan); "full" plans the whole suite
|
|
8401
8401
|
--plan <id> Run the tests of a plan made by piwi plan
|
|
8402
|
+
--environment <key> The environment the run reports (env PIWI_ENVIRONMENT):
|
|
8403
|
+
only passes of that environment are reused
|
|
8402
8404
|
|
|
8403
8405
|
Behavior:
|
|
8404
8406
|
--strict Fail (exit 2) instead of falling back when unreachable
|
|
@@ -8421,7 +8423,8 @@ var VALUE_FLAGS3 = /* @__PURE__ */ new Set([
|
|
|
8421
8423
|
"--shard",
|
|
8422
8424
|
"--base",
|
|
8423
8425
|
"--pkg-runner",
|
|
8424
|
-
"--plan"
|
|
8426
|
+
"--plan",
|
|
8427
|
+
"--environment"
|
|
8425
8428
|
]);
|
|
8426
8429
|
function readOption7(argv, name) {
|
|
8427
8430
|
const withEquals = argv.find((arg) => arg.startsWith(`${name}=`));
|
|
@@ -8681,7 +8684,7 @@ async function runRunImpact(args, env) {
|
|
|
8681
8684
|
console.error(`piwi run: no tests impacted by ${impact.impact.changedFiles} changed file(s) \u2014 nothing to run`);
|
|
8682
8685
|
return EXIT_OK6;
|
|
8683
8686
|
}
|
|
8684
|
-
const
|
|
8687
|
+
const runEnv2 = {
|
|
8685
8688
|
...env,
|
|
8686
8689
|
PIWI_SELECTION: IMPACT_KEY,
|
|
8687
8690
|
PIWI_SELECTION_VERSION: "0",
|
|
@@ -8690,7 +8693,7 @@ async function runRunImpact(args, env) {
|
|
|
8690
8693
|
...shardEnv(args)
|
|
8691
8694
|
};
|
|
8692
8695
|
console.error(`piwi run: impact \u2192 ${impact.estimate.count} test(s)${lineLevelNote(impact)}`);
|
|
8693
|
-
return spawnPlaywrightForRun(args.pkgRunner, [...impact.materialization.args, ...args.extra],
|
|
8696
|
+
return spawnPlaywrightForRun(args.pkgRunner, [...impact.materialization.args, ...args.extra], runEnv2);
|
|
8694
8697
|
}
|
|
8695
8698
|
async function runRun(argv, env = process.env) {
|
|
8696
8699
|
if (argv.includes("-h") || argv.includes("--help")) {
|
|
@@ -8734,7 +8737,7 @@ async function runRun(argv, env = process.env) {
|
|
|
8734
8737
|
console.error(`piwi run: "${args.key}" resolved to 0 tests`);
|
|
8735
8738
|
return EXIT_ERROR7;
|
|
8736
8739
|
}
|
|
8737
|
-
const
|
|
8740
|
+
const runEnv2 = {
|
|
8738
8741
|
...env,
|
|
8739
8742
|
PIWI_SELECTION: resolution.key ?? args.key,
|
|
8740
8743
|
PIWI_SELECTION_VERSION: String(resolution.version ?? 0),
|
|
@@ -8745,7 +8748,7 @@ async function runRun(argv, env = process.env) {
|
|
|
8745
8748
|
console.error(
|
|
8746
8749
|
`piwi run: ${args.key} \u2192 ${resolution.estimate.count} tests${resolution.materialization.format !== args.format ? ` (materialized as ${resolution.materialization.format})` : ""}`
|
|
8747
8750
|
);
|
|
8748
|
-
return spawnPlaywrightForRun(args.pkgRunner, [...resolution.materialization.args, ...args.extra],
|
|
8751
|
+
return spawnPlaywrightForRun(args.pkgRunner, [...resolution.materialization.args, ...args.extra], runEnv2);
|
|
8749
8752
|
}
|
|
8750
8753
|
|
|
8751
8754
|
// src/cli/plan.ts
|
|
@@ -8773,6 +8776,10 @@ Connection:
|
|
|
8773
8776
|
--api-key <key> API key (env PIWI_API_KEY, .env)
|
|
8774
8777
|
--project <name|id> Project (env PIWI_PROJECT_NAME, .env)
|
|
8775
8778
|
|
|
8779
|
+
Run:
|
|
8780
|
+
--environment <key> The environment the run reports (env PIWI_ENVIRONMENT):
|
|
8781
|
+
only passes of that environment are reused
|
|
8782
|
+
|
|
8776
8783
|
Behavior:
|
|
8777
8784
|
--json Print the plan as JSON instead of its id
|
|
8778
8785
|
-h, --help Show this help
|
|
@@ -8788,7 +8795,8 @@ var REASON_LABELS = {
|
|
|
8788
8795
|
"open-cluster": "open failure",
|
|
8789
8796
|
quarantined: "quarantined",
|
|
8790
8797
|
"no-reuse-tag": "@no-reuse",
|
|
8791
|
-
serial: "serial group"
|
|
8798
|
+
serial: "serial group",
|
|
8799
|
+
"deployed-version-unknown": "deployed version unknown"
|
|
8792
8800
|
};
|
|
8793
8801
|
function parsePlanArgs(argv, env, command) {
|
|
8794
8802
|
const dashIndex = argv.indexOf("--");
|
|
@@ -8822,6 +8830,7 @@ function parsePlanArgs(argv, env, command) {
|
|
|
8822
8830
|
planId: planRaw === void 0 ? null : Number(planRaw),
|
|
8823
8831
|
reuse: own.includes("--reuse"),
|
|
8824
8832
|
shard,
|
|
8833
|
+
environment: (readOption7(own, "--environment") ?? env[PIWI_ENV_KEYS.environment])?.trim() || null,
|
|
8825
8834
|
strict: own.includes("--strict"),
|
|
8826
8835
|
json: own.includes("--json"),
|
|
8827
8836
|
pkgRunner: readOption7(own, "--pkg-runner") ?? "npx",
|
|
@@ -8870,7 +8879,7 @@ function formatPlanReasons(reasons) {
|
|
|
8870
8879
|
}
|
|
8871
8880
|
async function makePlan(args, projectId, key) {
|
|
8872
8881
|
const playwrightVersion = readInstalledPlaywrightVersion(process.cwd());
|
|
8873
|
-
const sources = await fetchPlanSources(args, projectId, key, playwrightVersion);
|
|
8882
|
+
const sources = await fetchPlanSources(args, projectId, key, playwrightVersion, args.environment);
|
|
8874
8883
|
const untracked = (tryGit(["ls-files", "--others", "--exclude-standard", "--full-name", "--", ":/"]) ?? "").split("\n").filter(Boolean);
|
|
8875
8884
|
const diffs = [];
|
|
8876
8885
|
for (const { commit } of sources.commits) {
|
|
@@ -8898,6 +8907,7 @@ async function makePlan(args, projectId, key) {
|
|
|
8898
8907
|
return createPlan(args, projectId, {
|
|
8899
8908
|
selection: key,
|
|
8900
8909
|
playwrightVersion,
|
|
8910
|
+
environment: args.environment,
|
|
8901
8911
|
commit: tryGit(["rev-parse", "HEAD"]),
|
|
8902
8912
|
branch: branch && branch !== "HEAD" ? branch : null,
|
|
8903
8913
|
worktree: worktreeState(),
|
|
@@ -8934,6 +8944,9 @@ async function runPlanCommand(argv, env = process.env) {
|
|
|
8934
8944
|
return EXIT_ERROR8;
|
|
8935
8945
|
}
|
|
8936
8946
|
}
|
|
8947
|
+
function runEnv(args, env) {
|
|
8948
|
+
return args.environment ? { ...env, [PIWI_ENV_KEYS.environment]: args.environment } : env;
|
|
8949
|
+
}
|
|
8937
8950
|
function isPlannedRun(argv) {
|
|
8938
8951
|
const dashIndex = argv.indexOf("--");
|
|
8939
8952
|
const own = dashIndex === -1 ? argv : argv.slice(0, dashIndex);
|
|
@@ -8957,11 +8970,20 @@ async function runStoredPlan(args, projectId, planId, env, madeHere) {
|
|
|
8957
8970
|
throw new Error(`plan ${planId} and this checkout must both match their commit to skip tests in another job`);
|
|
8958
8971
|
}
|
|
8959
8972
|
}
|
|
8973
|
+
const planned = plan.environment?.trim() || null;
|
|
8974
|
+
const named = args.environment;
|
|
8975
|
+
if (planned && named && planned.toLowerCase() !== named.toLowerCase()) {
|
|
8976
|
+
throw new Error(`plan ${planId} was made for the environment ${planned}, and this run names ${named}`);
|
|
8977
|
+
}
|
|
8960
8978
|
const shardArgs = args.shard ? [`--shard=${args.shard.replace(/\s+/g, "")}`] : [];
|
|
8961
8979
|
console.error(
|
|
8962
8980
|
`piwi run: plan ${planId}${args.shard ? ` (shard ${args.shard})` : ""} \u2192 ${plan.selection.key}, skipping ${plan.counts.reused} reused test(s)`
|
|
8963
8981
|
);
|
|
8964
|
-
const planEnv = {
|
|
8982
|
+
const planEnv = {
|
|
8983
|
+
...runEnv(args, env),
|
|
8984
|
+
...planned && !named ? { [PIWI_ENV_KEYS.environment]: planned } : {},
|
|
8985
|
+
[PIWI_PLAN_ENV]: String(planId)
|
|
8986
|
+
};
|
|
8965
8987
|
if (plan.skip.length === 0) {
|
|
8966
8988
|
return spawnPlaywrightForRun(args.pkgRunner, [...plan.args, ...shardArgs, ...args.extra], planEnv);
|
|
8967
8989
|
}
|
|
@@ -9025,12 +9047,12 @@ async function runPlannedRun(argv, env = process.env) {
|
|
|
9025
9047
|
function fallBack(args, argv, env, reason) {
|
|
9026
9048
|
if (args.reuse && args.key && args.key !== "full") {
|
|
9027
9049
|
console.error(`piwi run: ${reason} \u2014 running "${args.key}" without reuse`);
|
|
9028
|
-
return runRun(withoutReuse(argv), env);
|
|
9050
|
+
return runRun(withoutReuse(argv), runEnv(args, env));
|
|
9029
9051
|
}
|
|
9030
9052
|
console.error(
|
|
9031
9053
|
`piwi run: ${reason} \u2014 running the full suite${args.shard ? ` (all of it, not shard ${args.shard})` : ""}`
|
|
9032
9054
|
);
|
|
9033
|
-
return spawnPlaywrightForRun(args.pkgRunner, args.extra, env);
|
|
9055
|
+
return spawnPlaywrightForRun(args.pkgRunner, args.extra, runEnv(args, env));
|
|
9034
9056
|
}
|
|
9035
9057
|
|
|
9036
9058
|
// src/cli/preflight.ts
|