allure 3.9.0 → 3.11.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/README.md +16 -1
- package/dist/commands/agent-run.d.ts +21 -0
- package/dist/commands/agent-run.js +151 -0
- package/dist/commands/agent.d.ts +38 -15
- package/dist/commands/agent.js +288 -219
- package/dist/commands/open.js +2 -2
- package/dist/commands/run.js +0 -18
- package/dist/index.js +16 -3
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -2
- package/package.json +28 -28
- package/dist/utils/agent-select.d.ts +0 -41
- package/dist/utils/agent-select.js +0 -141
- package/dist/utils/agent-state.d.ts +0 -15
- package/dist/utils/agent-state.js +0 -83
package/README.md
CHANGED
|
@@ -74,7 +74,21 @@ For example:
|
|
|
74
74
|
npx allure agent -- npm test
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
`allure agent` runs with an agent-only profile by default. It creates a fresh output directory automatically, can load an expectations file with `--expectations
|
|
77
|
+
`allure agent` runs with an agent-only profile by default. It creates a fresh output directory automatically, accepts compact inline expectations such as `--goal`, `--expect-tests`, `--expect-test`, `--expect-label`, and `--expect-step-containing`, and can still load an expectations file with `--expectations` when needed. Configured presentation or export plugins such as Awesome or TestOps are ignored for that run.
|
|
78
|
+
|
|
79
|
+
Agents and setup tools can inspect the local structured capability contract without scraping help text:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npx allure agent capabilities --json
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
After a run, agents can query the output directory without manually reading every manifest:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
npx allure agent query --latest summary
|
|
89
|
+
npx allure agent query --latest tests --status failed
|
|
90
|
+
npx allure agent query --from ./agent-output findings --severity high
|
|
91
|
+
```
|
|
78
92
|
|
|
79
93
|
### Generating Reports Manually
|
|
80
94
|
|
|
@@ -118,6 +132,7 @@ The Allure CLI includes several helpful global options. Use `--help` to explore
|
|
|
118
132
|
|
|
119
133
|
```bash
|
|
120
134
|
npx allure run --help
|
|
135
|
+
npx allure agent capabilities --json
|
|
121
136
|
npx allure agent --help
|
|
122
137
|
npx allure watch --help
|
|
123
138
|
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { writeLatestAgentState, type AgentExpectationsInput } from "@allurereport/plugin-agent";
|
|
2
|
+
export declare const formatAgentCommand: (args: string[]) => string;
|
|
3
|
+
export declare const printAgentOutputLinks: (outputDir: string) => void;
|
|
4
|
+
export declare const persistLatestAgentState: (value: Parameters<typeof writeLatestAgentState>[0]) => Promise<void>;
|
|
5
|
+
export type ExecuteAgentModeParams = {
|
|
6
|
+
configPath?: string;
|
|
7
|
+
cwd?: string;
|
|
8
|
+
output?: string;
|
|
9
|
+
expectations?: string;
|
|
10
|
+
inlineExpectations?: AgentExpectationsInput;
|
|
11
|
+
environment?: string;
|
|
12
|
+
environmentName?: string;
|
|
13
|
+
silent?: boolean;
|
|
14
|
+
rerunFrom?: string;
|
|
15
|
+
rerunLatest?: boolean;
|
|
16
|
+
rerunPreset?: string;
|
|
17
|
+
rerunEnvironments?: string[];
|
|
18
|
+
rerunLabels?: string[];
|
|
19
|
+
args: string[];
|
|
20
|
+
};
|
|
21
|
+
export declare const executeAgentMode: (params: ExecuteAgentModeParams) => Promise<void>;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import * as console from "node:console";
|
|
2
|
+
import { mkdtemp, realpath, rm } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join, resolve } from "node:path";
|
|
5
|
+
import process, { exit } from "node:process";
|
|
6
|
+
import { AllureReport, isFileNotFoundError, readConfig } from "@allurereport/core";
|
|
7
|
+
import { createAgentTestPlanContext, AgentUsageError, formatAgentOutputLinks, isPathInside, normalizeAgentRerunPreset, parseAgentLabelFilters, resolveAgentStateDir, writeLatestAgentState, } from "@allurereport/plugin-agent";
|
|
8
|
+
import { normalizeCommandEnvironmentOptions, resolveCommandEnvironment } from "../utils/environment.js";
|
|
9
|
+
import { createChildAllureCliEnvironment, getActiveAllureCliCommand } from "../utils/execution-context.js";
|
|
10
|
+
import { executeAllureRun, executeNestedAllureCommand } from "./commons/run.js";
|
|
11
|
+
export const formatAgentCommand = (args) => args.join(" ");
|
|
12
|
+
export const printAgentOutputLinks = (outputDir) => {
|
|
13
|
+
for (const line of formatAgentOutputLinks(outputDir)) {
|
|
14
|
+
console.log(line);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export const persistLatestAgentState = async (value) => {
|
|
18
|
+
try {
|
|
19
|
+
await writeLatestAgentState(value);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error(`Could not update latest agent output in ${resolveAgentStateDir(value.cwd)}: ${error.message}`);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
export const executeAgentMode = async (params) => {
|
|
26
|
+
const { configPath, cwd: configuredCwd, output, expectations, inlineExpectations, environment, environmentName, silent, rerunFrom, rerunLatest, rerunPreset, rerunEnvironments, rerunLabels, args, } = params;
|
|
27
|
+
const command = args[0];
|
|
28
|
+
const commandArgs = args.slice(1);
|
|
29
|
+
const cwd = await realpath(configuredCwd ?? process.cwd());
|
|
30
|
+
const commandString = formatAgentCommand(args);
|
|
31
|
+
const hasRerunSource = !!rerunFrom || !!rerunLatest;
|
|
32
|
+
const hasRerunFilters = !!rerunPreset || !!rerunEnvironments?.length || !!rerunLabels?.length;
|
|
33
|
+
if (!hasRerunSource && hasRerunFilters) {
|
|
34
|
+
throw new AgentUsageError("Use rerun filters only together with --rerun-from <path> or --rerun-latest");
|
|
35
|
+
}
|
|
36
|
+
const rerunContext = await createAgentTestPlanContext({
|
|
37
|
+
cwd,
|
|
38
|
+
from: rerunFrom,
|
|
39
|
+
latest: rerunLatest,
|
|
40
|
+
preset: normalizeAgentRerunPreset(rerunPreset),
|
|
41
|
+
environments: rerunEnvironments?.length ? rerunEnvironments : undefined,
|
|
42
|
+
labelFilters: parseAgentLabelFilters(rerunLabels),
|
|
43
|
+
});
|
|
44
|
+
const childEnvironmentVariables = {
|
|
45
|
+
...createChildAllureCliEnvironment("agent"),
|
|
46
|
+
...(rerunContext ? { ALLURE_TESTPLAN_PATH: rerunContext.testPlanPath } : {}),
|
|
47
|
+
};
|
|
48
|
+
try {
|
|
49
|
+
if (getActiveAllureCliCommand()) {
|
|
50
|
+
console.log(commandString);
|
|
51
|
+
const exitCode = await executeNestedAllureCommand({
|
|
52
|
+
command,
|
|
53
|
+
commandArgs,
|
|
54
|
+
cwd,
|
|
55
|
+
...(rerunContext ? { environmentVariables: { ALLURE_TESTPLAN_PATH: rerunContext.testPlanPath } } : {}),
|
|
56
|
+
silent,
|
|
57
|
+
});
|
|
58
|
+
exit(exitCode ?? -1);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const outputDir = output ? resolve(cwd, output) : await mkdtemp(join(tmpdir(), "allure-agent-"));
|
|
62
|
+
const expectationsPath = expectations ? resolve(cwd, expectations) : undefined;
|
|
63
|
+
const environmentOptions = {
|
|
64
|
+
environment,
|
|
65
|
+
environmentName,
|
|
66
|
+
};
|
|
67
|
+
normalizeCommandEnvironmentOptions(environmentOptions);
|
|
68
|
+
if (expectationsPath && isPathInside(outputDir, expectationsPath)) {
|
|
69
|
+
throw new AgentUsageError(`--expectations path ${JSON.stringify(expectationsPath)} must not be inside the agent output directory ${JSON.stringify(outputDir)}`);
|
|
70
|
+
}
|
|
71
|
+
const config = await readConfig(cwd, configPath, {
|
|
72
|
+
output: outputDir,
|
|
73
|
+
plugins: {
|
|
74
|
+
agent: {
|
|
75
|
+
options: {
|
|
76
|
+
outputDir,
|
|
77
|
+
command: commandString,
|
|
78
|
+
...(expectationsPath ? { expectationsPath } : {}),
|
|
79
|
+
...(inlineExpectations ? { expectations: inlineExpectations } : {}),
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
const resolvedEnvironment = resolveCommandEnvironment(config, environmentOptions);
|
|
85
|
+
try {
|
|
86
|
+
await rm(outputDir, { recursive: true });
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
if (!isFileNotFoundError(error)) {
|
|
90
|
+
console.error("could not clean output directory", error);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const startedAt = new Date().toISOString();
|
|
94
|
+
await persistLatestAgentState({
|
|
95
|
+
cwd,
|
|
96
|
+
outputDir,
|
|
97
|
+
expectationsPath,
|
|
98
|
+
command: commandString,
|
|
99
|
+
startedAt,
|
|
100
|
+
status: "running",
|
|
101
|
+
});
|
|
102
|
+
printAgentOutputLinks(outputDir);
|
|
103
|
+
if (expectationsPath) {
|
|
104
|
+
console.log(`agent expectations: ${expectationsPath}`);
|
|
105
|
+
}
|
|
106
|
+
else if (inlineExpectations) {
|
|
107
|
+
console.log("agent expectations: CLI options");
|
|
108
|
+
}
|
|
109
|
+
console.log(commandString);
|
|
110
|
+
const allureReport = new AllureReport({
|
|
111
|
+
...config,
|
|
112
|
+
output: outputDir,
|
|
113
|
+
environment: resolvedEnvironment?.id,
|
|
114
|
+
open: false,
|
|
115
|
+
port: undefined,
|
|
116
|
+
qualityGate: undefined,
|
|
117
|
+
allureService: undefined,
|
|
118
|
+
realTime: false,
|
|
119
|
+
plugins: config.plugins,
|
|
120
|
+
});
|
|
121
|
+
const knownIssues = await allureReport.store.allKnownIssues();
|
|
122
|
+
const { globalExitCode } = await executeAllureRun({
|
|
123
|
+
allureReport,
|
|
124
|
+
knownIssues,
|
|
125
|
+
cwd,
|
|
126
|
+
command,
|
|
127
|
+
commandArgs,
|
|
128
|
+
environmentVariables: childEnvironmentVariables,
|
|
129
|
+
environment: resolvedEnvironment?.id,
|
|
130
|
+
withQualityGate: false,
|
|
131
|
+
logs: "pipe",
|
|
132
|
+
silent,
|
|
133
|
+
ignoreLogs: false,
|
|
134
|
+
logProcessExit: false,
|
|
135
|
+
});
|
|
136
|
+
await persistLatestAgentState({
|
|
137
|
+
cwd,
|
|
138
|
+
outputDir,
|
|
139
|
+
expectationsPath,
|
|
140
|
+
command: commandString,
|
|
141
|
+
startedAt,
|
|
142
|
+
finishedAt: new Date().toISOString(),
|
|
143
|
+
status: "finished",
|
|
144
|
+
exitCode: globalExitCode.actual ?? globalExitCode.original,
|
|
145
|
+
});
|
|
146
|
+
exit(globalExitCode.actual ?? globalExitCode.original);
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
await rerunContext?.cleanup();
|
|
150
|
+
}
|
|
151
|
+
};
|
package/dist/commands/agent.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
import { AGENT_TASK_MAP_HELP, createAgentCapabilities, isAgentTaskMapHelpRequest } from "@allurereport/plugin-agent";
|
|
1
2
|
import { Command } from "clipanion";
|
|
3
|
+
export { AGENT_TASK_MAP_HELP, createAgentCapabilities, isAgentTaskMapHelpRequest };
|
|
4
|
+
export declare class AgentCapabilitiesCommand extends Command {
|
|
5
|
+
static paths: string[][];
|
|
6
|
+
static usage: import("clipanion").Usage;
|
|
7
|
+
json: boolean;
|
|
8
|
+
execute(): Promise<void>;
|
|
9
|
+
}
|
|
2
10
|
export declare class AgentCommand extends Command {
|
|
3
11
|
static paths: string[][];
|
|
4
12
|
static usage: import("clipanion").Usage;
|
|
@@ -6,6 +14,18 @@ export declare class AgentCommand extends Command {
|
|
|
6
14
|
cwd: string | undefined;
|
|
7
15
|
output: string | undefined;
|
|
8
16
|
expectations: string | undefined;
|
|
17
|
+
goal: string[] | undefined;
|
|
18
|
+
taskId: string[] | undefined;
|
|
19
|
+
expectTests: string[] | undefined;
|
|
20
|
+
expectLabels: string[] | undefined;
|
|
21
|
+
expectEnvironments: string[] | undefined;
|
|
22
|
+
expectFullNames: string[] | undefined;
|
|
23
|
+
expectPrefixes: string[] | undefined;
|
|
24
|
+
forbidLabels: string[] | undefined;
|
|
25
|
+
expectStepContains: string[] | undefined;
|
|
26
|
+
expectSteps: string[] | undefined;
|
|
27
|
+
expectAttachments: string[] | undefined;
|
|
28
|
+
expectAttachmentFilters: string[] | undefined;
|
|
9
29
|
environment: string | undefined;
|
|
10
30
|
environmentName: string | undefined;
|
|
11
31
|
silent: boolean | undefined;
|
|
@@ -29,6 +49,24 @@ export declare class AgentStateDirCommand extends Command {
|
|
|
29
49
|
cwd: string | undefined;
|
|
30
50
|
execute(): Promise<void>;
|
|
31
51
|
}
|
|
52
|
+
export declare class AgentQueryCommand extends Command {
|
|
53
|
+
static paths: string[][];
|
|
54
|
+
static usage: import("clipanion").Usage;
|
|
55
|
+
view: string | undefined;
|
|
56
|
+
cwd: string | undefined;
|
|
57
|
+
from: string | undefined;
|
|
58
|
+
latest: boolean | undefined;
|
|
59
|
+
statuses: string[] | undefined;
|
|
60
|
+
environments: string[] | undefined;
|
|
61
|
+
labels: string[] | undefined;
|
|
62
|
+
severities: string[] | undefined;
|
|
63
|
+
categories: string[] | undefined;
|
|
64
|
+
checks: string[] | undefined;
|
|
65
|
+
test: string | undefined;
|
|
66
|
+
limit: string | undefined;
|
|
67
|
+
includeMarkdown: boolean | undefined;
|
|
68
|
+
execute(): Promise<void>;
|
|
69
|
+
}
|
|
32
70
|
export declare class AgentSelectCommand extends Command {
|
|
33
71
|
static paths: string[][];
|
|
34
72
|
static usage: import("clipanion").Usage;
|
|
@@ -41,18 +79,3 @@ export declare class AgentSelectCommand extends Command {
|
|
|
41
79
|
output: string | undefined;
|
|
42
80
|
execute(): Promise<void>;
|
|
43
81
|
}
|
|
44
|
-
export declare const executeAgentMode: (params: {
|
|
45
|
-
configPath?: string;
|
|
46
|
-
cwd?: string;
|
|
47
|
-
output?: string;
|
|
48
|
-
expectations?: string;
|
|
49
|
-
environment?: string;
|
|
50
|
-
environmentName?: string;
|
|
51
|
-
silent?: boolean;
|
|
52
|
-
rerunFrom?: string;
|
|
53
|
-
rerunLatest?: boolean;
|
|
54
|
-
rerunPreset?: string;
|
|
55
|
-
rerunEnvironments?: string[];
|
|
56
|
-
rerunLabels?: string[];
|
|
57
|
-
args?: string[];
|
|
58
|
-
}) => Promise<void>;
|