Skip to content

Commit c861e2d

Browse files
authored
Merge branch 'master' into no-envars
2 parents 46b5e06 + 1a2b245 commit c861e2d

26 files changed

+236
-81
lines changed

bin/cml.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,7 @@ const yargs = require('yargs');
1010
const CML = require('../src/cml').default;
1111
const { jitsuEventPayload, send } = require('../src/analytics');
1212

13-
const setupOpts = (opts) => {
14-
const legacyEnvironmentVariables = {
15-
TB_CREDENTIALS: 'CML_TENSORBOARD_DEV_CREDENTIALS',
16-
DOCKER_MACHINE: 'CML_RUNNER_DOCKER_MACHINE',
17-
RUNNER_IDLE_TIMEOUT: 'CML_RUNNER_IDLE_TIMEOUT',
18-
RUNNER_LABELS: 'CML_RUNNER_LABELS',
19-
RUNNER_SINGLE: 'CML_RUNNER_SINGLE',
20-
RUNNER_REUSE: 'CML_RUNNER_REUSE',
21-
RUNNER_NO_RETRY: 'CML_RUNNER_NO_RETRY',
22-
RUNNER_DRIVER: 'CML_RUNNER_DRIVER',
23-
RUNNER_REPO: 'CML_RUNNER_REPO',
24-
RUNNER_PATH: 'CML_RUNNER_PATH'
25-
};
26-
27-
for (const [oldName, newName] of Object.entries(legacyEnvironmentVariables)) {
28-
if (process.env[oldName]) process.env[newName] = process.env[oldName];
29-
}
30-
13+
const aliasLegacyEnvironmentVariables = () => {
3114
const legacyEnvironmentPrefixes = {
3215
CML_CI: 'CML_REPO',
3316
CML_PUBLISH: 'CML_ASSET',
@@ -46,6 +29,25 @@ const setupOpts = (opts) => {
4629
}
4730
}
4831

32+
const legacyEnvironmentVariables = {
33+
TB_CREDENTIALS: 'CML_TENSORBOARD_CREDENTIALS',
34+
DOCKER_MACHINE: 'CML_RUNNER_DOCKER_MACHINE',
35+
RUNNER_IDLE_TIMEOUT: 'CML_RUNNER_IDLE_TIMEOUT',
36+
RUNNER_LABELS: 'CML_RUNNER_LABELS',
37+
RUNNER_SINGLE: 'CML_RUNNER_SINGLE',
38+
RUNNER_REUSE: 'CML_RUNNER_REUSE',
39+
RUNNER_NO_RETRY: 'CML_RUNNER_NO_RETRY',
40+
RUNNER_DRIVER: 'CML_RUNNER_DRIVER',
41+
RUNNER_REPO: 'CML_RUNNER_REPO',
42+
RUNNER_PATH: 'CML_RUNNER_PATH'
43+
};
44+
45+
for (const [oldName, newName] of Object.entries(legacyEnvironmentVariables)) {
46+
if (process.env[oldName]) process.env[newName] = process.env[oldName];
47+
}
48+
};
49+
50+
const setupOpts = (opts) => {
4951
const { markdownfile } = opts;
5052
opts.markdownFile = markdownfile;
5153
opts.cml = new CML(opts);
@@ -117,6 +119,7 @@ const handleError = (message, error) => {
117119
};
118120

119121
(async () => {
122+
aliasLegacyEnvironmentVariables();
120123
setupLogger({ log: 'debug' });
121124

122125
try {

bin/cml.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const { exec } = require('../src/utils');
2+
const fetch = require('node-fetch');
23

34
describe('command-line interface tests', () => {
45
test('cml --help', async () => {
@@ -31,3 +32,21 @@ describe('command-line interface tests', () => {
3132
`);
3233
});
3334
});
35+
36+
describe('Valid Docs URLs', () => {
37+
test.each([
38+
'workflow/rerun',
39+
'tensorboard/connect',
40+
'runner/launch',
41+
'repo/prepare',
42+
'pr/create',
43+
'comment/create',
44+
'comment/update',
45+
'check/create',
46+
'asset/publish'
47+
])('Check Docs Link', async (cmd) => {
48+
const { DOCSURL } = require(`./cml/${cmd}`);
49+
const { status } = await fetch(DOCSURL);
50+
expect(status).toBe(200);
51+
});
52+
});

bin/cml/asset/publish.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ const winston = require('winston');
44

55
const { CML } = require('../../../src/cml');
66

7+
const DESCRIPTION = 'Publish an asset';
8+
const DOCSURL = 'https://cml.dev/doc/usage#cml-reports';
9+
710
exports.command = 'publish <asset>';
8-
exports.description = 'Publish an asset';
11+
exports.description = `${DESCRIPTION}\n${DOCSURL}`;
912

1013
exports.handler = async (opts) => {
1114
if (opts.gitlabUploads) {
@@ -56,6 +59,7 @@ exports.options = kebabcaseKeys({
5659
rmWatermark: {
5760
type: 'boolean',
5861
description: 'Avoid CML watermark.',
62+
hidden: true,
5963
telemetryData: 'name'
6064
},
6165
mimeType: {
@@ -76,3 +80,4 @@ exports.options = kebabcaseKeys({
7680
'Specifies the repo to be used. If not specified is extracted from the CI ENV.'
7781
}
7882
});
83+
exports.DOCSURL = DOCSURL;

bin/cml/asset/publish.test.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ describe('CML cli test', () => {
2020
--help Show help [boolean]
2121
2222
Options:
23-
--md Output in markdown format [title || name](url) [boolean]
24-
-t, --title Markdown title [title](url) or ![](url title) [string]
25-
--native Uses driver's native capabilities to upload assets instead
26-
of CML's storage; not available on GitHub [boolean]
27-
--rm-watermark Avoid CML watermark. [boolean]
28-
--mime-type MIME type [string] [default: infer from the file contents]"
23+
--md Output in markdown format [title || name](url) [boolean]
24+
-t, --title Markdown title [title](url) or ![](url title) [string]
25+
--native Uses driver's native capabilities to upload assets instead of
26+
CML's storage; not available on GitHub [boolean]
27+
--mime-type MIME type [string] [default: infer from the file contents]"
2928
`);
3029
});
3130
});

bin/cml/check/create.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
const fs = require('fs').promises;
22
const kebabcaseKeys = require('kebabcase-keys');
33

4+
const DESCRIPTION = 'Create a check report';
5+
const DOCSURL = 'https://cml.dev/doc/ref/check';
6+
47
exports.command = 'create <markdown file>';
5-
exports.description = 'Create a check report';
8+
exports.description = `${DESCRIPTION}\n${DOCSURL}`;
69

710
exports.handler = async (opts) => {
811
const { cml, markdownfile } = opts;
@@ -53,3 +56,4 @@ exports.options = kebabcaseKeys({
5356
description: 'Title of the check'
5457
}
5558
});
59+
exports.DOCSURL = DOCSURL;

bin/cml/comment/create.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
const kebabcaseKeys = require('kebabcase-keys');
22

3+
const DESCRIPTION = 'Create a comment';
4+
const DOCSURL = 'https://cml.dev/doc/ref/comment#create';
5+
36
exports.command = 'create <markdown file>';
4-
exports.description = 'Create a comment';
7+
exports.description = `${DESCRIPTION}\n${DOCSURL}`;
58

69
exports.handler = async (opts) => {
710
const { cml } = opts;
@@ -63,6 +66,15 @@ exports.options = kebabcaseKeys({
6366
type: 'boolean',
6467
description:
6568
'Avoid watermark; CML needs a watermark to be able to distinguish CML comments from others',
69+
hidden: true,
6670
telemetryData: 'name'
71+
},
72+
watermarkTitle: {
73+
type: 'string',
74+
description:
75+
'Hidden comment marker (used for targeting in subsequent `cml comment update`); "{workflow}" & "{run}" are auto-replaced',
76+
default: '',
77+
conflicts: ['rmWatermark']
6778
}
6879
});
80+
exports.DOCSURL = DOCSURL;

bin/cml/comment/create.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const { exec } = require('../../../src/utils');
33
describe('Comment integration tests', () => {
44
test('cml send-comment --help', async () => {
55
const output = await exec(`node ./bin/cml.js send-comment --help`);
6-
76
expect(output).toMatchInlineSnapshot(`
87
"cml.js send-comment <markdown file>
98
@@ -31,8 +30,9 @@ describe('Comment integration tests', () => {
3130
--publish-native, --native Uses driver's native capabilities to upload assets
3231
instead of CML's storage; not available on GitHub
3332
[boolean]
34-
--rm-watermark Avoid watermark; CML needs a watermark to be able
35-
to distinguish CML comments from others [boolean]"
33+
--watermark-title Hidden comment marker (used for targeting in
34+
subsequent \`cml comment update\`); \\"{workflow}\\" &
35+
\\"{run}\\" are auto-replaced [string] [default: \\"\\"]"
3636
`);
3737
});
3838
});

bin/cml/comment/update.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
const { builder, handler } = require('./create');
22

3+
const DESCRIPTION = 'Update a comment';
4+
const DOCSURL = 'https://cml.dev/doc/ref/comment#update';
5+
36
exports.command = 'update <markdown file>';
4-
exports.description = 'Update a comment';
7+
exports.description = `${DESCRIPTION}\n${DOCSURL}`;
58

69
exports.handler = async (opts) => {
710
await handler({ ...opts, update: true });
811
};
912

1013
exports.builder = builder;
14+
exports.DOCSURL = DOCSURL;

bin/cml/pr/create.e2e.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ describe('CML e2e', () => {
1212
Commands:
1313
cml.js pr create <glob path...> Create a pull request with the specified
1414
files
15+
https://cml.dev/doc/ref/pr
1516
1617
Global Options:
1718
--log Logging verbosity

bin/cml/pr/create.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ const {
66
GIT_USER_EMAIL
77
} = require('../../../src/cml');
88

9+
const DESCRIPTION = 'Create a pull request with the specified files';
10+
const DOCSURL = 'https://cml.dev/doc/ref/pr';
11+
912
exports.command = 'create <glob path...>';
10-
exports.description = 'Create a pull request with the specified files';
13+
exports.description = `${DESCRIPTION}\n${DOCSURL}`;
1114

1215
exports.handler = async (opts) => {
1316
const { cml, globpath: globs } = opts;
@@ -78,3 +81,4 @@ exports.options = kebabcaseKeys({
7881
description: 'Git user name'
7982
}
8083
});
84+
exports.DOCSURL = DOCSURL;

0 commit comments

Comments
 (0)