@datadog/datadog-ci 0.17.6-alpha → 0.17.9

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 (153) 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__/fixtures.d.ts +42 -0
  44. package/dist/commands/lambda/__tests__/fixtures.js +73 -0
  45. package/dist/commands/lambda/__tests__/functions/commons.test.d.ts +1 -0
  46. package/dist/commands/lambda/__tests__/functions/commons.test.js +171 -0
  47. package/dist/commands/lambda/__tests__/functions/instrument.test.d.ts +1 -0
  48. package/dist/commands/lambda/__tests__/{function.test.js → functions/instrument.test.js} +355 -417
  49. package/dist/commands/lambda/__tests__/functions/uninstrument.test.d.ts +1 -0
  50. package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +298 -0
  51. package/dist/commands/lambda/__tests__/instrument.test.d.ts +1 -0
  52. package/dist/commands/lambda/__tests__/instrument.test.js +270 -163
  53. package/dist/commands/lambda/__tests__/loggroup.test.d.ts +1 -0
  54. package/dist/commands/lambda/__tests__/loggroup.test.js +98 -34
  55. package/dist/commands/lambda/__tests__/tags.test.d.ts +1 -0
  56. package/dist/commands/lambda/__tests__/tags.test.js +107 -31
  57. package/dist/commands/lambda/__tests__/uninstrument.test.d.ts +1 -0
  58. package/dist/commands/lambda/__tests__/uninstrument.test.js +223 -0
  59. package/dist/commands/lambda/constants.d.ts +44 -0
  60. package/dist/commands/lambda/constants.js +2 -1
  61. package/dist/commands/lambda/functions/commons.d.ts +71 -0
  62. package/dist/commands/lambda/functions/commons.js +170 -0
  63. package/dist/commands/lambda/functions/instrument.d.ts +16 -0
  64. package/dist/commands/lambda/{function.js → functions/instrument.js} +42 -102
  65. package/dist/commands/lambda/functions/uninstrument.d.ts +6 -0
  66. package/dist/commands/lambda/functions/uninstrument.js +110 -0
  67. package/dist/commands/lambda/index.d.ts +1 -0
  68. package/dist/commands/lambda/index.js +2 -1
  69. package/dist/commands/lambda/instrument.d.ts +29 -0
  70. package/dist/commands/lambda/instrument.js +85 -40
  71. package/dist/commands/lambda/interfaces.d.ts +70 -0
  72. package/dist/commands/lambda/loggroup.d.ts +14 -0
  73. package/dist/commands/lambda/loggroup.js +27 -4
  74. package/dist/commands/lambda/tags.d.ts +6 -0
  75. package/dist/commands/lambda/tags.js +19 -3
  76. package/dist/commands/lambda/uninstrument.d.ts +11 -0
  77. package/dist/commands/lambda/uninstrument.js +127 -0
  78. package/dist/commands/sourcemaps/__tests__/git.test.d.ts +1 -0
  79. package/dist/commands/sourcemaps/__tests__/upload.test.d.ts +1 -0
  80. package/dist/commands/sourcemaps/__tests__/utils.test.d.ts +1 -0
  81. package/dist/commands/sourcemaps/git.d.ts +20 -0
  82. package/dist/commands/sourcemaps/index.d.ts +1 -0
  83. package/dist/commands/sourcemaps/interfaces.d.ts +15 -0
  84. package/dist/commands/sourcemaps/renderer.d.ts +12 -0
  85. package/dist/commands/sourcemaps/upload.d.ts +25 -0
  86. package/dist/commands/sourcemaps/utils.d.ts +3 -0
  87. package/dist/commands/sourcemaps/validation.d.ts +6 -0
  88. package/dist/commands/synthetics/__tests__/api.test.d.ts +1 -0
  89. package/dist/commands/synthetics/__tests__/cli.test.d.ts +1 -0
  90. package/dist/commands/synthetics/__tests__/cli.test.js +232 -0
  91. package/dist/commands/synthetics/__tests__/crypto.test.d.ts +1 -0
  92. package/dist/commands/synthetics/__tests__/fixtures.d.ts +71 -0
  93. package/dist/commands/synthetics/__tests__/fixtures.js +17 -2
  94. package/dist/commands/synthetics/__tests__/reporters/default.test.d.ts +1 -0
  95. package/dist/commands/synthetics/__tests__/reporters/default.test.js +5 -4
  96. package/dist/commands/synthetics/__tests__/reporters/junit.test.d.ts +1 -0
  97. package/dist/commands/synthetics/__tests__/run-test.test.d.ts +1 -0
  98. package/dist/commands/synthetics/__tests__/run-test.test.js +48 -319
  99. package/dist/commands/synthetics/__tests__/tunnel.test.d.ts +1 -0
  100. package/dist/commands/synthetics/__tests__/utils.test.d.ts +1 -0
  101. package/dist/commands/synthetics/__tests__/utils.test.js +13 -1
  102. package/dist/commands/synthetics/__tests__/websocket.test.d.ts +1 -0
  103. package/dist/commands/synthetics/__tests__/websocket.test.js +6 -5
  104. package/dist/commands/synthetics/api.d.ts +24 -0
  105. package/dist/commands/synthetics/cli.d.ts +26 -0
  106. package/dist/commands/synthetics/cli.js +229 -0
  107. package/dist/commands/synthetics/crypto.d.ts +5 -0
  108. package/dist/commands/synthetics/errors.d.ts +9 -0
  109. package/dist/commands/synthetics/errors.js +25 -0
  110. package/dist/commands/synthetics/index.d.ts +1 -0
  111. package/dist/commands/synthetics/index.js +2 -2
  112. package/dist/commands/synthetics/interfaces.d.ts +342 -0
  113. package/dist/commands/synthetics/reporters/default.d.ts +18 -0
  114. package/dist/commands/synthetics/reporters/default.js +4 -3
  115. package/dist/commands/synthetics/reporters/junit.d.ts +95 -0
  116. package/dist/commands/synthetics/run-test.d.ts +74 -0
  117. package/dist/commands/synthetics/run-test.js +135 -319
  118. package/dist/commands/synthetics/tunnel.d.ts +43 -0
  119. package/dist/commands/synthetics/utils.d.ts +27 -0
  120. package/dist/commands/synthetics/utils.js +24 -5
  121. package/dist/commands/synthetics/websocket.d.ts +38 -0
  122. package/dist/commands/trace/__tests__/trace.test.d.ts +1 -0
  123. package/dist/commands/trace/api.d.ts +6 -0
  124. package/dist/commands/trace/index.d.ts +1 -0
  125. package/dist/commands/trace/interfaces.d.ts +23 -0
  126. package/dist/commands/trace/trace.d.ts +17 -0
  127. package/dist/commands/trace/trace.js +32 -3
  128. package/dist/helpers/__tests__/ci.test.d.ts +1 -0
  129. package/dist/helpers/__tests__/ci.test.js +23 -0
  130. package/dist/helpers/__tests__/git.test.d.ts +1 -0
  131. package/dist/helpers/__tests__/retry.test.d.ts +1 -0
  132. package/dist/helpers/__tests__/retry.test.js +98 -0
  133. package/dist/helpers/__tests__/tags.test.d.ts +1 -0
  134. package/dist/helpers/__tests__/upload.test.d.ts +1 -0
  135. package/dist/helpers/__tests__/user-provided-git.test.d.ts +1 -0
  136. package/dist/helpers/__tests__/utils.test.d.ts +1 -0
  137. package/dist/helpers/apikey.d.ts +14 -0
  138. package/dist/helpers/ci.d.ts +15 -0
  139. package/dist/helpers/ci.js +13 -6
  140. package/dist/helpers/errors.d.ts +2 -0
  141. package/dist/helpers/formatting.d.ts +5 -0
  142. package/dist/helpers/git.d.ts +2 -0
  143. package/dist/helpers/interfaces.d.ts +19 -0
  144. package/dist/helpers/metrics.d.ts +11 -0
  145. package/dist/helpers/retry.d.ts +2 -0
  146. package/dist/helpers/retry.js +38 -0
  147. package/dist/helpers/tags.d.ts +28 -0
  148. package/dist/helpers/upload.d.ts +44 -0
  149. package/dist/helpers/upload.js +4 -26
  150. package/dist/helpers/user-provided-git.d.ts +1 -0
  151. package/dist/helpers/utils.d.ts +31 -0
  152. package/dist/index.d.ts +1 -0
  153. package/package.json +2 -1
@@ -0,0 +1,28 @@
1
+ export declare const CI_PIPELINE_URL = "ci.pipeline.url";
2
+ export declare const CI_PROVIDER_NAME = "ci.provider.name";
3
+ export declare const CI_PIPELINE_ID = "ci.pipeline.id";
4
+ export declare const CI_PIPELINE_NAME = "ci.pipeline.name";
5
+ export declare const CI_PIPELINE_NUMBER = "ci.pipeline.number";
6
+ export declare const CI_WORKSPACE_PATH = "ci.workspace_path";
7
+ export declare const GIT_REPOSITORY_URL = "git.repository_url";
8
+ export declare const CI_JOB_URL = "ci.job.url";
9
+ export declare const CI_JOB_NAME = "ci.job.name";
10
+ export declare const CI_STAGE_NAME = "ci.stage.name";
11
+ export declare const CI_LEVEL = "_dd.ci.level";
12
+ export declare const CI_BUILD_LEVEL = "_dd.ci.build_level";
13
+ export declare const GIT_BRANCH = "git.branch";
14
+ export declare const GIT_COMMIT_AUTHOR_DATE = "git.commit.author.date";
15
+ export declare const GIT_COMMIT_AUTHOR_EMAIL = "git.commit.author.email";
16
+ export declare const GIT_COMMIT_AUTHOR_NAME = "git.commit.author.name";
17
+ export declare const GIT_COMMIT_COMMITTER_DATE = "git.commit.committer.date";
18
+ export declare const GIT_COMMIT_COMMITTER_EMAIL = "git.commit.committer.email";
19
+ export declare const GIT_COMMIT_COMMITTER_NAME = "git.commit.committer.name";
20
+ export declare const GIT_COMMIT_MESSAGE = "git.commit.message";
21
+ export declare const GIT_SHA = "git.commit.sha";
22
+ export declare const GIT_TAG = "git.tag";
23
+ export declare const SPAN_TYPE = "span.type";
24
+ /**
25
+ * Receives an array of the form ['key:value', 'key2:value2']
26
+ * and returns an object of the form {key: 'value', key2: 'value2'}
27
+ */
28
+ export declare const parseTags: (tags: string[]) => {};
@@ -0,0 +1,44 @@
1
+ /// <reference types="node" />
2
+ import FormData from 'form-data';
3
+ import { ReadStream } from 'fs';
4
+ import { ApiKeyValidator } from './apikey';
5
+ import { RequestBuilder } from './interfaces';
6
+ /** Multipart payload destined to be sent to Datadog's API
7
+ */
8
+ export interface MultipartPayload {
9
+ content: Map<string, MultipartValue>;
10
+ }
11
+ export interface MultipartValue {
12
+ options?: FormData.AppendOptions | string;
13
+ value: string | ReadStream;
14
+ }
15
+ export interface UploadOptions {
16
+ /** ApiKeyValidator (optional) throws an InvalidConfigurationException when upload fails because
17
+ * of an invalid API key. Callers should most likely catch this exception and display it as a
18
+ * nice error message.
19
+ */
20
+ apiKeyValidator?: ApiKeyValidator;
21
+ /** Retries is the amount of upload retries before giving up. Some requests are never retried
22
+ * (400, 413).
23
+ */
24
+ retries: number;
25
+ /** Callback when upload fails (retries are not considered as failure)
26
+ */
27
+ onError(error: Error): void;
28
+ /** Callback to execute before retries
29
+ */
30
+ onRetry(error: Error, attempts: number): void;
31
+ /** Callback to execute before upload.
32
+ */
33
+ onUpload(): void;
34
+ }
35
+ export declare enum UploadStatus {
36
+ Success = 0,
37
+ Failure = 1,
38
+ Skipped = 2
39
+ }
40
+ /** Upload a MultipartPayload to Datadog's API using the provided RequestBuilder.
41
+ * This handles retries as well as logging information about upload if a logger is provided in
42
+ * the options
43
+ */
44
+ export declare const upload: (requestBuilder: RequestBuilder) => (payload: MultipartPayload, opts: UploadOptions) => Promise<UploadStatus>;
@@ -13,9 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.upload = exports.UploadStatus = void 0;
16
- const async_retry_1 = __importDefault(require("async-retry"));
17
16
  const form_data_1 = __importDefault(require("form-data"));
18
- const errorCodesNoRetry = [400, 403, 413];
17
+ const retry_1 = require("./retry");
19
18
  var UploadStatus;
20
19
  (function (UploadStatus) {
21
20
  UploadStatus[UploadStatus["Success"] = 0] = "Success";
@@ -29,10 +28,10 @@ var UploadStatus;
29
28
  const upload = (requestBuilder) => (payload, opts) => __awaiter(void 0, void 0, void 0, function* () {
30
29
  opts.onUpload();
31
30
  try {
32
- yield uploadWithRetry(requestBuilder, {
31
+ yield retry_1.retryRequest(() => uploadMultipart(requestBuilder, payload), {
33
32
  onRetry: opts.onRetry,
34
33
  retries: opts.retries,
35
- })(payload);
34
+ });
36
35
  return UploadStatus.Success;
37
36
  }
38
37
  catch (error) {
@@ -52,31 +51,10 @@ const upload = (requestBuilder) => (payload, opts) => __awaiter(void 0, void 0,
52
51
  }
53
52
  });
54
53
  exports.upload = upload;
55
- const uploadWithRetry = (requestBuilder, retryOpts) => (payload) => __awaiter(void 0, void 0, void 0, function* () {
56
- // Upload function, passed to async-retry
57
- const doUpload = (bail) => __awaiter(void 0, void 0, void 0, function* () {
58
- try {
59
- yield uploadMultipart(requestBuilder)(payload);
60
- }
61
- catch (error) {
62
- if (error.response) {
63
- // If it's an axios error
64
- if (!errorCodesNoRetry.includes(error.response.status)) {
65
- // And a status code that is not excluded from retries, throw the error so that upload is retried
66
- throw error;
67
- }
68
- }
69
- // If it's another error or an axios error we don't want to retry, bail
70
- bail(error);
71
- }
72
- });
73
- // Do the actual call
74
- return async_retry_1.default(doUpload, retryOpts);
75
- });
76
54
  // Dependency follows-redirects sets a default maxBodyLength of 10 MB https://github.com/follow-redirects/follow-redirects/blob/b774a77e582b97174813b3eaeb86931becba69db/index.js#L391
77
55
  // We don't want any hard limit enforced by the CLI, the backend will enforce a max size by returning 413 errors.
78
56
  const maxBodyLength = Infinity;
79
- const uploadMultipart = (request) => (payload) => __awaiter(void 0, void 0, void 0, function* () {
57
+ const uploadMultipart = (request, payload) => __awaiter(void 0, void 0, void 0, function* () {
80
58
  const form = new form_data_1.default();
81
59
  payload.content.forEach((value, key) => {
82
60
  form.append(key, value.value, value.options);
@@ -0,0 +1 @@
1
+ export declare const getUserGitMetadata: () => {};
@@ -0,0 +1,31 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import ProxyAgent from 'proxy-agent';
3
+ import type { SpanTags } from './interfaces';
4
+ export declare const pick: <T extends object, K extends keyof T>(base: T, keys: K[]) => Partial<T>;
5
+ export declare const getConfig: (configPath: string) => Promise<any>;
6
+ export declare const parseConfigFile: <T>(baseConfig: T, configPath?: string | undefined) => Promise<T>;
7
+ declare type ProxyType = 'http' | 'https' | 'socks' | 'socks4' | 'socks4a' | 'socks5' | 'socks5h' | 'pac+data' | 'pac+file' | 'pac+ftp' | 'pac+http' | 'pac+https';
8
+ export interface ProxyConfiguration {
9
+ auth?: {
10
+ password: string;
11
+ username: string;
12
+ };
13
+ host?: string;
14
+ port?: number;
15
+ protocol: ProxyType;
16
+ }
17
+ export declare const getProxyUrl: (options?: ProxyConfiguration | undefined) => string;
18
+ export interface RequestOptions {
19
+ apiKey: string;
20
+ appKey?: string;
21
+ baseUrl: string;
22
+ headers?: Map<string, string>;
23
+ overrideUrl?: string;
24
+ proxyOpts?: ProxyConfiguration;
25
+ }
26
+ export declare const getRequestBuilder: (options: RequestOptions) => (args: AxiosRequestConfig) => import("axios").AxiosPromise<any>;
27
+ export declare const getProxyAgent: (proxyOpts?: ProxyConfiguration | undefined) => ReturnType<typeof ProxyAgent>;
28
+ export declare const getApiHostForSite: (site: string) => string;
29
+ export declare const buildPath: (...args: string[]) => string;
30
+ export declare const removeEmptyValues: (tags: SpanTags) => {};
31
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/datadog-ci",
3
- "version": "0.17.6-alpha",
3
+ "version": "0.17.9",
4
4
  "description": "Run datadog actions from the CI.",
5
5
  "main": "dist/index.js",
6
6
  "repository": "https://github.com/DataDog/datadog-ci",
@@ -79,6 +79,7 @@
79
79
  "@types/xml2js": "0.4.9",
80
80
  "jest": "27.0.5",
81
81
  "jest-environment-node": "27.0.5",
82
+ "jest-matcher-specific-error": "1.0.0",
82
83
  "prettier": "2.0.5",
83
84
  "proxy": "1.0.2",
84
85
  "ts-jest": "27.0.3",