@datadog/datadog-ci 0.17.4 → 0.17.7

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.
Files changed (130) hide show
  1. package/LICENSE-3rdparty.csv +1 -0
  2. package/dist/commands/dependencies/__tests__/helpers/context.d.ts +12 -0
  3. package/dist/commands/dependencies/__tests__/helpers/stream.d.ts +2 -0
  4. package/dist/commands/dependencies/__tests__/helpers/upload.run.d.ts +13 -0
  5. package/dist/commands/dependencies/__tests__/upload.test.d.ts +1 -0
  6. package/dist/commands/dependencies/api.d.ts +2 -0
  7. package/dist/commands/dependencies/index.d.ts +1 -0
  8. package/dist/commands/dependencies/interfaces.d.ts +10 -0
  9. package/dist/commands/dependencies/renderer.d.ts +13 -0
  10. package/dist/commands/dependencies/upload.d.ts +16 -0
  11. package/dist/commands/dsyms/__tests__/upload.test.d.ts +1 -0
  12. package/dist/commands/dsyms/__tests__/utils.test.d.ts +1 -0
  13. package/dist/commands/dsyms/index.d.ts +1 -0
  14. package/dist/commands/dsyms/interfaces.d.ts +7 -0
  15. package/dist/commands/dsyms/renderer.d.ts +9 -0
  16. package/dist/commands/dsyms/upload.d.ts +11 -0
  17. package/dist/commands/dsyms/utils.d.ts +9 -0
  18. package/dist/commands/git-metadata/__tests__/git.test.d.ts +1 -0
  19. package/dist/commands/{commit → git-metadata}/__tests__/git.test.js +0 -0
  20. package/dist/commands/git-metadata/__tests__/upload.test.d.ts +1 -0
  21. package/dist/commands/{commit → git-metadata}/__tests__/upload.test.js +1 -1
  22. package/dist/commands/git-metadata/api.d.ts +3 -0
  23. package/dist/commands/{commit → git-metadata}/api.js +0 -0
  24. package/dist/commands/git-metadata/git.d.ts +8 -0
  25. package/dist/commands/{commit → git-metadata}/git.js +0 -0
  26. package/dist/commands/git-metadata/index.d.ts +1 -0
  27. package/dist/commands/{commit → git-metadata}/index.js +0 -0
  28. package/dist/commands/git-metadata/interfaces.d.ts +9 -0
  29. package/dist/commands/{commit → git-metadata}/interfaces.js +0 -0
  30. package/dist/commands/git-metadata/renderer.d.ts +8 -0
  31. package/dist/commands/{commit → git-metadata}/renderer.js +5 -8
  32. package/dist/commands/git-metadata/upload.d.ts +12 -0
  33. package/dist/commands/{commit → git-metadata}/upload.js +8 -3
  34. package/dist/commands/junit/__tests__/api.test.d.ts +1 -0
  35. package/dist/commands/junit/__tests__/upload.test.d.ts +1 -0
  36. package/dist/commands/junit/api.d.ts +8 -0
  37. package/dist/commands/junit/index.d.ts +1 -0
  38. package/dist/commands/junit/interfaces.d.ts +12 -0
  39. package/dist/commands/junit/renderer.d.ts +8 -0
  40. package/dist/commands/junit/upload.d.ts +15 -0
  41. package/dist/commands/junit/upload.js +8 -25
  42. package/dist/commands/junit/utils.d.ts +1 -0
  43. package/dist/commands/lambda/__tests__/function.test.d.ts +1 -0
  44. package/dist/commands/lambda/__tests__/instrument.test.d.ts +1 -0
  45. package/dist/commands/lambda/__tests__/loggroup.test.d.ts +1 -0
  46. package/dist/commands/lambda/__tests__/tags.test.d.ts +1 -0
  47. package/dist/commands/lambda/constants.d.ts +43 -0
  48. package/dist/commands/lambda/function.d.ts +43 -0
  49. package/dist/commands/lambda/index.d.ts +1 -0
  50. package/dist/commands/lambda/instrument.d.ts +28 -0
  51. package/dist/commands/lambda/interfaces.d.ts +16 -0
  52. package/dist/commands/lambda/loggroup.d.ts +17 -0
  53. package/dist/commands/lambda/tags.d.ts +7 -0
  54. package/dist/commands/sourcemaps/__tests__/git.test.d.ts +1 -0
  55. package/dist/commands/sourcemaps/__tests__/upload.test.d.ts +1 -0
  56. package/dist/commands/sourcemaps/__tests__/utils.test.d.ts +1 -0
  57. package/dist/commands/sourcemaps/git.d.ts +20 -0
  58. package/dist/commands/sourcemaps/index.d.ts +1 -0
  59. package/dist/commands/sourcemaps/interfaces.d.ts +15 -0
  60. package/dist/commands/sourcemaps/renderer.d.ts +12 -0
  61. package/dist/commands/sourcemaps/upload.d.ts +25 -0
  62. package/dist/commands/sourcemaps/utils.d.ts +3 -0
  63. package/dist/commands/sourcemaps/validation.d.ts +6 -0
  64. package/dist/commands/synthetics/__tests__/api.test.d.ts +1 -0
  65. package/dist/commands/synthetics/__tests__/cli.test.d.ts +1 -0
  66. package/dist/commands/synthetics/__tests__/cli.test.js +232 -0
  67. package/dist/commands/synthetics/__tests__/crypto.test.d.ts +1 -0
  68. package/dist/commands/synthetics/__tests__/fixtures.d.ts +71 -0
  69. package/dist/commands/synthetics/__tests__/fixtures.js +17 -1
  70. package/dist/commands/synthetics/__tests__/reporters/default.test.d.ts +1 -0
  71. package/dist/commands/synthetics/__tests__/reporters/default.test.js +2 -2
  72. package/dist/commands/synthetics/__tests__/reporters/junit.test.d.ts +1 -0
  73. package/dist/commands/synthetics/__tests__/reporters/junit.test.js +16 -14
  74. package/dist/commands/synthetics/__tests__/run-test.test.d.ts +1 -0
  75. package/dist/commands/synthetics/__tests__/run-test.test.js +42 -313
  76. package/dist/commands/synthetics/__tests__/tunnel.test.d.ts +1 -0
  77. package/dist/commands/synthetics/__tests__/utils.test.d.ts +1 -0
  78. package/dist/commands/synthetics/__tests__/utils.test.js +4 -0
  79. package/dist/commands/synthetics/__tests__/websocket.test.d.ts +1 -0
  80. package/dist/commands/synthetics/__tests__/websocket.test.js +6 -5
  81. package/dist/commands/synthetics/api.d.ts +24 -0
  82. package/dist/commands/synthetics/cli.d.ts +26 -0
  83. package/dist/commands/synthetics/cli.js +229 -0
  84. package/dist/commands/synthetics/crypto.d.ts +5 -0
  85. package/dist/commands/synthetics/errors.d.ts +9 -0
  86. package/dist/commands/synthetics/errors.js +25 -0
  87. package/dist/commands/synthetics/index.d.ts +1 -0
  88. package/dist/commands/synthetics/index.js +2 -2
  89. package/dist/commands/synthetics/interfaces.d.ts +342 -0
  90. package/dist/commands/synthetics/reporters/default.d.ts +18 -0
  91. package/dist/commands/synthetics/reporters/junit.d.ts +95 -0
  92. package/dist/commands/synthetics/reporters/junit.js +45 -19
  93. package/dist/commands/synthetics/run-test.d.ts +74 -0
  94. package/dist/commands/synthetics/run-test.js +135 -319
  95. package/dist/commands/synthetics/tunnel.d.ts +43 -0
  96. package/dist/commands/synthetics/utils.d.ts +26 -0
  97. package/dist/commands/synthetics/utils.js +11 -1
  98. package/dist/commands/synthetics/websocket.d.ts +38 -0
  99. package/dist/commands/trace/__tests__/trace.test.d.ts +1 -0
  100. package/dist/commands/trace/api.d.ts +6 -0
  101. package/dist/commands/trace/index.d.ts +1 -0
  102. package/dist/commands/trace/interfaces.d.ts +23 -0
  103. package/dist/commands/trace/trace.d.ts +17 -0
  104. package/dist/commands/trace/trace.js +32 -3
  105. package/dist/helpers/__tests__/ci.test.d.ts +1 -0
  106. package/dist/helpers/__tests__/ci.test.js +1 -1
  107. package/dist/helpers/__tests__/git.test.d.ts +1 -0
  108. package/dist/helpers/__tests__/retry.test.d.ts +1 -0
  109. package/dist/helpers/__tests__/retry.test.js +98 -0
  110. package/dist/helpers/__tests__/tags.test.d.ts +1 -0
  111. package/dist/helpers/__tests__/upload.test.d.ts +1 -0
  112. package/dist/helpers/__tests__/user-provided-git.test.d.ts +1 -0
  113. package/dist/helpers/__tests__/utils.test.d.ts +1 -0
  114. package/dist/helpers/apikey.d.ts +14 -0
  115. package/dist/helpers/ci.d.ts +15 -0
  116. package/dist/helpers/ci.js +3 -3
  117. package/dist/helpers/errors.d.ts +2 -0
  118. package/dist/helpers/formatting.d.ts +5 -0
  119. package/dist/helpers/git.d.ts +2 -0
  120. package/dist/helpers/interfaces.d.ts +19 -0
  121. package/dist/helpers/metrics.d.ts +11 -0
  122. package/dist/helpers/retry.d.ts +2 -0
  123. package/dist/helpers/retry.js +38 -0
  124. package/dist/helpers/tags.d.ts +28 -0
  125. package/dist/helpers/upload.d.ts +44 -0
  126. package/dist/helpers/upload.js +4 -26
  127. package/dist/helpers/user-provided-git.d.ts +1 -0
  128. package/dist/helpers/utils.d.ts +31 -0
  129. package/dist/index.d.ts +1 -0
  130. package/package.json +4 -3
@@ -0,0 +1,229 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.RunTestCommand = exports.DEFAULT_COMMAND_CONFIG = void 0;
16
+ const chalk_1 = __importDefault(require("chalk"));
17
+ const clipanion_1 = require("clipanion");
18
+ const deep_extend_1 = __importDefault(require("deep-extend"));
19
+ const utils_1 = require("../../helpers/utils");
20
+ const errors_1 = require("./errors");
21
+ const interfaces_1 = require("./interfaces");
22
+ const default_1 = require("./reporters/default");
23
+ const junit_1 = require("./reporters/junit");
24
+ const run_test_1 = require("./run-test");
25
+ const utils_2 = require("./utils");
26
+ exports.DEFAULT_COMMAND_CONFIG = {
27
+ apiKey: '',
28
+ appKey: '',
29
+ configPath: 'datadog-ci.json',
30
+ datadogSite: 'datadoghq.com',
31
+ failOnCriticalErrors: false,
32
+ failOnTimeout: true,
33
+ files: ['{,!(node_modules)/**/}*.synthetics.json'],
34
+ global: {},
35
+ locations: [],
36
+ pollingTimeout: 2 * 60 * 1000,
37
+ proxy: { protocol: 'http' },
38
+ publicIds: [],
39
+ subdomain: 'app',
40
+ tunnel: false,
41
+ };
42
+ class RunTestCommand extends clipanion_1.Command {
43
+ constructor() {
44
+ super(...arguments);
45
+ this.config = JSON.parse(JSON.stringify(exports.DEFAULT_COMMAND_CONFIG)); // Deep copy to avoid mutation during unit tests
46
+ }
47
+ execute() {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ const reporters = [new default_1.DefaultReporter(this)];
50
+ this.reporter = utils_2.getReporter(reporters);
51
+ if (this.jUnitReport) {
52
+ reporters.push(new junit_1.JUnitReporter(this));
53
+ }
54
+ yield this.resolveConfig();
55
+ const startTime = Date.now();
56
+ if (this.config.tunnel) {
57
+ this.reporter.log('You are using tunnel option, the chosen location(s) will be overridden by a location in your account region.\n');
58
+ }
59
+ let results;
60
+ let summary;
61
+ let tests;
62
+ let triggers;
63
+ try {
64
+ ;
65
+ ({ results, summary, tests, triggers } = yield run_test_1.executeTests(this.reporter, this.config));
66
+ }
67
+ catch (error) {
68
+ if (error instanceof errors_1.CiError) {
69
+ this.reportCiError(error, this.reporter);
70
+ if (error instanceof errors_1.CriticalError && this.config.failOnCriticalErrors) {
71
+ return 1;
72
+ }
73
+ }
74
+ return 0;
75
+ }
76
+ return this.renderResults(results, summary, tests, triggers, startTime);
77
+ });
78
+ }
79
+ getAppBaseURL() {
80
+ return `https://${this.config.subdomain}.${this.config.datadogSite}/`;
81
+ }
82
+ renderResults(results, summary, tests, triggers, startTime) {
83
+ var _a, _b, _c, _d;
84
+ // Sort tests to show success first then non blocking failures and finally blocking failures.
85
+ tests.sort(this.sortTestsByOutcome(results));
86
+ // Rendering the results.
87
+ (_a = this.reporter) === null || _a === void 0 ? void 0 : _a.reportStart({ startTime });
88
+ const locationNames = triggers.locations.reduce((mapping, location) => {
89
+ mapping[location.id] = location.display_name;
90
+ return mapping;
91
+ }, {});
92
+ let hasSucceeded = true; // Determine if all the tests have succeeded
93
+ for (const test of tests) {
94
+ const testResults = results[test.public_id];
95
+ if (!this.config.failOnTimeout) {
96
+ if (!summary.timedOut) {
97
+ summary.timedOut = 0;
98
+ }
99
+ const hasTimeout = testResults.some((pollResult) => pollResult.result.error === interfaces_1.ERRORS.TIMEOUT);
100
+ if (hasTimeout) {
101
+ summary.timedOut++;
102
+ }
103
+ }
104
+ if (!this.config.failOnCriticalErrors) {
105
+ if (!summary.criticalErrors) {
106
+ summary.criticalErrors = 0;
107
+ }
108
+ const hasCriticalErrors = testResults.some((pollResult) => utils_2.isCriticalError(pollResult.result));
109
+ if (hasCriticalErrors) {
110
+ summary.criticalErrors++;
111
+ }
112
+ }
113
+ const passed = utils_2.hasTestSucceeded(testResults, this.config.failOnCriticalErrors, this.config.failOnTimeout);
114
+ if (passed) {
115
+ summary.passed++;
116
+ }
117
+ else {
118
+ summary.failed++;
119
+ if (((_b = test.options.ci) === null || _b === void 0 ? void 0 : _b.executionRule) !== interfaces_1.ExecutionRule.NON_BLOCKING) {
120
+ hasSucceeded = false;
121
+ }
122
+ }
123
+ (_c = this.reporter) === null || _c === void 0 ? void 0 : _c.testEnd(test, testResults, this.getAppBaseURL(), locationNames, this.config.failOnCriticalErrors, this.config.failOnTimeout);
124
+ }
125
+ (_d = this.reporter) === null || _d === void 0 ? void 0 : _d.runEnd(summary);
126
+ return hasSucceeded ? 0 : 1;
127
+ }
128
+ reportCiError(error, reporter) {
129
+ switch (error.code) {
130
+ case 'NO_RESULTS_TO_POLL':
131
+ reporter.log('No results to poll.\n');
132
+ break;
133
+ case 'NO_TESTS_TO_RUN':
134
+ reporter.log('No test to run.\n');
135
+ break;
136
+ case 'MISSING_APP_KEY':
137
+ reporter.error(`Missing ${chalk_1.default.red.bold('DATADOG_APP_KEY')} in your environment.\n`);
138
+ break;
139
+ case 'MISSING_API_KEY':
140
+ reporter.error(`Missing ${chalk_1.default.red.bold('DATADOG_API_KEY')} in your environment.\n`);
141
+ break;
142
+ case 'POLL_RESULTS_FAILED':
143
+ reporter.error(`\n${chalk_1.default.bgRed.bold(' ERROR: unable to poll test results ')}\n${error.message}\n\n`);
144
+ break;
145
+ case 'TUNNEL_START_FAILED':
146
+ reporter.error(`\n${chalk_1.default.bgRed.bold(' ERROR: unable to start tunnel')}\n${error.message}\n\n`);
147
+ break;
148
+ case 'TRIGGER_TESTS_FAILED':
149
+ reporter.error(`\n${chalk_1.default.bgRed.bold(' ERROR: unable to trigger tests')}\n${error.message}\n\n`);
150
+ break;
151
+ case 'UNAVAILABLE_TEST_CONFIG':
152
+ reporter.error(`\n${chalk_1.default.bgRed.bold(' ERROR: unable to obtain test configurations with search query ')}\n${error.message}\n\n`);
153
+ break;
154
+ case 'UNAVAILABLE_TUNNEL_CONFIG':
155
+ reporter.error(`\n${chalk_1.default.bgRed.bold(' ERROR: unable to get tunnel configuration')}\n${error.message}\n\n`);
156
+ }
157
+ }
158
+ resolveConfig() {
159
+ var _a, _b;
160
+ return __awaiter(this, void 0, void 0, function* () {
161
+ // Default < file < ENV < CLI
162
+ // Override with file config variables
163
+ try {
164
+ this.config = yield utils_1.parseConfigFile(this.config, (_a = this.configPath) !== null && _a !== void 0 ? _a : this.config.configPath);
165
+ }
166
+ catch (error) {
167
+ if (this.configPath) {
168
+ throw error;
169
+ }
170
+ }
171
+ // Override with ENV variables
172
+ this.config = deep_extend_1.default(this.config, utils_2.removeUndefinedValues({
173
+ apiKey: process.env.DATADOG_API_KEY,
174
+ appKey: process.env.DATADOG_APP_KEY,
175
+ datadogSite: process.env.DATADOG_SITE,
176
+ locations: (_b = process.env.DATADOG_SYNTHETICS_LOCATIONS) === null || _b === void 0 ? void 0 : _b.split(';'),
177
+ subdomain: process.env.DATADOG_SUBDOMAIN,
178
+ }));
179
+ // Override with CLI parameters
180
+ this.config = deep_extend_1.default(this.config, utils_2.removeUndefinedValues({
181
+ apiKey: this.apiKey,
182
+ appKey: this.appKey,
183
+ configPath: this.configPath,
184
+ datadogSite: this.datadogSite,
185
+ failOnCriticalErrors: this.failOnCriticalErrors,
186
+ failOnTimeout: this.failOnTimeout,
187
+ files: this.files,
188
+ publicIds: this.publicIds,
189
+ subdomain: this.subdomain,
190
+ testSearchQuery: this.testSearchQuery,
191
+ tunnel: this.tunnel,
192
+ }));
193
+ if (typeof this.config.files === 'string') {
194
+ this.reporter.log('[DEPRECATED] "files" should be an array of string instead of a string.\n');
195
+ this.config.files = [this.config.files];
196
+ }
197
+ });
198
+ }
199
+ sortTestsByOutcome(results) {
200
+ return (t1, t2) => {
201
+ var _a, _b;
202
+ const success1 = utils_2.hasTestSucceeded(results[t1.public_id], this.config.failOnCriticalErrors, this.config.failOnTimeout);
203
+ const success2 = utils_2.hasTestSucceeded(results[t2.public_id], this.config.failOnCriticalErrors, this.config.failOnTimeout);
204
+ const isNonBlockingTest1 = ((_a = t1.options.ci) === null || _a === void 0 ? void 0 : _a.executionRule) === interfaces_1.ExecutionRule.NON_BLOCKING;
205
+ const isNonBlockingTest2 = ((_b = t2.options.ci) === null || _b === void 0 ? void 0 : _b.executionRule) === interfaces_1.ExecutionRule.NON_BLOCKING;
206
+ if (success1 === success2) {
207
+ if (isNonBlockingTest1 === isNonBlockingTest2) {
208
+ return 0;
209
+ }
210
+ return isNonBlockingTest1 ? -1 : 1;
211
+ }
212
+ return success1 ? -1 : 1;
213
+ };
214
+ }
215
+ }
216
+ exports.RunTestCommand = RunTestCommand;
217
+ RunTestCommand.addPath('synthetics', 'run-tests');
218
+ RunTestCommand.addOption('apiKey', clipanion_1.Command.String('--apiKey'));
219
+ RunTestCommand.addOption('appKey', clipanion_1.Command.String('--appKey'));
220
+ RunTestCommand.addOption('failOnCriticalErrors', clipanion_1.Command.Boolean('--failOnCriticalErrors'));
221
+ RunTestCommand.addOption('configPath', clipanion_1.Command.String('--config'));
222
+ RunTestCommand.addOption('datadogSite', clipanion_1.Command.String('--datadogSite'));
223
+ RunTestCommand.addOption('files', clipanion_1.Command.Array('-f,--files'));
224
+ RunTestCommand.addOption('failOnTimeout', clipanion_1.Command.Boolean('--failOnTimeout'));
225
+ RunTestCommand.addOption('publicIds', clipanion_1.Command.Array('-p,--public-id'));
226
+ RunTestCommand.addOption('testSearchQuery', clipanion_1.Command.String('-s,--search'));
227
+ RunTestCommand.addOption('subdomain', clipanion_1.Command.Boolean('--subdomain'));
228
+ RunTestCommand.addOption('tunnel', clipanion_1.Command.Boolean('-t,--tunnel'));
229
+ RunTestCommand.addOption('runName', clipanion_1.Command.String('-n,--runName'));
@@ -0,0 +1,5 @@
1
+ export declare const generateOpenSSHKeys: () => {
2
+ privateKey: string;
3
+ publicKey: string;
4
+ };
5
+ export declare const parseSSHKey: (key: string) => import("ssh2-streams").ParsedKey;
@@ -0,0 +1,9 @@
1
+ declare const ciErrorCodes: readonly ["UNAVAILABLE_TEST_CONFIG", "MISSING_API_KEY", "MISSING_APP_KEY", "NO_RESULTS_TO_POLL", "NO_TESTS_TO_RUN", "UNAVAILABLE_TUNNEL_CONFIG", "TUNNEL_START_FAILED", "TRIGGER_TESTS_FAILED", "POLL_RESULTS_FAILED"];
2
+ declare type CiErrorCode = typeof ciErrorCodes[number];
3
+ export declare class CiError extends Error {
4
+ code: CiErrorCode;
5
+ constructor(code: CiErrorCode);
6
+ }
7
+ export declare class CriticalError extends CiError {
8
+ }
9
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CriticalError = exports.CiError = void 0;
4
+ /* tslint:disable:max-classes-per-file */
5
+ const ciErrorCodes = [
6
+ 'UNAVAILABLE_TEST_CONFIG',
7
+ 'MISSING_API_KEY',
8
+ 'MISSING_APP_KEY',
9
+ 'NO_RESULTS_TO_POLL',
10
+ 'NO_TESTS_TO_RUN',
11
+ 'UNAVAILABLE_TUNNEL_CONFIG',
12
+ 'TUNNEL_START_FAILED',
13
+ 'TRIGGER_TESTS_FAILED',
14
+ 'POLL_RESULTS_FAILED',
15
+ ];
16
+ class CiError extends Error {
17
+ constructor(code) {
18
+ super();
19
+ this.code = code;
20
+ }
21
+ }
22
+ exports.CiError = CiError;
23
+ class CriticalError extends CiError {
24
+ }
25
+ exports.CriticalError = CriticalError;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const run_test_1 = require("./run-test");
4
- module.exports = [run_test_1.RunTestCommand];
3
+ const cli_1 = require("./cli");
4
+ module.exports = [cli_1.RunTestCommand];
@@ -0,0 +1,342 @@
1
+ /// <reference types="node" />
2
+ import { Metadata } from '../../helpers/interfaces';
3
+ import { ProxyConfiguration } from '../../helpers/utils';
4
+ import { TunnelInfo } from './tunnel';
5
+ export interface MainReporter {
6
+ error(error: string): void;
7
+ initErrors(errors: string[]): void;
8
+ log(log: string): void;
9
+ reportStart(timings: {
10
+ startTime: number;
11
+ }): void;
12
+ runEnd(summary: Summary): void;
13
+ testEnd(test: Test, results: PollResult[], baseUrl: string, locationNames: LocationsMapping, failOnCriticalErrors: boolean, failOnTimeout: boolean): void;
14
+ testTrigger(test: Test, testId: string, executionRule: ExecutionRule, config: ConfigOverride): void;
15
+ testWait(test: Test): void;
16
+ }
17
+ export declare enum ERRORS {
18
+ TIMEOUT = "Timeout",
19
+ ENDPOINT = "Endpoint Failure",
20
+ TUNNEL = "Tunnel Failure"
21
+ }
22
+ export declare type Reporter = Partial<MainReporter>;
23
+ export interface TestResult {
24
+ error?: string;
25
+ errorCode?: string;
26
+ errorMessage?: string;
27
+ eventType: string;
28
+ failure?: {
29
+ code: string;
30
+ message: string;
31
+ };
32
+ passed: boolean;
33
+ tunnel?: boolean;
34
+ unhealthy?: boolean;
35
+ }
36
+ export interface BrowserTestResult extends TestResult {
37
+ device: {
38
+ height: number;
39
+ id: string;
40
+ width: number;
41
+ };
42
+ duration: number;
43
+ error?: string | ERRORS;
44
+ startUrl: string;
45
+ stepDetails: Step[];
46
+ }
47
+ interface AssertionResult {
48
+ actual: any;
49
+ expected?: any;
50
+ valid: boolean;
51
+ }
52
+ export interface ApiTestResult extends TestResult {
53
+ assertionResults: AssertionResult[];
54
+ timings: {
55
+ total: number;
56
+ };
57
+ }
58
+ export interface MultiStep {
59
+ allowFailure: boolean;
60
+ assertionResults: AssertionResult[];
61
+ failure?: {
62
+ code: string;
63
+ message: string;
64
+ };
65
+ name: string;
66
+ passed: boolean;
67
+ skipped: boolean;
68
+ subtype: string;
69
+ timings: {
70
+ total: number;
71
+ };
72
+ }
73
+ export interface MultiStepsTestResult extends TestResult {
74
+ duration: number;
75
+ steps: MultiStep[];
76
+ }
77
+ export declare type Result = BrowserTestResult | ApiTestResult | MultiStepsTestResult;
78
+ export interface PollResult {
79
+ check?: Test;
80
+ check_id?: string;
81
+ dc_id: number;
82
+ result: Result;
83
+ resultID: string;
84
+ timestamp: number;
85
+ }
86
+ export interface Vitals {
87
+ cls?: number;
88
+ lcp?: number;
89
+ url: string;
90
+ }
91
+ export interface BrowserError {
92
+ description: string;
93
+ name: string;
94
+ type: string;
95
+ }
96
+ export interface Step {
97
+ allowFailure: boolean;
98
+ browserErrors: BrowserError[];
99
+ description: string;
100
+ duration: number;
101
+ error?: string;
102
+ publicId?: string;
103
+ skipped: boolean;
104
+ stepId: number;
105
+ subTestPublicId?: string;
106
+ subTestStepDetails?: Step[];
107
+ type: string;
108
+ url: string;
109
+ value?: string | number;
110
+ vitalsMetrics: Vitals[];
111
+ warnings?: {
112
+ message: string;
113
+ type: string;
114
+ }[];
115
+ }
116
+ export interface Test {
117
+ config: {
118
+ assertions: Assertion[];
119
+ request: {
120
+ dnsServer?: string;
121
+ headers: {
122
+ [key: string]: string;
123
+ };
124
+ host?: string;
125
+ method: string;
126
+ port?: number;
127
+ timeout: number;
128
+ url: string;
129
+ };
130
+ steps?: {
131
+ subtype: string;
132
+ }[];
133
+ variables: string[];
134
+ };
135
+ created_at: string;
136
+ created_by: User;
137
+ locations: string[];
138
+ message: string;
139
+ modified_at: string;
140
+ modified_by: User;
141
+ monitor_id: number;
142
+ name: string;
143
+ options: {
144
+ ci?: {
145
+ executionRule: ExecutionRule;
146
+ };
147
+ device_ids: string[];
148
+ min_failure_duration: number;
149
+ min_location_failed: number;
150
+ tick_every: number;
151
+ };
152
+ overall_state: number;
153
+ overall_state_modified: string;
154
+ public_id: string;
155
+ status: string;
156
+ stepCount: number;
157
+ subtype: string;
158
+ tags: string[];
159
+ type: string;
160
+ }
161
+ export interface InternalTest extends Test {
162
+ suite?: string;
163
+ }
164
+ export interface Assertion {
165
+ actual: string | number | Date | {
166
+ [key: string]: any;
167
+ };
168
+ errorMessage?: string;
169
+ operator: Operator;
170
+ property?: string;
171
+ target: string | number | Date | {
172
+ [key: string]: any;
173
+ };
174
+ type: string;
175
+ valid: boolean;
176
+ }
177
+ export declare enum Operator {
178
+ contains = "contains",
179
+ doesNotContain = "doesNotContain",
180
+ is = "is",
181
+ isNot = "isNot",
182
+ lessThan = "lessThan",
183
+ matches = "matches",
184
+ doesNotMatch = "doesNotMatch",
185
+ validates = "validates",
186
+ isInMoreThan = "isInMoreThan",
187
+ isInLessThan = "isInLessThan"
188
+ }
189
+ export interface User {
190
+ email: string;
191
+ handle: string;
192
+ id: number;
193
+ name: string;
194
+ }
195
+ export interface TriggerResponse {
196
+ device: string;
197
+ location: number;
198
+ public_id: string;
199
+ result_id: string;
200
+ }
201
+ export interface TriggerResult extends TriggerResponse {
202
+ pollingTimeout: number;
203
+ result?: PollResult;
204
+ }
205
+ export interface Location {
206
+ display_name: string;
207
+ id: number;
208
+ is_active: boolean;
209
+ name: string;
210
+ region: string;
211
+ }
212
+ export interface LocationsMapping {
213
+ [key: number]: string;
214
+ }
215
+ export interface Trigger {
216
+ locations: Location[];
217
+ results: TriggerResponse[];
218
+ triggered_check_ids: string[];
219
+ }
220
+ export interface RetryConfig {
221
+ count: number;
222
+ interval: number;
223
+ }
224
+ export interface ConfigOverride {
225
+ allowInsecureCertificates?: boolean;
226
+ basicAuth?: BasicAuthCredentials;
227
+ body?: string;
228
+ bodyType?: string;
229
+ cookies?: string | {
230
+ append?: boolean;
231
+ value: string;
232
+ };
233
+ defaultStepTimeout?: number;
234
+ deviceIds?: string[];
235
+ executionRule?: ExecutionRule;
236
+ followRedirects?: boolean;
237
+ headers?: {
238
+ [key: string]: string;
239
+ };
240
+ locations?: string[];
241
+ pollingTimeout?: number;
242
+ retry?: RetryConfig;
243
+ startUrl?: string;
244
+ tunnel?: TunnelInfo;
245
+ variables?: {
246
+ [key: string]: string;
247
+ };
248
+ }
249
+ export interface Payload {
250
+ metadata?: Metadata;
251
+ tests: TestPayload[];
252
+ }
253
+ export interface TestPayload extends ConfigOverride {
254
+ executionRule: ExecutionRule;
255
+ public_id: string;
256
+ }
257
+ export interface BasicAuthCredentials {
258
+ password: string;
259
+ username: string;
260
+ }
261
+ export interface TemplateVariables {
262
+ DOMAIN?: string;
263
+ HASH?: string;
264
+ HOST?: string;
265
+ HOSTNAME?: string;
266
+ ORIGIN?: string;
267
+ PARAMS?: string;
268
+ PATHNAME?: string;
269
+ PORT?: string;
270
+ PROTOCOL?: string;
271
+ SUBDOMAIN?: string;
272
+ URL: string;
273
+ }
274
+ export interface TemplateContext extends TemplateVariables, NodeJS.ProcessEnv {
275
+ }
276
+ export interface TriggerConfig {
277
+ config: ConfigOverride;
278
+ id: string;
279
+ suite?: string;
280
+ }
281
+ export declare enum ExecutionRule {
282
+ BLOCKING = "blocking",
283
+ NON_BLOCKING = "non_blocking",
284
+ SKIPPED = "skipped"
285
+ }
286
+ export interface Suite {
287
+ content: {
288
+ tests: TriggerConfig[];
289
+ };
290
+ name?: string;
291
+ }
292
+ export interface Summary {
293
+ criticalErrors: number;
294
+ failed: number;
295
+ notFound: number;
296
+ passed: number;
297
+ skipped: number;
298
+ timedOut: number;
299
+ }
300
+ export interface TestSearchResult {
301
+ tests: {
302
+ public_id: string;
303
+ }[];
304
+ }
305
+ export interface APIHelper {
306
+ getPresignedURL(testIds: string[]): Promise<{
307
+ url: string;
308
+ }>;
309
+ getTest(testId: string): Promise<Test>;
310
+ pollResults(resultIds: string[]): Promise<{
311
+ results: PollResult[];
312
+ }>;
313
+ searchTests(query: string): Promise<TestSearchResult>;
314
+ triggerTests(payload: Payload): Promise<Trigger>;
315
+ }
316
+ export interface APIConfiguration {
317
+ apiKey: string;
318
+ appKey: string;
319
+ baseIntakeUrl: string;
320
+ baseUrl: string;
321
+ proxyOpts: ProxyConfiguration;
322
+ }
323
+ export interface SyntheticsCIConfig {
324
+ apiKey: string;
325
+ appKey: string;
326
+ configPath: string;
327
+ datadogSite: string;
328
+ failOnCriticalErrors: boolean;
329
+ files: string[];
330
+ global: ConfigOverride;
331
+ locations: string[];
332
+ pollingTimeout: number;
333
+ proxy: ProxyConfiguration;
334
+ publicIds: string[];
335
+ subdomain: string;
336
+ testSearchQuery?: string;
337
+ tunnel: boolean;
338
+ }
339
+ export interface CommandConfig extends SyntheticsCIConfig {
340
+ failOnTimeout: boolean;
341
+ }
342
+ export {};
@@ -0,0 +1,18 @@
1
+ import { BaseContext } from 'clipanion';
2
+ import { ConfigOverride, ExecutionRule, LocationsMapping, PollResult, Reporter, Summary, Test } from '../interfaces';
3
+ export declare class DefaultReporter implements Reporter {
4
+ private write;
5
+ constructor({ context }: {
6
+ context: BaseContext;
7
+ });
8
+ error(error: string): void;
9
+ initError(errors: string[]): void;
10
+ log(log: string): void;
11
+ reportStart(timings: {
12
+ startTime: number;
13
+ }): void;
14
+ runEnd(summary: Summary): void;
15
+ testEnd(test: Test, results: PollResult[], baseUrl: string, locationNames: LocationsMapping, failOnCriticalErrors: boolean, failOnTimeout: boolean): void;
16
+ testTrigger(test: Test, testId: string, executionRule: ExecutionRule, config: ConfigOverride): void;
17
+ testWait(test: Test): void;
18
+ }