@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.
- package/LICENSE-3rdparty.csv +1 -0
- package/dist/commands/dependencies/__tests__/helpers/context.d.ts +12 -0
- package/dist/commands/dependencies/__tests__/helpers/stream.d.ts +2 -0
- package/dist/commands/dependencies/__tests__/helpers/upload.run.d.ts +13 -0
- package/dist/commands/dependencies/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/dependencies/api.d.ts +2 -0
- package/dist/commands/dependencies/index.d.ts +1 -0
- package/dist/commands/dependencies/interfaces.d.ts +10 -0
- package/dist/commands/dependencies/renderer.d.ts +13 -0
- package/dist/commands/dependencies/upload.d.ts +16 -0
- package/dist/commands/dsyms/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/dsyms/__tests__/utils.test.d.ts +1 -0
- package/dist/commands/dsyms/index.d.ts +1 -0
- package/dist/commands/dsyms/interfaces.d.ts +7 -0
- package/dist/commands/dsyms/renderer.d.ts +9 -0
- package/dist/commands/dsyms/upload.d.ts +11 -0
- package/dist/commands/dsyms/utils.d.ts +9 -0
- package/dist/commands/git-metadata/__tests__/git.test.d.ts +1 -0
- package/dist/commands/{commit → git-metadata}/__tests__/git.test.js +0 -0
- package/dist/commands/git-metadata/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/{commit → git-metadata}/__tests__/upload.test.js +1 -1
- package/dist/commands/git-metadata/api.d.ts +3 -0
- package/dist/commands/{commit → git-metadata}/api.js +0 -0
- package/dist/commands/git-metadata/git.d.ts +8 -0
- package/dist/commands/{commit → git-metadata}/git.js +0 -0
- package/dist/commands/git-metadata/index.d.ts +1 -0
- package/dist/commands/{commit → git-metadata}/index.js +0 -0
- package/dist/commands/git-metadata/interfaces.d.ts +9 -0
- package/dist/commands/{commit → git-metadata}/interfaces.js +0 -0
- package/dist/commands/git-metadata/renderer.d.ts +8 -0
- package/dist/commands/{commit → git-metadata}/renderer.js +5 -8
- package/dist/commands/git-metadata/upload.d.ts +12 -0
- package/dist/commands/{commit → git-metadata}/upload.js +8 -3
- package/dist/commands/junit/__tests__/api.test.d.ts +1 -0
- package/dist/commands/junit/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/junit/api.d.ts +8 -0
- package/dist/commands/junit/index.d.ts +1 -0
- package/dist/commands/junit/interfaces.d.ts +12 -0
- package/dist/commands/junit/renderer.d.ts +8 -0
- package/dist/commands/junit/upload.d.ts +15 -0
- package/dist/commands/junit/upload.js +8 -25
- package/dist/commands/junit/utils.d.ts +1 -0
- package/dist/commands/lambda/__tests__/fixtures.d.ts +42 -0
- package/dist/commands/lambda/__tests__/fixtures.js +73 -0
- package/dist/commands/lambda/__tests__/functions/commons.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/functions/commons.test.js +171 -0
- package/dist/commands/lambda/__tests__/functions/instrument.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/{function.test.js → functions/instrument.test.js} +355 -417
- package/dist/commands/lambda/__tests__/functions/uninstrument.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +298 -0
- package/dist/commands/lambda/__tests__/instrument.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/instrument.test.js +270 -163
- package/dist/commands/lambda/__tests__/loggroup.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/loggroup.test.js +98 -34
- package/dist/commands/lambda/__tests__/tags.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/tags.test.js +107 -31
- package/dist/commands/lambda/__tests__/uninstrument.test.d.ts +1 -0
- package/dist/commands/lambda/__tests__/uninstrument.test.js +223 -0
- package/dist/commands/lambda/constants.d.ts +44 -0
- package/dist/commands/lambda/constants.js +2 -1
- package/dist/commands/lambda/functions/commons.d.ts +71 -0
- package/dist/commands/lambda/functions/commons.js +170 -0
- package/dist/commands/lambda/functions/instrument.d.ts +16 -0
- package/dist/commands/lambda/{function.js → functions/instrument.js} +42 -102
- package/dist/commands/lambda/functions/uninstrument.d.ts +6 -0
- package/dist/commands/lambda/functions/uninstrument.js +110 -0
- package/dist/commands/lambda/index.d.ts +1 -0
- package/dist/commands/lambda/index.js +2 -1
- package/dist/commands/lambda/instrument.d.ts +29 -0
- package/dist/commands/lambda/instrument.js +85 -40
- package/dist/commands/lambda/interfaces.d.ts +70 -0
- package/dist/commands/lambda/loggroup.d.ts +14 -0
- package/dist/commands/lambda/loggroup.js +27 -4
- package/dist/commands/lambda/tags.d.ts +6 -0
- package/dist/commands/lambda/tags.js +19 -3
- package/dist/commands/lambda/uninstrument.d.ts +11 -0
- package/dist/commands/lambda/uninstrument.js +127 -0
- package/dist/commands/sourcemaps/__tests__/git.test.d.ts +1 -0
- package/dist/commands/sourcemaps/__tests__/upload.test.d.ts +1 -0
- package/dist/commands/sourcemaps/__tests__/utils.test.d.ts +1 -0
- package/dist/commands/sourcemaps/git.d.ts +20 -0
- package/dist/commands/sourcemaps/index.d.ts +1 -0
- package/dist/commands/sourcemaps/interfaces.d.ts +15 -0
- package/dist/commands/sourcemaps/renderer.d.ts +12 -0
- package/dist/commands/sourcemaps/upload.d.ts +25 -0
- package/dist/commands/sourcemaps/utils.d.ts +3 -0
- package/dist/commands/sourcemaps/validation.d.ts +6 -0
- package/dist/commands/synthetics/__tests__/api.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/cli.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/cli.test.js +232 -0
- package/dist/commands/synthetics/__tests__/crypto.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/fixtures.d.ts +71 -0
- package/dist/commands/synthetics/__tests__/fixtures.js +17 -2
- package/dist/commands/synthetics/__tests__/reporters/default.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/reporters/default.test.js +5 -4
- package/dist/commands/synthetics/__tests__/reporters/junit.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/run-test.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/run-test.test.js +48 -319
- package/dist/commands/synthetics/__tests__/tunnel.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/utils.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/utils.test.js +13 -1
- package/dist/commands/synthetics/__tests__/websocket.test.d.ts +1 -0
- package/dist/commands/synthetics/__tests__/websocket.test.js +6 -5
- package/dist/commands/synthetics/api.d.ts +24 -0
- package/dist/commands/synthetics/cli.d.ts +26 -0
- package/dist/commands/synthetics/cli.js +229 -0
- package/dist/commands/synthetics/crypto.d.ts +5 -0
- package/dist/commands/synthetics/errors.d.ts +9 -0
- package/dist/commands/synthetics/errors.js +25 -0
- package/dist/commands/synthetics/index.d.ts +1 -0
- package/dist/commands/synthetics/index.js +2 -2
- package/dist/commands/synthetics/interfaces.d.ts +342 -0
- package/dist/commands/synthetics/reporters/default.d.ts +18 -0
- package/dist/commands/synthetics/reporters/default.js +4 -3
- package/dist/commands/synthetics/reporters/junit.d.ts +95 -0
- package/dist/commands/synthetics/run-test.d.ts +74 -0
- package/dist/commands/synthetics/run-test.js +135 -319
- package/dist/commands/synthetics/tunnel.d.ts +43 -0
- package/dist/commands/synthetics/utils.d.ts +27 -0
- package/dist/commands/synthetics/utils.js +24 -5
- package/dist/commands/synthetics/websocket.d.ts +38 -0
- package/dist/commands/trace/__tests__/trace.test.d.ts +1 -0
- package/dist/commands/trace/api.d.ts +6 -0
- package/dist/commands/trace/index.d.ts +1 -0
- package/dist/commands/trace/interfaces.d.ts +23 -0
- package/dist/commands/trace/trace.d.ts +17 -0
- package/dist/commands/trace/trace.js +32 -3
- package/dist/helpers/__tests__/ci.test.d.ts +1 -0
- package/dist/helpers/__tests__/ci.test.js +23 -0
- package/dist/helpers/__tests__/git.test.d.ts +1 -0
- package/dist/helpers/__tests__/retry.test.d.ts +1 -0
- package/dist/helpers/__tests__/retry.test.js +98 -0
- package/dist/helpers/__tests__/tags.test.d.ts +1 -0
- package/dist/helpers/__tests__/upload.test.d.ts +1 -0
- package/dist/helpers/__tests__/user-provided-git.test.d.ts +1 -0
- package/dist/helpers/__tests__/utils.test.d.ts +1 -0
- package/dist/helpers/apikey.d.ts +14 -0
- package/dist/helpers/ci.d.ts +15 -0
- package/dist/helpers/ci.js +13 -6
- package/dist/helpers/errors.d.ts +2 -0
- package/dist/helpers/formatting.d.ts +5 -0
- package/dist/helpers/git.d.ts +2 -0
- package/dist/helpers/interfaces.d.ts +19 -0
- package/dist/helpers/metrics.d.ts +11 -0
- package/dist/helpers/retry.d.ts +2 -0
- package/dist/helpers/retry.js +38 -0
- package/dist/helpers/tags.d.ts +28 -0
- package/dist/helpers/upload.d.ts +44 -0
- package/dist/helpers/upload.js +4 -26
- package/dist/helpers/user-provided-git.d.ts +1 -0
- package/dist/helpers/utils.d.ts +31 -0
- package/dist/index.d.ts +1 -0
- package/package.json +2 -1
package/LICENSE-3rdparty.csv
CHANGED
|
@@ -27,6 +27,7 @@ form-data,import,MIT,Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.co
|
|
|
27
27
|
glob,import,ISC,Copyright (c) Isaac Z. Schlueter and Contributors
|
|
28
28
|
jest,dev,MIT,Copyright (c) Facebook, Inc. and its affiliates.
|
|
29
29
|
jest-environment-node,dev,MIT,Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
+
jest-matcher-specific-error,dev,MIT,Copyright (c) 2020 Daniel Hreben
|
|
30
31
|
prettier,dev,MIT,Copyright © James Long and contributors
|
|
31
32
|
proxy,dev,MIT,Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
|
32
33
|
proxy-agent,import,MIT,Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { BaseContext } from 'clipanion/lib/advanced';
|
|
3
|
+
import { Writable } from 'stream';
|
|
4
|
+
interface WritableToString extends Writable {
|
|
5
|
+
toString(): string;
|
|
6
|
+
}
|
|
7
|
+
export interface MockContext extends BaseContext {
|
|
8
|
+
stderr: WritableToString;
|
|
9
|
+
stdout: WritableToString;
|
|
10
|
+
}
|
|
11
|
+
export declare const createMockContext: () => MockContext;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface RunUploadInput {
|
|
2
|
+
apiKey?: string;
|
|
3
|
+
appKey?: string;
|
|
4
|
+
dryRun?: boolean;
|
|
5
|
+
releaseVersion?: string;
|
|
6
|
+
service?: string;
|
|
7
|
+
source?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const runUploadCommand: (filePath: string, input: RunUploadInput) => Promise<{
|
|
10
|
+
context: import("./context").MockContext;
|
|
11
|
+
code: number;
|
|
12
|
+
}>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AxiosPromise, AxiosResponse } from 'axios';
|
|
2
|
+
export interface Payload {
|
|
3
|
+
dependenciesFilePath: string;
|
|
4
|
+
service: string;
|
|
5
|
+
source: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface APIHelper {
|
|
9
|
+
uploadDependencies(payload: Payload): AxiosPromise<AxiosResponse>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const renderSupportedValues: (supportedValues: string[]) => string;
|
|
2
|
+
export declare const renderMissingParameter: (parameter: string, supportedValues?: string[] | undefined) => string;
|
|
3
|
+
export declare const renderMissingEnvironmentVariable: (variable: string) => string;
|
|
4
|
+
export declare const renderUnsupportedParameterValue: (parameter: string, value: string, supportedValues: string[]) => string;
|
|
5
|
+
export declare const renderMissingReleaseVersionParameter: () => string;
|
|
6
|
+
export declare const renderCannotFindFile: (file: string) => string;
|
|
7
|
+
export declare const renderCommandInfo: (dependenciesFilePath: string, source: string, service: string, version: string | undefined, dryRun: boolean) => string;
|
|
8
|
+
export declare const renderDryRunUpload: () => string;
|
|
9
|
+
export declare const renderUpload: () => string;
|
|
10
|
+
export declare const renderRetriedUpload: (errorMessage: string, attempt: number) => string;
|
|
11
|
+
export declare const renderFailedUploadBecauseOf403: (errorMessage: string) => string;
|
|
12
|
+
export declare const renderFailedUpload: (errorMessage: string) => string;
|
|
13
|
+
export declare const renderSuccessfulCommand: (duration: number) => string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Command } from 'clipanion';
|
|
2
|
+
export declare class UploadCommand extends Command {
|
|
3
|
+
static SUPPORTED_SOURCES: string[];
|
|
4
|
+
static usage: import("clipanion/lib/advanced").Usage;
|
|
5
|
+
private static INVALID_INPUT_EXIT_CODE;
|
|
6
|
+
private static MISSING_FILE_EXIT_CODE;
|
|
7
|
+
private static UPLOAD_ERROR_EXIT_CODE;
|
|
8
|
+
private config;
|
|
9
|
+
private dependenciesFilePath;
|
|
10
|
+
private dryRun;
|
|
11
|
+
private releaseVersion?;
|
|
12
|
+
private service?;
|
|
13
|
+
private source?;
|
|
14
|
+
execute(): Promise<number | undefined>;
|
|
15
|
+
private uploadDependencies;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Dsym } from './interfaces';
|
|
2
|
+
import { UploadStatus } from '../../helpers/upload';
|
|
3
|
+
export declare const renderConfigurationError: (error: Error) => string;
|
|
4
|
+
export declare const renderInvalidDsymWarning: (path: string) => string;
|
|
5
|
+
export declare const renderFailedUpload: (dSYM: Dsym, errorMessage: string) => string;
|
|
6
|
+
export declare const renderRetriedUpload: (dSYM: Dsym, errorMessage: string, attempt: number) => string;
|
|
7
|
+
export declare const renderSuccessfulCommand: (statuses: UploadStatus[], duration: number, dryRun: boolean) => string;
|
|
8
|
+
export declare const renderCommandInfo: (basePath: string, poolLimit: number, dryRun: boolean) => string;
|
|
9
|
+
export declare const renderUpload: (dSYM: Dsym) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from 'clipanion';
|
|
2
|
+
export declare class UploadCommand extends Command {
|
|
3
|
+
static usage: import("clipanion/lib/advanced").Usage;
|
|
4
|
+
private basePath;
|
|
5
|
+
private config;
|
|
6
|
+
private dryRun;
|
|
7
|
+
private maxConcurrency;
|
|
8
|
+
execute(): Promise<1 | 0>;
|
|
9
|
+
private getRequestBuilder;
|
|
10
|
+
private uploadDSYM;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseContext } from 'clipanion';
|
|
2
|
+
import { Dsym } from './interfaces';
|
|
3
|
+
export declare const isZipFile: (filepath: string) => Promise<boolean>;
|
|
4
|
+
export declare const getMatchingDSYMFiles: (absoluteFolderPath: string, context: BaseContext) => Promise<(Dsym | undefined)[]>;
|
|
5
|
+
export declare const dwarfdumpUUID: (filePath: string) => Promise<string[]>;
|
|
6
|
+
export declare const zipToTmpDir: (sourcePath: string, targetFilename: string) => Promise<string>;
|
|
7
|
+
export declare const unzipToTmpDir: (sourcePath: string) => Promise<string>;
|
|
8
|
+
export declare const getBaseIntakeUrl: () => string;
|
|
9
|
+
export declare const pluralize: (nb: number, singular: string, plural: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -31,7 +31,7 @@ describe('execute', () => {
|
|
|
31
31
|
const cli = makeCli();
|
|
32
32
|
const context = createMockContext();
|
|
33
33
|
process.env = { DATADOG_API_KEY: 'PLACEHOLDER' };
|
|
34
|
-
const code = yield cli.run(['
|
|
34
|
+
const code = yield cli.run(['git-metadata', 'upload', '--dry-run'], context);
|
|
35
35
|
return { context, code };
|
|
36
36
|
});
|
|
37
37
|
test('runCLI', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as simpleGit from 'simple-git';
|
|
2
|
+
import { Writable } from 'stream';
|
|
3
|
+
import { CommitInfo } from './interfaces';
|
|
4
|
+
export declare const newSimpleGit: () => Promise<simpleGit.SimpleGit>;
|
|
5
|
+
export declare const gitRemote: (git: simpleGit.SimpleGit) => Promise<string>;
|
|
6
|
+
export declare const stripCredentials: (remote: string) => string;
|
|
7
|
+
export declare const gitTrackedFiles: (git: simpleGit.SimpleGit) => Promise<string[]>;
|
|
8
|
+
export declare const getCommitInfo: (git: simpleGit.SimpleGit, stdout: Writable, repositoryURL?: string | undefined) => Promise<CommitInfo | undefined>;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MultipartPayload } from '../../helpers/upload';
|
|
2
|
+
export declare class CommitInfo {
|
|
3
|
+
hash: string;
|
|
4
|
+
remote: string;
|
|
5
|
+
trackedFiles: string[];
|
|
6
|
+
constructor(hash: string, remote: string, trackedFiles: string[]);
|
|
7
|
+
asMultipartPayload(cliVersion: string): MultipartPayload;
|
|
8
|
+
private repositoryPayload;
|
|
9
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CommitInfo } from './interfaces';
|
|
2
|
+
export declare const renderGitError: (errorMessage: string) => string;
|
|
3
|
+
export declare const renderConfigurationError: (error: Error) => string;
|
|
4
|
+
export declare const renderFailedUpload: (errorMessage: string) => string;
|
|
5
|
+
export declare const renderRetriedUpload: (errorMessage: string, attempt: number) => string;
|
|
6
|
+
export declare const renderSuccessfulCommand: (duration: number, dryRun: boolean) => string;
|
|
7
|
+
export declare const renderDryRunWarning: () => string;
|
|
8
|
+
export declare const renderCommandInfo: (commit: CommitInfo) => string;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.renderCommandInfo = exports.
|
|
6
|
+
exports.renderCommandInfo = exports.renderDryRunWarning = exports.renderSuccessfulCommand = exports.renderRetriedUpload = exports.renderFailedUpload = exports.renderConfigurationError = exports.renderGitError = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const formatting_1 = require("../../helpers/formatting");
|
|
9
9
|
const renderGitError = (errorMessage) => chalk_1.default.red(`${formatting_1.ICONS.FAILED} An error occured while invoking git: ${errorMessage}
|
|
@@ -15,7 +15,6 @@ const renderFailedUpload = (errorMessage) => chalk_1.default.red(`${formatting_1
|
|
|
15
15
|
exports.renderFailedUpload = renderFailedUpload;
|
|
16
16
|
const renderRetriedUpload = (errorMessage, attempt) => chalk_1.default.yellow(`[attempt ${attempt}] Retrying upload: ${errorMessage}\n`);
|
|
17
17
|
exports.renderRetriedUpload = renderRetriedUpload;
|
|
18
|
-
exports.renderUpload = 'Uploading\n';
|
|
19
18
|
const renderSuccessfulCommand = (duration, dryRun) => {
|
|
20
19
|
if (dryRun) {
|
|
21
20
|
return chalk_1.default.green(`${formatting_1.ICONS.SUCCESS} [DRYRUN] Handled in ${duration} seconds.\n`);
|
|
@@ -25,10 +24,8 @@ const renderSuccessfulCommand = (duration, dryRun) => {
|
|
|
25
24
|
}
|
|
26
25
|
};
|
|
27
26
|
exports.renderSuccessfulCommand = renderSuccessfulCommand;
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return chalk_1.default.green('Starting upload. \n');
|
|
33
|
-
};
|
|
27
|
+
const renderDryRunWarning = () => chalk_1.default.yellow(`${formatting_1.ICONS.WARNING} DRY-RUN MODE ENABLED. WILL NOT UPLOAD\n`);
|
|
28
|
+
exports.renderDryRunWarning = renderDryRunWarning;
|
|
29
|
+
const renderCommandInfo = (commit) => `Reporting commit ${commit.hash} from repository ${commit.remote}.
|
|
30
|
+
${commit.trackedFiles.length} tracked file paths will be reported.\n`;
|
|
34
31
|
exports.renderCommandInfo = renderCommandInfo;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from 'clipanion';
|
|
2
|
+
export declare class UploadCommand extends Command {
|
|
3
|
+
static usage: import("clipanion/lib/advanced").Usage;
|
|
4
|
+
repositoryURL?: string;
|
|
5
|
+
private cliVersion;
|
|
6
|
+
private config;
|
|
7
|
+
private dryRun;
|
|
8
|
+
constructor();
|
|
9
|
+
execute(): Promise<1 | 0>;
|
|
10
|
+
private getRequestBuilder;
|
|
11
|
+
private uploadRepository;
|
|
12
|
+
}
|
|
@@ -36,7 +36,9 @@ class UploadCommand extends clipanion_1.Command {
|
|
|
36
36
|
execute() {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
38
|
const initialTime = new Date().getTime();
|
|
39
|
-
|
|
39
|
+
if (this.dryRun) {
|
|
40
|
+
this.context.stdout.write(renderer_1.renderDryRunWarning());
|
|
41
|
+
}
|
|
40
42
|
const metricsLogger = metrics_1.getMetricsLogger({
|
|
41
43
|
datadogSite: process.env.DATADOG_SITE,
|
|
42
44
|
defaultTags: [`cli_version:${this.cliVersion}`],
|
|
@@ -51,6 +53,7 @@ class UploadCommand extends clipanion_1.Command {
|
|
|
51
53
|
if (payload === undefined) {
|
|
52
54
|
return 0;
|
|
53
55
|
}
|
|
56
|
+
this.context.stdout.write(renderer_1.renderCommandInfo(payload));
|
|
54
57
|
try {
|
|
55
58
|
const requestBuilder = this.getRequestBuilder();
|
|
56
59
|
const status = yield this.uploadRepository(requestBuilder)(payload, {
|
|
@@ -63,7 +66,9 @@ class UploadCommand extends clipanion_1.Command {
|
|
|
63
66
|
this.context.stdout.write(renderer_1.renderRetriedUpload(e.message, attempt));
|
|
64
67
|
metricsLogger.logger.increment('retries', 1);
|
|
65
68
|
},
|
|
66
|
-
onUpload: () =>
|
|
69
|
+
onUpload: () => {
|
|
70
|
+
return;
|
|
71
|
+
},
|
|
67
72
|
retries: 5,
|
|
68
73
|
});
|
|
69
74
|
metricsLogger.logger.increment('success', 1);
|
|
@@ -122,6 +127,6 @@ UploadCommand.usage = clipanion_1.Command.Usage({
|
|
|
122
127
|
`,
|
|
123
128
|
examples: [['Upload the current commit details', 'datadog-ci report-commits upload']],
|
|
124
129
|
});
|
|
125
|
-
UploadCommand.addPath('
|
|
130
|
+
UploadCommand.addPath('git-metadata', 'upload');
|
|
126
131
|
UploadCommand.addOption('dryRun', clipanion_1.Command.Boolean('--dry-run'));
|
|
127
132
|
UploadCommand.addOption('repositoryURL', clipanion_1.Command.String('--repository-url'));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AxiosPromise, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
+
import { Writable } from 'stream';
|
|
3
|
+
import { Payload } from './interfaces';
|
|
4
|
+
export declare const getSafeFileName: (unsafeFileName: string) => string;
|
|
5
|
+
export declare const uploadJUnitXML: (request: (args: AxiosRequestConfig) => AxiosPromise<AxiosResponse>) => (jUnitXML: Payload, write: Writable['write']) => Promise<AxiosResponse<AxiosResponse<any>>>;
|
|
6
|
+
export declare const apiConstructor: (baseIntakeUrl: string, apiKey: string) => {
|
|
7
|
+
uploadJUnitXML: (jUnitXML: Payload, write: Writable['write']) => Promise<AxiosResponse<AxiosResponse<any>>>;
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AxiosPromise, AxiosResponse } from 'axios';
|
|
3
|
+
import { Writable } from 'stream';
|
|
4
|
+
import { SpanTags } from '../../helpers/interfaces';
|
|
5
|
+
export interface Payload {
|
|
6
|
+
service: string;
|
|
7
|
+
spanTags: SpanTags;
|
|
8
|
+
xmlPath: string;
|
|
9
|
+
}
|
|
10
|
+
export interface APIHelper {
|
|
11
|
+
uploadJUnitXML(jUnitXML: Payload, write: Writable['write']): AxiosPromise<AxiosResponse>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Payload } from './interfaces';
|
|
2
|
+
export declare const renderInvalidFile: (xmlPath: string, errorMessage: string) => string;
|
|
3
|
+
export declare const renderFailedUpload: (payload: Payload, errorMessage: string) => string;
|
|
4
|
+
export declare const renderRetriedUpload: (payload: Payload, errorMessage: string, attempt: number) => string;
|
|
5
|
+
export declare const renderSuccessfulCommand: (fileCount: number, duration: number) => string;
|
|
6
|
+
export declare const renderDryRunUpload: (payload: Payload) => string;
|
|
7
|
+
export declare const renderUpload: (payload: Payload) => string;
|
|
8
|
+
export declare const renderCommandInfo: (basePaths: string[], service: string, concurrency: number, dryRun: boolean) => string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Command } from 'clipanion';
|
|
2
|
+
export declare class UploadJUnitXMLCommand extends Command {
|
|
3
|
+
static usage: import("clipanion/lib/advanced").Usage;
|
|
4
|
+
private basePaths?;
|
|
5
|
+
private config;
|
|
6
|
+
private dryRun;
|
|
7
|
+
private env?;
|
|
8
|
+
private maxConcurrency;
|
|
9
|
+
private service?;
|
|
10
|
+
private tags?;
|
|
11
|
+
execute(): Promise<1 | undefined>;
|
|
12
|
+
private getApiHelper;
|
|
13
|
+
private getMatchingJUnitXMLFiles;
|
|
14
|
+
private uploadJUnitXML;
|
|
15
|
+
}
|
|
@@ -13,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.UploadJUnitXMLCommand = void 0;
|
|
16
|
-
const async_retry_1 = __importDefault(require("async-retry"));
|
|
17
16
|
const chalk_1 = __importDefault(require("chalk"));
|
|
18
17
|
const clipanion_1 = require("clipanion");
|
|
19
18
|
const fast_xml_parser_1 = __importDefault(require("fast-xml-parser"));
|
|
@@ -26,10 +25,10 @@ const renderer_1 = require("./renderer");
|
|
|
26
25
|
const utils_1 = require("./utils");
|
|
27
26
|
const ci_1 = require("../../helpers/ci");
|
|
28
27
|
const git_1 = require("../../helpers/git");
|
|
28
|
+
const retry_1 = require("../../helpers/retry");
|
|
29
29
|
const tags_1 = require("../../helpers/tags");
|
|
30
30
|
const user_provided_git_1 = require("../../helpers/user-provided-git");
|
|
31
31
|
const utils_2 = require("../../helpers/utils");
|
|
32
|
-
const errorCodesNoRetry = [400, 403, 413];
|
|
33
32
|
const errorCodesStopUpload = [400, 403];
|
|
34
33
|
const validateXml = (xmlFilePath) => {
|
|
35
34
|
const xmlFileContentString = String(fs_1.default.readFileSync(xmlFilePath));
|
|
@@ -122,36 +121,20 @@ class UploadJUnitXMLCommand extends clipanion_1.Command {
|
|
|
122
121
|
}
|
|
123
122
|
uploadJUnitXML(api, jUnitXML) {
|
|
124
123
|
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
if (this.dryRun) {
|
|
125
|
+
this.context.stdout.write(renderer_1.renderDryRunUpload(jUnitXML));
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
125
128
|
try {
|
|
126
|
-
yield
|
|
127
|
-
try {
|
|
128
|
-
if (this.dryRun) {
|
|
129
|
-
this.context.stdout.write(renderer_1.renderDryRunUpload(jUnitXML));
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
yield api.uploadJUnitXML(jUnitXML, this.context.stdout.write.bind(this.context.stdout));
|
|
133
|
-
}
|
|
134
|
-
catch (error) {
|
|
135
|
-
if (error.response) {
|
|
136
|
-
// If it's an axios error
|
|
137
|
-
if (!errorCodesNoRetry.includes(error.response.status)) {
|
|
138
|
-
// And a status code that is not excluded from retries, throw the error so that upload is retried
|
|
139
|
-
throw error;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
// If it's another error or an axios error we don't want to retry, bail
|
|
143
|
-
bail(error);
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
}), {
|
|
129
|
+
yield retry_1.retryRequest(() => api.uploadJUnitXML(jUnitXML, this.context.stdout.write.bind(this.context.stdout)), {
|
|
147
130
|
onRetry: (e, attempt) => {
|
|
148
|
-
this.context.
|
|
131
|
+
this.context.stderr.write(renderer_1.renderRetriedUpload(jUnitXML, e.message, attempt));
|
|
149
132
|
},
|
|
150
133
|
retries: 5,
|
|
151
134
|
});
|
|
152
135
|
}
|
|
153
136
|
catch (error) {
|
|
154
|
-
this.context.
|
|
137
|
+
this.context.stderr.write(renderer_1.renderFailedUpload(jUnitXML, error));
|
|
155
138
|
if (error.response) {
|
|
156
139
|
// If it's an axios error
|
|
157
140
|
if (!errorCodesStopUpload.includes(error.response.status)) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getBaseIntakeUrl: () => string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import { CloudWatchLogs, Lambda } from 'aws-sdk';
|
|
3
|
+
import { Cli, Command } from 'clipanion/lib/advanced';
|
|
4
|
+
export declare const createMockContext: () => {
|
|
5
|
+
stdout: {
|
|
6
|
+
toString: () => string;
|
|
7
|
+
write: (input: string) => void;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare const makeCli: () => Cli<import("clipanion/lib/advanced").BaseContext>;
|
|
11
|
+
/**
|
|
12
|
+
* Allow for constructors with any amount of parameters.
|
|
13
|
+
* Mainly used for testing when we are creating commands.
|
|
14
|
+
*/
|
|
15
|
+
export declare type ConstructorOf<T> = new (...args: any[]) => T;
|
|
16
|
+
/**
|
|
17
|
+
* Allows to create an instance of any command that
|
|
18
|
+
* extends the Command clss.
|
|
19
|
+
*
|
|
20
|
+
* @param commandClass any class that extends the Command class.
|
|
21
|
+
* @param parameters parameters to use while creating the commandClass
|
|
22
|
+
* @returns the instance of the given command with a mock context attatched.
|
|
23
|
+
*/
|
|
24
|
+
export declare const createCommand: <T extends Command<import("clipanion/lib/advanced").BaseContext>>(commandClass: ConstructorOf<T>, ...parameters: any[]) => T;
|
|
25
|
+
export declare const makeMockLambda: (functionConfigs: Record<string, Lambda.FunctionConfiguration>) => {
|
|
26
|
+
getFunction: jest.Mock<any, any>;
|
|
27
|
+
listFunctions: jest.Mock<any, any>;
|
|
28
|
+
listTags: jest.Mock<any, any>;
|
|
29
|
+
tagResource: jest.Mock<any, any>;
|
|
30
|
+
updateFunctionConfiguration: jest.Mock<any, any>;
|
|
31
|
+
};
|
|
32
|
+
export declare const makeMockCloudWatchLogs: (logGroups: Record<string, {
|
|
33
|
+
config: CloudWatchLogs.DescribeLogGroupsResponse;
|
|
34
|
+
filters?: CloudWatchLogs.DescribeSubscriptionFiltersResponse;
|
|
35
|
+
}>) => {
|
|
36
|
+
createLogGroup: jest.Mock<any, any>;
|
|
37
|
+
deleteSubscriptionFilter: jest.Mock<any, any>;
|
|
38
|
+
describeLogGroups: jest.Mock<any, any>;
|
|
39
|
+
describeSubscriptionFilters: jest.Mock<any, any>;
|
|
40
|
+
putSubscriptionFilter: jest.Mock<any, any>;
|
|
41
|
+
};
|
|
42
|
+
export declare const mockAwsAccount = "123456789012";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mockAwsAccount = exports.makeMockCloudWatchLogs = exports.makeMockLambda = exports.createCommand = exports.makeCli = exports.createMockContext = void 0;
|
|
4
|
+
const advanced_1 = require("clipanion/lib/advanced");
|
|
5
|
+
const instrument_1 = require("../instrument");
|
|
6
|
+
const uninstrument_1 = require("../uninstrument");
|
|
7
|
+
const createMockContext = () => {
|
|
8
|
+
let data = '';
|
|
9
|
+
return {
|
|
10
|
+
stdout: {
|
|
11
|
+
toString: () => data,
|
|
12
|
+
write: (input) => {
|
|
13
|
+
data += input;
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
exports.createMockContext = createMockContext;
|
|
19
|
+
const makeCli = () => {
|
|
20
|
+
const cli = new advanced_1.Cli();
|
|
21
|
+
cli.register(instrument_1.InstrumentCommand);
|
|
22
|
+
cli.register(uninstrument_1.UninstrumentCommand);
|
|
23
|
+
return cli;
|
|
24
|
+
};
|
|
25
|
+
exports.makeCli = makeCli;
|
|
26
|
+
/**
|
|
27
|
+
* Allows to create an instance of any command that
|
|
28
|
+
* extends the Command clss.
|
|
29
|
+
*
|
|
30
|
+
* @param commandClass any class that extends the Command class.
|
|
31
|
+
* @param parameters parameters to use while creating the commandClass
|
|
32
|
+
* @returns the instance of the given command with a mock context attatched.
|
|
33
|
+
*/
|
|
34
|
+
const createCommand = (commandClass, ...parameters) => {
|
|
35
|
+
// Create a new instance of commandClass and pass in the parameters
|
|
36
|
+
const command = new commandClass(...parameters);
|
|
37
|
+
command.context = exports.createMockContext();
|
|
38
|
+
return command;
|
|
39
|
+
};
|
|
40
|
+
exports.createCommand = createCommand;
|
|
41
|
+
const makeMockLambda = (functionConfigs) => ({
|
|
42
|
+
getFunction: jest.fn().mockImplementation(({ FunctionName }) => ({
|
|
43
|
+
promise: () => Promise.resolve({ Configuration: functionConfigs[FunctionName] }),
|
|
44
|
+
})),
|
|
45
|
+
listFunctions: jest.fn().mockImplementation(() => ({
|
|
46
|
+
promise: () => Promise.resolve({ Functions: Object.values(functionConfigs) }),
|
|
47
|
+
})),
|
|
48
|
+
listTags: jest.fn().mockImplementation(() => ({ promise: () => Promise.resolve({ Tags: {} }) })),
|
|
49
|
+
tagResource: jest.fn().mockImplementation(() => ({ promise: () => Promise.resolve() })),
|
|
50
|
+
updateFunctionConfiguration: jest.fn().mockImplementation(() => ({ promise: () => Promise.resolve() })),
|
|
51
|
+
});
|
|
52
|
+
exports.makeMockLambda = makeMockLambda;
|
|
53
|
+
const makeMockCloudWatchLogs = (logGroups) => ({
|
|
54
|
+
createLogGroup: jest.fn().mockImplementation(() => ({ promise: () => Promise.resolve() })),
|
|
55
|
+
deleteSubscriptionFilter: jest.fn().mockImplementation(() => ({ promise: () => Promise.resolve() })),
|
|
56
|
+
describeLogGroups: jest.fn().mockImplementation(({ logGroupNamePrefix }) => {
|
|
57
|
+
var _a, _b;
|
|
58
|
+
const groups = (_b = (_a = logGroups[logGroupNamePrefix]) === null || _a === void 0 ? void 0 : _a.config) !== null && _b !== void 0 ? _b : { logGroups: [] };
|
|
59
|
+
return {
|
|
60
|
+
promise: () => Promise.resolve(groups),
|
|
61
|
+
};
|
|
62
|
+
}),
|
|
63
|
+
describeSubscriptionFilters: jest.fn().mockImplementation(({ logGroupName }) => {
|
|
64
|
+
var _a, _b;
|
|
65
|
+
const groups = (_b = (_a = logGroups[logGroupName]) === null || _a === void 0 ? void 0 : _a.filters) !== null && _b !== void 0 ? _b : { subscriptionFilters: [] };
|
|
66
|
+
return {
|
|
67
|
+
promise: () => Promise.resolve(groups),
|
|
68
|
+
};
|
|
69
|
+
}),
|
|
70
|
+
putSubscriptionFilter: jest.fn().mockImplementation(() => ({ promise: () => Promise.resolve() })),
|
|
71
|
+
});
|
|
72
|
+
exports.makeMockCloudWatchLogs = makeMockCloudWatchLogs;
|
|
73
|
+
exports.mockAwsAccount = '123456789012';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|