@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,95 @@
1
+ import { BaseContext } from 'clipanion';
2
+ import { InternalTest, LocationsMapping, PollResult, Reporter, Vitals } from '../interfaces';
3
+ interface Stats {
4
+ allowfailures: number;
5
+ errors: number;
6
+ failures: number;
7
+ skipped: number;
8
+ tests: number;
9
+ warnings: number;
10
+ }
11
+ interface XMLTestCaseProperties extends Stats {
12
+ name: string;
13
+ time: number | undefined;
14
+ timestamp: string;
15
+ }
16
+ export interface XMLTestCase {
17
+ $: XMLTestCaseProperties;
18
+ allowed_error: XMLError[];
19
+ browser_error: XMLError[];
20
+ error: XMLError[];
21
+ properties: {
22
+ property: {
23
+ $: {
24
+ name: string;
25
+ value: any;
26
+ };
27
+ }[];
28
+ };
29
+ testcase: XMLStep[];
30
+ warning: XMLError[];
31
+ }
32
+ interface XMLStepProperties extends Stats {
33
+ allow_failure: boolean;
34
+ is_skipped: boolean;
35
+ name: string;
36
+ substep_public_id?: string;
37
+ time: number;
38
+ type: string;
39
+ url?: string;
40
+ }
41
+ interface XMLStep {
42
+ $: XMLStepProperties;
43
+ browser_error?: {
44
+ $: {
45
+ name: string;
46
+ type: string;
47
+ };
48
+ _: string;
49
+ }[];
50
+ error: {
51
+ $: {
52
+ type: 'assertion';
53
+ };
54
+ _: string;
55
+ }[];
56
+ vitals?: {
57
+ $: Vitals;
58
+ }[];
59
+ warning?: {
60
+ $: {
61
+ type: string;
62
+ };
63
+ _: string;
64
+ }[];
65
+ }
66
+ interface XMLError {
67
+ $: {
68
+ type: string;
69
+ [key: string]: string;
70
+ };
71
+ _: string;
72
+ }
73
+ interface Args {
74
+ context: BaseContext;
75
+ jUnitReport?: string;
76
+ runName?: string;
77
+ }
78
+ export declare const getDefaultStats: () => Stats;
79
+ export declare class JUnitReporter implements Reporter {
80
+ private builder;
81
+ private destination;
82
+ private json;
83
+ private write;
84
+ constructor({ context, jUnitReport, runName }: Args);
85
+ runEnd(): Promise<void>;
86
+ testEnd(test: InternalTest, results: PollResult[], baseUrl: string, locations: LocationsMapping, failOnCriticalErrors: boolean, failOnTimeout: boolean): void;
87
+ private getApiStepStats;
88
+ private getApiTestStep;
89
+ private getBrowserStepStats;
90
+ private getBrowserTestStep;
91
+ private getResultStats;
92
+ private getSuiteStats;
93
+ private getTestCase;
94
+ }
95
+ export {};
@@ -64,7 +64,7 @@ class JUnitReporter {
64
64
  }
65
65
  });
66
66
  }
67
- testEnd(test, results, baseUrl, locations) {
67
+ testEnd(test, results, baseUrl, locations, failOnCriticalErrors, failOnTimeout) {
68
68
  const suiteRunName = test.suite || 'Undefined suite';
69
69
  let suiteRun = this.json.testsuites.testsuite.find((suite) => suite.$.name === suiteRunName);
70
70
  if (!suiteRun) {
@@ -77,7 +77,7 @@ class JUnitReporter {
77
77
  // Update stats for the suite.
78
78
  suiteRun.$ = Object.assign(Object.assign({}, suiteRun.$), this.getSuiteStats(results, getStats(suiteRun.$)));
79
79
  for (const result of results) {
80
- const testCase = this.getTestCase(test, result, locations);
80
+ const testCase = this.getTestCase(test, result, locations, failOnCriticalErrors, failOnTimeout);
81
81
  // Timeout errors are only reported at the top level.
82
82
  if (result.result.error === interfaces_1.ERRORS.TIMEOUT) {
83
83
  testCase.error.push({
@@ -88,7 +88,8 @@ class JUnitReporter {
88
88
  if ('stepDetails' in result.result) {
89
89
  // It's a browser test.
90
90
  for (const stepDetail of result.result.stepDetails) {
91
- const { browser_error, error, warning } = this.getBrowserTestStep(stepDetail);
91
+ const { allowed_error, browser_error, error, warning } = this.getBrowserTestStep(stepDetail);
92
+ testCase.allowed_error.push(...allowed_error);
92
93
  testCase.browser_error.push(...browser_error);
93
94
  testCase.error.push(...error);
94
95
  testCase.warning.push(...warning);
@@ -97,7 +98,8 @@ class JUnitReporter {
97
98
  else if ('steps' in result.result) {
98
99
  // It's a multistep test.
99
100
  for (const step of result.result.steps) {
100
- const { error } = this.getApiTestStep(step);
101
+ const { allowed_error, error } = this.getApiTestStep(step);
102
+ testCase.allowed_error.push(...allowed_error);
101
103
  testCase.error.push(...error);
102
104
  }
103
105
  }
@@ -124,11 +126,22 @@ class JUnitReporter {
124
126
  };
125
127
  }
126
128
  getApiTestStep(step) {
129
+ const allowedError = [];
127
130
  const error = [];
128
131
  if (step.failure) {
129
- error.push({ $: { type: step.failure.code, step: step.name }, _: step.failure.message });
132
+ const xmlError = {
133
+ $: { type: step.failure.code, step: step.name, allowFailure: `${step.allowFailure}` },
134
+ _: step.failure.message,
135
+ };
136
+ if (step.allowFailure) {
137
+ allowedError.push(xmlError);
138
+ }
139
+ else {
140
+ error.push(xmlError);
141
+ }
130
142
  }
131
143
  return {
144
+ allowed_error: allowedError,
132
145
  error,
133
146
  };
134
147
  }
@@ -145,6 +158,7 @@ class JUnitReporter {
145
158
  }
146
159
  getBrowserTestStep(stepDetail) {
147
160
  var _a, _b;
161
+ const allowedError = [];
148
162
  const browserError = [];
149
163
  const error = [];
150
164
  const warning = [];
@@ -155,10 +169,16 @@ class JUnitReporter {
155
169
  })));
156
170
  }
157
171
  if (stepDetail.error) {
158
- error.push({
159
- $: { type: 'assertion', step: stepDetail.description },
172
+ const xmlError = {
173
+ $: { type: 'assertion', step: stepDetail.description, allowFailure: `${stepDetail.allowFailure}` },
160
174
  _: stepDetail.error,
161
- });
175
+ };
176
+ if (stepDetail.allowFailure) {
177
+ allowedError.push(xmlError);
178
+ }
179
+ else {
180
+ error.push(xmlError);
181
+ }
162
182
  }
163
183
  if ((_b = stepDetail.warnings) === null || _b === void 0 ? void 0 : _b.length) {
164
184
  warning.push(...stepDetail.warnings.map((w) => ({
@@ -167,6 +187,7 @@ class JUnitReporter {
167
187
  })));
168
188
  }
169
189
  return {
190
+ allowed_error: allowedError,
170
191
  browser_error: browserError,
171
192
  error,
172
193
  warning,
@@ -209,25 +230,18 @@ class JUnitReporter {
209
230
  }
210
231
  return stats;
211
232
  }
212
- getTestCase(test, result, locations) {
233
+ getTestCase(test, result, locations, failOnCriticalErrors, failOnTimeout) {
213
234
  var _a;
235
+ const timeout = result.result.error === interfaces_1.ERRORS.TIMEOUT;
236
+ const passed = utils_1.hasTestSucceeded([result], failOnCriticalErrors, failOnTimeout);
214
237
  return {
215
238
  $: Object.assign({ name: test.name, time: utils_1.getResultDuration(result.result) / 1000, timestamp: new Date(result.timestamp).toISOString() }, this.getResultStats(result)),
239
+ allowed_error: [],
216
240
  browser_error: [],
217
241
  error: [],
218
242
  properties: {
219
243
  property: [
220
- { $: { name: 'status', value: test.status } },
221
- { $: { name: 'public_id', value: test.public_id } },
222
244
  { $: { name: 'check_id', value: result.check_id } },
223
- { $: { name: 'result_id', value: result.resultID } },
224
- { $: { name: 'type', value: test.type } },
225
- { $: { name: 'message', value: test.message } },
226
- { $: { name: 'monitor_id', value: test.monitor_id } },
227
- { $: { name: 'tags', value: test.tags.join(',') } },
228
- { $: { name: 'location', value: locations[result.dc_id] } },
229
- { $: { name: 'execution_rule', value: (_a = test.options.ci) === null || _a === void 0 ? void 0 : _a.executionRule } },
230
- ...('startUrl' in result.result ? [{ $: { name: 'start_url', value: result.result.startUrl } }] : []),
231
245
  ...('device' in result.result
232
246
  ? [
233
247
  { $: { name: 'device', value: result.result.device.id } },
@@ -235,6 +249,18 @@ class JUnitReporter {
235
249
  { $: { name: 'height', value: result.result.device.height } },
236
250
  ]
237
251
  : []),
252
+ { $: { name: 'execution_rule', value: (_a = test.options.ci) === null || _a === void 0 ? void 0 : _a.executionRule } },
253
+ { $: { name: 'location', value: locations[result.dc_id] } },
254
+ { $: { name: 'message', value: test.message } },
255
+ { $: { name: 'monitor_id', value: test.monitor_id } },
256
+ { $: { name: 'passed', value: `${passed}` } },
257
+ { $: { name: 'public_id', value: test.public_id } },
258
+ { $: { name: 'result_id', value: result.resultID } },
259
+ ...('startUrl' in result.result ? [{ $: { name: 'start_url', value: result.result.startUrl } }] : []),
260
+ { $: { name: 'status', value: test.status } },
261
+ { $: { name: 'tags', value: test.tags.join(',') } },
262
+ { $: { name: 'timeout', value: `${timeout}` } },
263
+ { $: { name: 'type', value: test.type } },
238
264
  ].filter((prop) => prop.$.value),
239
265
  },
240
266
  testcase: [],
@@ -0,0 +1,74 @@
1
+ import { APIHelper, MainReporter, PollResult, Summary, SyntheticsCIConfig, Test, Trigger } from './interfaces';
2
+ export declare const executeTests: (reporter: MainReporter, config: SyntheticsCIConfig) => Promise<{
3
+ results: {
4
+ [key: string]: PollResult[];
5
+ };
6
+ summary: Summary;
7
+ tests: Test[];
8
+ triggers: Trigger;
9
+ }>;
10
+ export declare const getTestsList: (api: APIHelper, config: SyntheticsCIConfig, reporter: MainReporter) => Promise<{
11
+ config: {
12
+ allowInsecureCertificates?: boolean | undefined;
13
+ basicAuth?: import("./interfaces").BasicAuthCredentials | undefined;
14
+ body?: string | undefined;
15
+ bodyType?: string | undefined;
16
+ cookies?: string | {
17
+ append?: boolean | undefined;
18
+ value: string;
19
+ } | undefined;
20
+ defaultStepTimeout?: number | undefined;
21
+ deviceIds?: string[] | undefined;
22
+ executionRule?: import("./interfaces").ExecutionRule | undefined;
23
+ followRedirects?: boolean | undefined;
24
+ headers?: {
25
+ [key: string]: string;
26
+ } | undefined;
27
+ locations: string[];
28
+ pollingTimeout?: number | undefined;
29
+ retry?: import("./interfaces").RetryConfig | undefined;
30
+ startUrl?: string | undefined;
31
+ tunnel?: import("./tunnel").TunnelInfo | undefined;
32
+ variables?: {
33
+ [key: string]: string;
34
+ } | undefined;
35
+ } | {
36
+ allowInsecureCertificates?: boolean | undefined;
37
+ basicAuth?: import("./interfaces").BasicAuthCredentials | undefined;
38
+ body?: string | undefined;
39
+ bodyType?: string | undefined;
40
+ cookies?: string | {
41
+ append?: boolean | undefined;
42
+ value: string;
43
+ } | undefined;
44
+ defaultStepTimeout?: number | undefined;
45
+ deviceIds?: string[] | undefined;
46
+ executionRule?: import("./interfaces").ExecutionRule | undefined;
47
+ followRedirects?: boolean | undefined;
48
+ headers?: {
49
+ [key: string]: string;
50
+ } | undefined;
51
+ locations?: string[] | undefined;
52
+ pollingTimeout?: number | undefined;
53
+ retry?: import("./interfaces").RetryConfig | undefined;
54
+ startUrl?: string | undefined;
55
+ tunnel?: import("./tunnel").TunnelInfo | undefined;
56
+ variables?: {
57
+ [key: string]: string;
58
+ } | undefined;
59
+ };
60
+ id: string;
61
+ suite: string | undefined;
62
+ }[]>;
63
+ export declare const getApiHelper: (config: SyntheticsCIConfig) => {
64
+ getPresignedURL: (testIds: string[]) => Promise<{
65
+ url: string;
66
+ }>;
67
+ getTest: (testId: string) => Promise<Test>;
68
+ pollResults: (resultIds: string[]) => Promise<{
69
+ results: PollResult[];
70
+ }>;
71
+ searchTests: (query: string) => Promise<import("./interfaces").TestSearchResult>;
72
+ triggerTests: (data: import("./interfaces").Payload) => Promise<Trigger>;
73
+ };
74
+ export declare const getDatadogHost: (useIntake: boolean | undefined, config: SyntheticsCIConfig) => string;