eas-cli 24.1.1 → 24.2.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 +237 -131
- package/build/channel/insights/formatInsights.js +1 -5
- package/build/commandUtils/EasCommand.d.ts +2 -1
- package/build/commandUtils/EasCommand.js +2 -1
- package/build/commandUtils/context/ContextField.d.ts +2 -0
- package/build/commandUtils/context/ProjectIdContextField.d.ts +1 -1
- package/build/commandUtils/context/ProjectIdContextField.js +4 -1
- package/build/commandUtils/flags.d.ts +3 -0
- package/build/commandUtils/flags.js +6 -1
- package/build/commandUtils/pagination.js +2 -2
- package/build/commandUtils/planGating.d.ts +2 -0
- package/build/commandUtils/planGating.js +10 -0
- package/build/commands/channel/insights.d.ts +2 -2
- package/build/commands/channel/insights.js +1 -13
- package/build/commands/observe/errors.d.ts +0 -1
- package/build/commands/observe/errors.js +3 -10
- package/build/commands/observe/event.d.ts +0 -1
- package/build/commands/observe/event.js +3 -11
- package/build/commands/observe/events.d.ts +0 -1
- package/build/commands/observe/events.js +3 -10
- package/build/commands/observe/metrics-summary.d.ts +0 -1
- package/build/commands/observe/metrics-summary.js +3 -10
- package/build/commands/observe/metrics.d.ts +0 -1
- package/build/commands/observe/metrics.js +3 -10
- package/build/commands/observe/routes.d.ts +0 -1
- package/build/commands/observe/routes.js +3 -10
- package/build/commands/observe/session.d.ts +0 -1
- package/build/commands/observe/session.js +3 -10
- package/build/commands/observe/versions.d.ts +0 -1
- package/build/commands/observe/versions.js +3 -10
- package/build/commands/simulator/egress.js +1 -1
- package/build/commands/simulator/index.js +2 -6
- package/build/commands/update/insights.d.ts +1 -1
- package/build/commands/update/insights.js +1 -13
- package/build/commands/workflow/insights/index.d.ts +23 -0
- package/build/commands/workflow/insights/index.js +80 -0
- package/build/commands/workflow/insights/maestro.d.ts +26 -0
- package/build/commands/workflow/insights/maestro.js +140 -0
- package/build/graphql/generated.d.ts +261 -0
- package/build/graphql/generated.js +2 -0
- package/build/graphql/queries/AppQuery.d.ts +4 -0
- package/build/graphql/queries/AppQuery.js +19 -0
- package/build/graphql/queries/WorkflowDeviceTestCaseInsightsQuery.d.ts +27 -0
- package/build/graphql/queries/WorkflowDeviceTestCaseInsightsQuery.js +173 -0
- package/build/graphql/queries/WorkflowsInsightsQuery.d.ts +13 -0
- package/build/graphql/queries/WorkflowsInsightsQuery.js +84 -0
- package/build/insights/formatFilters.d.ts +2 -0
- package/build/insights/formatFilters.js +10 -0
- package/build/insights/formatRunsOverTime.d.ts +13 -0
- package/build/insights/formatRunsOverTime.js +49 -0
- package/build/insights/formatTimespan.d.ts +5 -1
- package/build/insights/formatTimespan.js +12 -0
- package/build/insights/metrics.d.ts +22 -0
- package/build/insights/metrics.js +48 -0
- package/build/insights/timeRange.d.ts +5 -0
- package/build/insights/timeRange.js +17 -1
- package/build/observe/flags.d.ts +0 -3
- package/build/observe/flags.js +1 -6
- package/build/observe/formatErrors.js +3 -5
- package/build/observe/planGating.js +2 -5
- package/build/observe/startAndEndTime.js +9 -0
- package/build/simulator/egress.js +4 -1
- package/build/simulator/utils.d.ts +5 -1
- package/build/simulator/utils.js +21 -28
- package/build/update/insights/formatInsights.js +1 -5
- package/build/utils/terminalText.d.ts +1 -0
- package/build/utils/terminalText.js +4 -0
- package/build/workflow/insights/filters.d.ts +30 -0
- package/build/workflow/insights/filters.js +79 -0
- package/build/workflow/insights/formatInsights.d.ts +44 -0
- package/build/workflow/insights/formatInsights.js +155 -0
- package/build/workflow/insights/formatMaestroInsights.d.ts +105 -0
- package/build/workflow/insights/formatMaestroInsights.js +298 -0
- package/build/workflow/insights/granularity.d.ts +27 -0
- package/build/workflow/insights/granularity.js +79 -0
- package/build/workflow/insights/maestroFilters.d.ts +23 -0
- package/build/workflow/insights/maestroFilters.js +47 -0
- package/build/workflow/insights/maestroSort.d.ts +7 -0
- package/build/workflow/insights/maestroSort.js +27 -0
- package/build/workflow/insights/planGating.d.ts +6 -0
- package/build/workflow/insights/planGating.js +33 -0
- package/oclif.manifest.json +1941 -1561
- package/package.json +5 -5
- package/build/observe/resolveProjectContext.d.ts +0 -22
- package/build/observe/resolveProjectContext.js +0 -21
package/build/simulator/utils.js
CHANGED
|
@@ -89,19 +89,18 @@ function getLoopbackForwardPlan(allow, proxyPort) {
|
|
|
89
89
|
}
|
|
90
90
|
return { ports: [...ports].sort((a, b) => a - b), skipped };
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
if (skipped.length > 0) {
|
|
101
|
-
lines.push(`${skipped.join(', ')} ${skipped.length === 1 ? 'is' : 'are'} reachable by name only: ` +
|
|
102
|
-
'privileged ports and the egress proxy port are not forwarded to 127.0.0.1 in the simulator.');
|
|
92
|
+
/**
|
|
93
|
+
* Only the exception is worth a line: forwarded ports just work, but an entry
|
|
94
|
+
* the device host will not forward changes what the reader would expect.
|
|
95
|
+
*/
|
|
96
|
+
function formatLoopbackForwardNotice({ skipped }) {
|
|
97
|
+
if (skipped.length === 0) {
|
|
98
|
+
return [];
|
|
103
99
|
}
|
|
104
|
-
return
|
|
100
|
+
return [
|
|
101
|
+
`${skipped.join(', ')} ${skipped.length === 1 ? 'is' : 'are'} reachable by name only: ` +
|
|
102
|
+
'privileged ports and the egress proxy port are not forwarded to 127.0.0.1 in the simulator.',
|
|
103
|
+
];
|
|
105
104
|
}
|
|
106
105
|
function getLocalEgressEnvironmentVariables(egress) {
|
|
107
106
|
if (!egress) {
|
|
@@ -187,33 +186,27 @@ function formatRemoteSessionInstructions(remoteConfig, configType, { egressAllow
|
|
|
187
186
|
return instructions;
|
|
188
187
|
}
|
|
189
188
|
const egressCommand = configType === 'env' ? 'eas simulator:egress --config-type env' : 'eas simulator:egress';
|
|
189
|
+
const summary = "🔀 Local egress: the simulator's HTTP(S) traffic exits from this machine." +
|
|
190
|
+
(egress.allow.length > 0 ? ` It can also reach ${egress.allow.join(', ')}.` : '');
|
|
190
191
|
return [
|
|
191
192
|
instructions,
|
|
192
193
|
'',
|
|
193
|
-
|
|
194
|
-
...(
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
summary,
|
|
195
|
+
...formatLoopbackForwardNotice(getLoopbackForwardPlan(egress.allow, egress.port)),
|
|
196
|
+
// In interactive mode the client starts in this terminal once the session is
|
|
197
|
+
// ready and stops with it, so there is nothing for the reader to run.
|
|
197
198
|
...(egressClientRunsInline
|
|
198
|
-
? [
|
|
199
|
-
'The egress client runs in this terminal for the life of the session. If this process exits, reconnect the tunnel from another shell with:',
|
|
200
|
-
'',
|
|
201
|
-
egressCommand,
|
|
202
|
-
]
|
|
199
|
+
? []
|
|
203
200
|
: [
|
|
201
|
+
...(configType === 'env'
|
|
202
|
+
? Object.entries(getLocalEgressEnvironmentVariables(egress)).map(([key, value]) => `export ${key}='${value}'`)
|
|
203
|
+
: []),
|
|
204
204
|
'Run the egress client to connect the tunnel:',
|
|
205
205
|
'',
|
|
206
206
|
egressCommand,
|
|
207
207
|
'',
|
|
208
208
|
'Keep it running for the life of the session.',
|
|
209
209
|
]),
|
|
210
|
-
...(egress.allow.length > 0
|
|
211
|
-
? [
|
|
212
|
-
'',
|
|
213
|
-
`The simulator may reach ${egress.allow.join(', ')} on this machine's network.`,
|
|
214
|
-
...formatLoopbackForwardNotice(getLoopbackForwardPlan(egress.allow, egress.port)),
|
|
215
|
-
]
|
|
216
|
-
: []),
|
|
217
210
|
].join('\n');
|
|
218
211
|
}
|
|
219
212
|
function formatControllerInstructions(remoteConfig, configType) {
|
|
@@ -48,11 +48,7 @@ function toPlatformSummary(update) {
|
|
|
48
48
|
function buildUpdateInsightsJson(summary) {
|
|
49
49
|
return {
|
|
50
50
|
groupId: summary.groupId,
|
|
51
|
-
timespan:
|
|
52
|
-
start: summary.startTime,
|
|
53
|
-
end: summary.endTime,
|
|
54
|
-
...(summary.daysBack !== undefined ? { daysBack: summary.daysBack } : {}),
|
|
55
|
-
},
|
|
51
|
+
timespan: (0, formatTimespan_1.toTimespanJson)(summary),
|
|
56
52
|
platforms: summary.platforms.map(p => ({
|
|
57
53
|
platform: p.platform,
|
|
58
54
|
updateId: p.updateId,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sanitizeTerminalText = sanitizeTerminalText;
|
|
4
|
+
exports.truncate = truncate;
|
|
4
5
|
/**
|
|
5
6
|
* Sanitize externally-influenced text for printing as a single-line field value. Escape
|
|
6
7
|
* sequences in a crafted value could clear the screen or spoof output, and embedded newlines
|
|
@@ -12,3 +13,6 @@ const CONTROL_CHARACTERS = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F
|
|
|
12
13
|
function sanitizeTerminalText(value) {
|
|
13
14
|
return value.replace(CONTROL_CHARACTERS, '').replace(/\s+/g, ' ').trim();
|
|
14
15
|
}
|
|
16
|
+
function truncate(value, maxLength) {
|
|
17
|
+
return value.length > maxLength ? `${value.slice(0, maxLength - 1)}…` : value;
|
|
18
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
|
2
|
+
import { WorkflowRunStatus, WorkflowRunTriggerEventType, WorkflowsInsightsFiltersInput } from '../../graphql/generated';
|
|
3
|
+
export declare const INSIGHTS_RUN_STATUSES: readonly [WorkflowRunStatus.Success, WorkflowRunStatus.Failure, WorkflowRunStatus.Canceled];
|
|
4
|
+
export type InsightsRunStatus = (typeof INSIGHTS_RUN_STATUSES)[number];
|
|
5
|
+
/** The filters as the user typed them, before workflow file names are resolved to IDs. */
|
|
6
|
+
export interface AppliedWorkflowsInsightsFilters {
|
|
7
|
+
workflows?: string[];
|
|
8
|
+
statuses?: InsightsRunStatus[];
|
|
9
|
+
triggerEventTypes?: WorkflowRunTriggerEventType[];
|
|
10
|
+
gitRef?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const WorkflowsInsightsSharedFilterFlags: {
|
|
13
|
+
workflow: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
14
|
+
'git-ref': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
15
|
+
};
|
|
16
|
+
export interface WorkflowsInsightsFilterFlags {
|
|
17
|
+
workflow?: string[];
|
|
18
|
+
status?: InsightsRunStatus[];
|
|
19
|
+
trigger?: WorkflowRunTriggerEventType[];
|
|
20
|
+
'git-ref'?: string;
|
|
21
|
+
}
|
|
22
|
+
/** The server filters by workflow ID, so workflow file names are resolved first. */
|
|
23
|
+
export declare function resolveWorkflowsInsightsFiltersInputAsync(graphqlClient: ExpoGraphqlClient, appId: string, flags: WorkflowsInsightsFilterFlags): Promise<WorkflowsInsightsFiltersInput | undefined>;
|
|
24
|
+
export declare function getAppliedWorkflowsInsightsFilters(flags: WorkflowsInsightsFilterFlags): AppliedWorkflowsInsightsFilters | undefined;
|
|
25
|
+
export declare function resolveWorkflowIdsAsync(graphqlClient: ExpoGraphqlClient, appId: string, fileNames: string[]): Promise<string[]>;
|
|
26
|
+
/**
|
|
27
|
+
* A run records either the fully qualified ref it was requested for, or the commit SHA when
|
|
28
|
+
* `eas workflow:run --ref` resolved one, so only a bare branch name needs qualifying.
|
|
29
|
+
*/
|
|
30
|
+
export declare function normalizeGitRef(gitRef: string): string;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkflowsInsightsSharedFilterFlags = exports.INSIGHTS_RUN_STATUSES = void 0;
|
|
4
|
+
exports.resolveWorkflowsInsightsFiltersInputAsync = resolveWorkflowsInsightsFiltersInputAsync;
|
|
5
|
+
exports.getAppliedWorkflowsInsightsFilters = getAppliedWorkflowsInsightsFilters;
|
|
6
|
+
exports.resolveWorkflowIdsAsync = resolveWorkflowIdsAsync;
|
|
7
|
+
exports.normalizeGitRef = normalizeGitRef;
|
|
8
|
+
const core_1 = require("@oclif/core");
|
|
9
|
+
const errors_1 = require("../../commandUtils/errors");
|
|
10
|
+
const generated_1 = require("../../graphql/generated");
|
|
11
|
+
const AppQuery_1 = require("../../graphql/queries/AppQuery");
|
|
12
|
+
const COMMIT_SHA = /^[0-9a-f]{40}$/i;
|
|
13
|
+
// Insights only cover finished runs, so the other run statuses would never match.
|
|
14
|
+
exports.INSIGHTS_RUN_STATUSES = [
|
|
15
|
+
generated_1.WorkflowRunStatus.Success,
|
|
16
|
+
generated_1.WorkflowRunStatus.Failure,
|
|
17
|
+
generated_1.WorkflowRunStatus.Canceled,
|
|
18
|
+
];
|
|
19
|
+
exports.WorkflowsInsightsSharedFilterFlags = {
|
|
20
|
+
workflow: core_1.Flags.string({
|
|
21
|
+
description: 'Only include runs of this workflow file name (can be specified multiple times).',
|
|
22
|
+
multiple: true,
|
|
23
|
+
}),
|
|
24
|
+
'git-ref': core_1.Flags.string({
|
|
25
|
+
description: 'Only include runs requested for this git ref, for example main or refs/heads/main, or for the full 40-character commit SHA that eas workflow:run recorded.',
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
|
+
/** The server filters by workflow ID, so workflow file names are resolved first. */
|
|
29
|
+
async function resolveWorkflowsInsightsFiltersInputAsync(graphqlClient, appId, flags) {
|
|
30
|
+
const input = {};
|
|
31
|
+
if (flags.workflow?.length) {
|
|
32
|
+
input.workflowIds = await resolveWorkflowIdsAsync(graphqlClient, appId, flags.workflow);
|
|
33
|
+
}
|
|
34
|
+
if (flags.status?.length) {
|
|
35
|
+
input.statuses = flags.status;
|
|
36
|
+
}
|
|
37
|
+
if (flags.trigger?.length) {
|
|
38
|
+
input.triggerEventTypes = flags.trigger;
|
|
39
|
+
}
|
|
40
|
+
if (flags['git-ref']) {
|
|
41
|
+
input.gitRefRequested = [normalizeGitRef(flags['git-ref'])];
|
|
42
|
+
}
|
|
43
|
+
return Object.keys(input).length === 0 ? undefined : input;
|
|
44
|
+
}
|
|
45
|
+
function getAppliedWorkflowsInsightsFilters(flags) {
|
|
46
|
+
const applied = {
|
|
47
|
+
...(flags.workflow?.length ? { workflows: flags.workflow } : {}),
|
|
48
|
+
...(flags.status?.length ? { statuses: flags.status } : {}),
|
|
49
|
+
...(flags.trigger?.length ? { triggerEventTypes: flags.trigger } : {}),
|
|
50
|
+
...(flags['git-ref'] ? { gitRef: normalizeGitRef(flags['git-ref']) } : {}),
|
|
51
|
+
};
|
|
52
|
+
return Object.keys(applied).length === 0 ? undefined : applied;
|
|
53
|
+
}
|
|
54
|
+
async function resolveWorkflowIdsAsync(graphqlClient, appId, fileNames) {
|
|
55
|
+
const workflows = await AppQuery_1.AppQuery.byIdWorkflowFileNamesAsync(graphqlClient, appId);
|
|
56
|
+
const knownFileNames = new Set(workflows.map(workflow => workflow.fileName));
|
|
57
|
+
const requestedFileNames = new Set(fileNames);
|
|
58
|
+
const unknownFileNames = [...requestedFileNames].filter(fileName => !knownFileNames.has(fileName));
|
|
59
|
+
if (unknownFileNames.length > 0) {
|
|
60
|
+
const quoted = unknownFileNames.map(fileName => `"${fileName}"`).join(', ');
|
|
61
|
+
const known = knownFileNames.size > 0
|
|
62
|
+
? `Known: ${[...knownFileNames].sort().join(', ')}.`
|
|
63
|
+
: 'No workflows are known yet.';
|
|
64
|
+
throw new errors_1.EasCommandError(`Workflow file(s) not found on this project: ${quoted}. ${known} --workflow takes the workflow file name including the extension; a workflow is listed after its first run.`);
|
|
65
|
+
}
|
|
66
|
+
return workflows
|
|
67
|
+
.filter(workflow => requestedFileNames.has(workflow.fileName))
|
|
68
|
+
.map(workflow => workflow.id);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A run records either the fully qualified ref it was requested for, or the commit SHA when
|
|
72
|
+
* `eas workflow:run --ref` resolved one, so only a bare branch name needs qualifying.
|
|
73
|
+
*/
|
|
74
|
+
function normalizeGitRef(gitRef) {
|
|
75
|
+
if (gitRef.startsWith('refs/') || COMMIT_SHA.test(gitRef)) {
|
|
76
|
+
return gitRef;
|
|
77
|
+
}
|
|
78
|
+
return `refs/heads/${gitRef}`;
|
|
79
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { WorkflowsInsightsRunsOverTimeGranularity } from '../../graphql/generated';
|
|
2
|
+
import { AppWithWorkflowsInsightsObject } from '../../graphql/queries/WorkflowsInsightsQuery';
|
|
3
|
+
import { InsightsTimespanFields } from '../../insights/formatTimespan';
|
|
4
|
+
import { AppliedWorkflowsInsightsFilters } from './filters';
|
|
5
|
+
import { InsightsMetricSummary } from '../../insights/metrics';
|
|
6
|
+
export interface WorkflowsInsightsBucket {
|
|
7
|
+
start: string;
|
|
8
|
+
totalRuns: number;
|
|
9
|
+
successfulRuns: number;
|
|
10
|
+
failedRuns: number;
|
|
11
|
+
canceledRuns: number;
|
|
12
|
+
}
|
|
13
|
+
export interface WorkflowsInsightsWorkflowSummary {
|
|
14
|
+
workflowId: string;
|
|
15
|
+
fileName: string;
|
|
16
|
+
name: string;
|
|
17
|
+
totalRuns: number;
|
|
18
|
+
successfulRuns: number;
|
|
19
|
+
failedRuns: number;
|
|
20
|
+
canceledRuns: number;
|
|
21
|
+
successRatePercent: number;
|
|
22
|
+
lastRunAt: string;
|
|
23
|
+
}
|
|
24
|
+
export interface WorkflowsInsightsSummary extends InsightsTimespanFields {
|
|
25
|
+
appFullName: string;
|
|
26
|
+
granularity: WorkflowsInsightsRunsOverTimeGranularity;
|
|
27
|
+
filters?: AppliedWorkflowsInsightsFilters;
|
|
28
|
+
overview: {
|
|
29
|
+
totalRuns: InsightsMetricSummary;
|
|
30
|
+
successRatePercent: InsightsMetricSummary;
|
|
31
|
+
activeWorkflows: InsightsMetricSummary;
|
|
32
|
+
failedRuns: InsightsMetricSummary;
|
|
33
|
+
};
|
|
34
|
+
runsOverTime: WorkflowsInsightsBucket[];
|
|
35
|
+
workflows: WorkflowsInsightsWorkflowSummary[];
|
|
36
|
+
hasMoreWorkflows: boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare function toWorkflowsInsightsSummary(app: AppWithWorkflowsInsightsObject, { timespan, granularity, filters, }: {
|
|
39
|
+
timespan: InsightsTimespanFields;
|
|
40
|
+
granularity: WorkflowsInsightsRunsOverTimeGranularity;
|
|
41
|
+
filters?: AppliedWorkflowsInsightsFilters;
|
|
42
|
+
}): WorkflowsInsightsSummary;
|
|
43
|
+
export declare function buildWorkflowsInsightsJson(summary: WorkflowsInsightsSummary): object;
|
|
44
|
+
export declare function buildWorkflowsInsightsTable(summary: WorkflowsInsightsSummary): string;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toWorkflowsInsightsSummary = toWorkflowsInsightsSummary;
|
|
4
|
+
exports.buildWorkflowsInsightsJson = buildWorkflowsInsightsJson;
|
|
5
|
+
exports.buildWorkflowsInsightsTable = buildWorkflowsInsightsTable;
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
|
+
const indent_string_1 = tslib_1.__importDefault(require("indent-string"));
|
|
9
|
+
const formatRunsOverTime_1 = require("../../insights/formatRunsOverTime");
|
|
10
|
+
const formatTimespan_1 = require("../../insights/formatTimespan");
|
|
11
|
+
const formatFilters_1 = require("../../insights/formatFilters");
|
|
12
|
+
const formatFields_1 = tslib_1.__importDefault(require("../../utils/formatFields"));
|
|
13
|
+
const renderTextTable_1 = tslib_1.__importDefault(require("../../utils/renderTextTable"));
|
|
14
|
+
const metrics_1 = require("../../insights/metrics");
|
|
15
|
+
// Dataset ids assigned by the server's `runsOverTime` resolver.
|
|
16
|
+
const RUNS_OVER_TIME_DATASET_IDS = {
|
|
17
|
+
total: 'WorkflowsInsightsRunsOverTimeDataset:total',
|
|
18
|
+
success: 'WorkflowsInsightsRunsOverTimeDataset:success',
|
|
19
|
+
failure: 'WorkflowsInsightsRunsOverTimeDataset:failure',
|
|
20
|
+
canceled: 'WorkflowsInsightsRunsOverTimeDataset:canceled',
|
|
21
|
+
};
|
|
22
|
+
function toWorkflowsInsightsSummary(app, { timespan, granularity, filters, }) {
|
|
23
|
+
const { overviewMetrics, runsOverTime, workflows } = app.workflowsInsights;
|
|
24
|
+
// Insights rows carry the workflow's YAML name, which is neither unique nor what
|
|
25
|
+
// `--workflow` accepts, so the table is keyed by file name instead.
|
|
26
|
+
const fileNamesByWorkflowId = new Map(app.workflows.map(w => [w.id, w.fileName]));
|
|
27
|
+
return {
|
|
28
|
+
appFullName: app.fullName,
|
|
29
|
+
...timespan,
|
|
30
|
+
granularity,
|
|
31
|
+
filters,
|
|
32
|
+
overview: {
|
|
33
|
+
totalRuns: (0, metrics_1.toMetricSummary)(overviewMetrics.totalRuns),
|
|
34
|
+
successRatePercent: {
|
|
35
|
+
current: (0, metrics_1.ratePercent)(overviewMetrics.successfulRuns.currentValue, overviewMetrics.totalRuns.currentValue),
|
|
36
|
+
previous: (0, metrics_1.ratePercent)(overviewMetrics.successfulRuns.previousValue, overviewMetrics.totalRuns.previousValue),
|
|
37
|
+
},
|
|
38
|
+
activeWorkflows: (0, metrics_1.toMetricSummary)(overviewMetrics.activeWorkflows),
|
|
39
|
+
failedRuns: (0, metrics_1.toMetricSummary)(overviewMetrics.failedRuns),
|
|
40
|
+
},
|
|
41
|
+
runsOverTime: toBuckets(runsOverTime.lineChart),
|
|
42
|
+
workflows: workflows.edges.map(({ node }) => ({
|
|
43
|
+
workflowId: node.workflowId,
|
|
44
|
+
fileName: fileNamesByWorkflowId.get(node.workflowId) ?? node.workflowId,
|
|
45
|
+
name: node.name,
|
|
46
|
+
totalRuns: node.totalRuns,
|
|
47
|
+
successfulRuns: node.successfulRuns,
|
|
48
|
+
failedRuns: node.failedRuns,
|
|
49
|
+
canceledRuns: node.canceledRuns,
|
|
50
|
+
successRatePercent: (0, metrics_1.ratePercent)(node.successfulRuns, node.totalRuns),
|
|
51
|
+
lastRunAt: node.lastRunAt,
|
|
52
|
+
})),
|
|
53
|
+
hasMoreWorkflows: workflows.pageInfo.hasNextPage,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function toBuckets(lineChart) {
|
|
57
|
+
const dataset = (id) => {
|
|
58
|
+
const match = lineChart.datasets.find(d => d.id === id);
|
|
59
|
+
if (!match) {
|
|
60
|
+
throw new Error(`Workflows insights response is missing the "${id}" dataset.`);
|
|
61
|
+
}
|
|
62
|
+
return match.data;
|
|
63
|
+
};
|
|
64
|
+
const total = dataset(RUNS_OVER_TIME_DATASET_IDS.total);
|
|
65
|
+
const success = dataset(RUNS_OVER_TIME_DATASET_IDS.success);
|
|
66
|
+
const failure = dataset(RUNS_OVER_TIME_DATASET_IDS.failure);
|
|
67
|
+
const canceled = dataset(RUNS_OVER_TIME_DATASET_IDS.canceled);
|
|
68
|
+
return lineChart.labels.map((start, i) => ({
|
|
69
|
+
start,
|
|
70
|
+
totalRuns: total[i] ?? 0,
|
|
71
|
+
successfulRuns: success[i] ?? 0,
|
|
72
|
+
failedRuns: failure[i] ?? 0,
|
|
73
|
+
canceledRuns: canceled[i] ?? 0,
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
function buildWorkflowsInsightsJson(summary) {
|
|
77
|
+
return {
|
|
78
|
+
project: summary.appFullName,
|
|
79
|
+
timespan: (0, formatTimespan_1.toTimespanJson)(summary),
|
|
80
|
+
...(summary.filters ? { filters: summary.filters } : {}),
|
|
81
|
+
overview: summary.overview,
|
|
82
|
+
runsOverTime: {
|
|
83
|
+
granularity: summary.granularity,
|
|
84
|
+
buckets: summary.runsOverTime,
|
|
85
|
+
},
|
|
86
|
+
workflows: summary.workflows,
|
|
87
|
+
hasMoreWorkflows: summary.hasMoreWorkflows,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function buildWorkflowsInsightsTable(summary) {
|
|
91
|
+
const sections = [];
|
|
92
|
+
sections.push(chalk_1.default.bold('Workflows insights:'));
|
|
93
|
+
sections.push((0, formatFields_1.default)([
|
|
94
|
+
{ label: 'Project', value: summary.appFullName },
|
|
95
|
+
{ label: 'Time range', value: (0, formatTimespan_1.formatTimespan)(summary) },
|
|
96
|
+
...(summary.filters ? [{ label: 'Filters', value: formatFilters(summary.filters) }] : []),
|
|
97
|
+
]));
|
|
98
|
+
const { overview } = summary;
|
|
99
|
+
sections.push('');
|
|
100
|
+
sections.push(chalk_1.default.bold('Overview (compared with the previous period):'));
|
|
101
|
+
sections.push((0, formatFields_1.default)([
|
|
102
|
+
{ label: 'Total runs', value: (0, metrics_1.formatCountWithTrend)(overview.totalRuns) },
|
|
103
|
+
{
|
|
104
|
+
label: 'Success rate',
|
|
105
|
+
value: (0, metrics_1.formatRateWithDelta)(overview.successRatePercent, overview.totalRuns),
|
|
106
|
+
},
|
|
107
|
+
{ label: 'Active workflows', value: (0, metrics_1.formatCountWithTrend)(overview.activeWorkflows) },
|
|
108
|
+
{
|
|
109
|
+
label: 'Failed runs',
|
|
110
|
+
value: (0, metrics_1.formatCountWithTrend)(overview.failedRuns, { lowerIsBetter: true }),
|
|
111
|
+
},
|
|
112
|
+
]));
|
|
113
|
+
sections.push(...(0, formatRunsOverTime_1.buildRunsOverTimeSection)(summary.runsOverTime, summary.granularity, {
|
|
114
|
+
runs: bucket => bucket.totalRuns,
|
|
115
|
+
columns: ['Total', 'Successful', 'Failed', 'Canceled'],
|
|
116
|
+
toRow: bucket => [
|
|
117
|
+
bucket.totalRuns.toLocaleString(),
|
|
118
|
+
bucket.successfulRuns.toLocaleString(),
|
|
119
|
+
bucket.failedRuns.toLocaleString(),
|
|
120
|
+
bucket.canceledRuns.toLocaleString(),
|
|
121
|
+
],
|
|
122
|
+
}));
|
|
123
|
+
sections.push('');
|
|
124
|
+
if (summary.workflows.length === 0) {
|
|
125
|
+
sections.push(chalk_1.default.bold('Workflows:'));
|
|
126
|
+
sections.push(chalk_1.default.dim(' No workflow runs in this time range.'));
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
sections.push(chalk_1.default.bold(summary.hasMoreWorkflows
|
|
130
|
+
? `Workflows (showing the ${summary.workflows.length} with the most runs):`
|
|
131
|
+
: 'Workflows:'));
|
|
132
|
+
sections.push('');
|
|
133
|
+
sections.push((0, indent_string_1.default)(renderWorkflowsTable(summary.workflows), 2));
|
|
134
|
+
}
|
|
135
|
+
return sections.join('\n');
|
|
136
|
+
}
|
|
137
|
+
function formatFilters(filters) {
|
|
138
|
+
return (0, formatFilters_1.formatAppliedFilters)([
|
|
139
|
+
['workflows', filters.workflows],
|
|
140
|
+
['statuses', filters.statuses],
|
|
141
|
+
['triggers', filters.triggerEventTypes],
|
|
142
|
+
['git ref', filters.gitRef],
|
|
143
|
+
]);
|
|
144
|
+
}
|
|
145
|
+
function renderWorkflowsTable(workflows) {
|
|
146
|
+
return (0, renderTextTable_1.default)(['Workflow', 'Runs', 'Successful', 'Failed', 'Canceled', 'Success rate', 'Last run'], workflows.map(workflow => [
|
|
147
|
+
workflow.fileName,
|
|
148
|
+
workflow.totalRuns.toLocaleString(),
|
|
149
|
+
workflow.successfulRuns.toLocaleString(),
|
|
150
|
+
workflow.failedRuns.toLocaleString(),
|
|
151
|
+
workflow.canceledRuns.toLocaleString(),
|
|
152
|
+
(0, metrics_1.formatPercent)(workflow.successRatePercent),
|
|
153
|
+
(0, formatTimespan_1.toDateTime)(workflow.lastRunAt),
|
|
154
|
+
]));
|
|
155
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { WorkflowDeviceTestCaseInsightsTimeSeriesGranularity, WorkflowDeviceTestCaseStatus } from '../../graphql/generated';
|
|
2
|
+
import { AppWithMaestroFlowHistoryObject, AppWithMaestroInsightsObject } from '../../graphql/queries/WorkflowDeviceTestCaseInsightsQuery';
|
|
3
|
+
import { InsightsTimespanFields } from '../../insights/formatTimespan';
|
|
4
|
+
import { AppliedMaestroInsightsFilters } from './maestroFilters';
|
|
5
|
+
import { MaestroSortDirection, MaestroSortOption } from './maestroSort';
|
|
6
|
+
import { InsightsMetricSummary } from '../../insights/metrics';
|
|
7
|
+
/** Durations are unknown until at least one run in the window reported one. */
|
|
8
|
+
export interface NullableMetricSummary {
|
|
9
|
+
current: number | null;
|
|
10
|
+
previous: number | null;
|
|
11
|
+
}
|
|
12
|
+
/** The Maestro tab's overview tiles. */
|
|
13
|
+
export interface MaestroInsightsTotals {
|
|
14
|
+
totalRuns: InsightsMetricSummary;
|
|
15
|
+
passRatePercent: InsightsMetricSummary;
|
|
16
|
+
distinctFlakyFlows: InsightsMetricSummary;
|
|
17
|
+
avgDurationMs: NullableMetricSummary;
|
|
18
|
+
}
|
|
19
|
+
/** The tiles of one flow's detail view, which shows no previous-period comparison. */
|
|
20
|
+
export interface MaestroFlowTotals {
|
|
21
|
+
totalRuns: number;
|
|
22
|
+
passRatePercent: number;
|
|
23
|
+
flakyRuns: number;
|
|
24
|
+
p90DurationMs: number | null;
|
|
25
|
+
}
|
|
26
|
+
export interface MaestroInsightsBucket {
|
|
27
|
+
start: string;
|
|
28
|
+
passedClean: number;
|
|
29
|
+
flaky: number;
|
|
30
|
+
failed: number;
|
|
31
|
+
}
|
|
32
|
+
export interface MaestroFlowSummary {
|
|
33
|
+
path: string;
|
|
34
|
+
name: string;
|
|
35
|
+
totalRuns: number;
|
|
36
|
+
passRatePercent: number;
|
|
37
|
+
failed: number;
|
|
38
|
+
flakeRatePercent: number;
|
|
39
|
+
p90DurationMs: number | null;
|
|
40
|
+
lastRunAt: string;
|
|
41
|
+
lastRunStatus: WorkflowDeviceTestCaseStatus;
|
|
42
|
+
lastRunIsFlaky: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface MaestroInsightsSummary extends InsightsTimespanFields {
|
|
45
|
+
appFullName: string;
|
|
46
|
+
granularity: WorkflowDeviceTestCaseInsightsTimeSeriesGranularity;
|
|
47
|
+
filters?: AppliedMaestroInsightsFilters;
|
|
48
|
+
totals: MaestroInsightsTotals;
|
|
49
|
+
runsOverTime: MaestroInsightsBucket[];
|
|
50
|
+
flows: MaestroFlowSummary[];
|
|
51
|
+
totalFlows: number;
|
|
52
|
+
hasMoreFlows: boolean;
|
|
53
|
+
sort: {
|
|
54
|
+
field: MaestroSortOption;
|
|
55
|
+
direction: MaestroSortDirection;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface MaestroErrorPatternSummary {
|
|
59
|
+
count: number;
|
|
60
|
+
sampleMessage: string;
|
|
61
|
+
}
|
|
62
|
+
export interface MaestroRecentRunSummary {
|
|
63
|
+
id: string;
|
|
64
|
+
status: WorkflowDeviceTestCaseStatus;
|
|
65
|
+
isFlaky: boolean;
|
|
66
|
+
durationMs: number | null;
|
|
67
|
+
createdAt: string;
|
|
68
|
+
workflowRunId: string;
|
|
69
|
+
workflowRunName: string;
|
|
70
|
+
gitRef: string | null;
|
|
71
|
+
commitSha: string | null;
|
|
72
|
+
}
|
|
73
|
+
export interface MaestroFlowHistorySummary extends InsightsTimespanFields {
|
|
74
|
+
appFullName: string;
|
|
75
|
+
flowPath: string;
|
|
76
|
+
granularity: WorkflowDeviceTestCaseInsightsTimeSeriesGranularity;
|
|
77
|
+
filters?: Pick<AppliedMaestroInsightsFilters, 'workflows' | 'gitRef'>;
|
|
78
|
+
totals: MaestroFlowTotals;
|
|
79
|
+
runsOverTime: MaestroInsightsBucket[];
|
|
80
|
+
errorPatterns: MaestroErrorPatternSummary[];
|
|
81
|
+
recentRuns: MaestroRecentRunSummary[];
|
|
82
|
+
totalRecentRuns: number;
|
|
83
|
+
hasMoreRecentRuns: boolean;
|
|
84
|
+
}
|
|
85
|
+
export declare function toMaestroInsightsSummary(app: AppWithMaestroInsightsObject, { timespan, granularity, filters, sort, }: {
|
|
86
|
+
timespan: InsightsTimespanFields;
|
|
87
|
+
granularity: WorkflowDeviceTestCaseInsightsTimeSeriesGranularity;
|
|
88
|
+
filters?: AppliedMaestroInsightsFilters;
|
|
89
|
+
sort: {
|
|
90
|
+
field: MaestroSortOption;
|
|
91
|
+
direction: MaestroSortDirection;
|
|
92
|
+
};
|
|
93
|
+
}): MaestroInsightsSummary;
|
|
94
|
+
export declare function toMaestroFlowHistorySummary(app: AppWithMaestroFlowHistoryObject, { flowPath, timespan, granularity, filters, }: {
|
|
95
|
+
flowPath: string;
|
|
96
|
+
timespan: InsightsTimespanFields;
|
|
97
|
+
granularity: WorkflowDeviceTestCaseInsightsTimeSeriesGranularity;
|
|
98
|
+
filters?: AppliedMaestroInsightsFilters;
|
|
99
|
+
}): MaestroFlowHistorySummary;
|
|
100
|
+
export declare function buildMaestroInsightsJson(summary: MaestroInsightsSummary): object;
|
|
101
|
+
export declare function buildMaestroFlowHistoryJson(summary: MaestroFlowHistorySummary): object;
|
|
102
|
+
export declare function buildMaestroInsightsTable(summary: MaestroInsightsSummary): string;
|
|
103
|
+
export declare function buildMaestroFlowHistoryTable(summary: MaestroFlowHistorySummary): string;
|
|
104
|
+
/** Matches the dashboard's duration format. */
|
|
105
|
+
export declare function formatDurationMs(ms: number | null): string;
|