Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide Docs URLs in --help messaging #1232

Merged
merged 4 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions bin/cml.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { exec } = require('../src/utils');
const fetch = require('node-fetch');

describe('command-line interface tests', () => {
test('cml --help', async () => {
Expand Down Expand Up @@ -31,3 +32,21 @@ describe('command-line interface tests', () => {
`);
});
});

describe('Valid Docs URLs', () => {
test.each([
'workflow/rerun',
'tensorboard/connect',
'runner/launch',
'repo/prepare',
'pr/create',
'comment/create',
'comment/update',
'check/create',
'asset/publish'
Comment on lines +38 to +46
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'workflow/rerun',
'tensorboard/connect',
'runner/launch',
'repo/prepare',
'pr/create',
'comment/create',
'comment/update',
'check/create',
'asset/publish'
'workflow:rerun',
'tensorboard:connect',
'runner:launch',
'repo:prepare',
'pr:create',
'comment:create',
'comment:update',
'check:create',
'asset:publish'

For consistency with analytics?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's only used to import the file, we could but it would and more code in the test :/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, nevermind

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

going to be hard to keep this list updated as (sub)commands new are added.

])('Check Docs Links', async (cmd) => {
dacbd marked this conversation as resolved.
Show resolved Hide resolved
const { DOCSURL } = require(`./cml/${cmd}`);
const { status } = await fetch(DOCSURL);
expect(status).toBe(200);
});
});
6 changes: 5 additions & 1 deletion bin/cml/asset/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ const winston = require('winston');

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

const DESCRIPTION = 'Publish an asset';
const DOCSURL = 'https://cml.dev/doc/usage#cml-reports';

exports.command = 'publish <asset>';
exports.description = 'Publish an asset';
exports.description = `${DESCRIPTION}\n${DOCSURL}`;

exports.handler = async (opts) => {
if (opts.gitlabUploads) {
Expand Down Expand Up @@ -76,3 +79,4 @@ exports.options = kebabcaseKeys({
'Specifies the repo to be used. If not specified is extracted from the CI ENV.'
}
});
exports.DOCSURL = DOCSURL;
6 changes: 5 additions & 1 deletion bin/cml/check/create.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const fs = require('fs').promises;
const kebabcaseKeys = require('kebabcase-keys');

const DESCRIPTION = 'Create a check report';
const DOCSURL = 'https://cml.dev/doc/ref/check';

exports.command = 'create <markdown file>';
exports.description = 'Create a check report';
exports.description = `${DESCRIPTION}\n${DOCSURL}`;

exports.handler = async (opts) => {
const { cml, markdownfile } = opts;
Expand Down Expand Up @@ -53,3 +56,4 @@ exports.options = kebabcaseKeys({
description: 'Title of the check'
}
});
exports.DOCSURL = DOCSURL;
6 changes: 5 additions & 1 deletion bin/cml/comment/create.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const kebabcaseKeys = require('kebabcase-keys');

const DESCRIPTION = 'Create a comment';
const DOCSURL = 'https://cml.dev/doc/ref/comment#create';

exports.command = 'create <markdown file>';
exports.description = 'Create a comment';
exports.description = `${DESCRIPTION}\n${DOCSURL}`;

exports.handler = async (opts) => {
const { cml } = opts;
Expand Down Expand Up @@ -66,3 +69,4 @@ exports.options = kebabcaseKeys({
telemetryData: 'name'
}
});
exports.DOCSURL = DOCSURL;
6 changes: 5 additions & 1 deletion bin/cml/comment/update.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
const { builder, handler } = require('./create');

const DESCRIPTION = 'Update a comment';
const DOCSURL = 'https://cml.dev/doc/ref/comment#update';

exports.command = 'update <markdown file>';
exports.description = 'Update a comment';
exports.description = `${DESCRIPTION}\n${DOCSURL}`;

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

exports.builder = builder;
exports.DOCSURL = DOCSURL;
1 change: 1 addition & 0 deletions bin/cml/pr/create.e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('CML e2e', () => {
Commands:
cml.js pr create <glob path...> Create a pull request with the specified
files
https://cml.dev/doc/ref/pr

Global Options:
--log Logging verbosity
Expand Down
6 changes: 5 additions & 1 deletion bin/cml/pr/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ const {
GIT_USER_EMAIL
} = require('../../../src/cml');

const DESCRIPTION = 'Create a pull request with the specified files';
const DOCSURL = 'https://cml.dev/doc/ref/pr';

exports.command = 'create <glob path...>';
exports.description = 'Create a pull request with the specified files';
exports.description = `${DESCRIPTION}\n${DOCSURL}`;

exports.handler = async (opts) => {
const { cml, globpath: globs } = opts;
Expand Down Expand Up @@ -78,3 +81,4 @@ exports.options = kebabcaseKeys({
description: 'Git user name'
}
});
exports.DOCSURL = DOCSURL;
6 changes: 5 additions & 1 deletion bin/cml/repo/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ const kebabcaseKeys = require('kebabcase-keys');

const { GIT_USER_NAME, GIT_USER_EMAIL } = require('../../../src/cml');

const DESCRIPTION = 'Prepare the cloned repository';
const DOCSURL = 'https://cml.dev/doc/ref/ci';

exports.command = 'prepare';
exports.description = 'Prepare the cloned repository';
exports.description = `${DESCRIPTION}\n${DOCSURL}`;

exports.handler = async (opts) => {
const { cml } = opts;
Expand Down Expand Up @@ -33,3 +36,4 @@ exports.options = kebabcaseKeys({
description: 'Git user name'
}
});
exports.DOCSURL = DOCSURL;
6 changes: 5 additions & 1 deletion bin/cml/runner/launch.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,11 @@ const run = async (opts) => {
else await runLocal(opts);
};

const DESCRIPTION = 'Launch and register a self-hosted runner';
const DOCSURL = 'https://cml.dev/doc/ref/runner';

exports.command = 'launch';
exports.description = 'Launch and register a self-hosted runner';
exports.description = `${DESCRIPTION}\n${DOCSURL}`;

exports.handler = async (opts) => {
({ cml } = opts);
Expand Down Expand Up @@ -579,3 +582,4 @@ exports.options = kebabcaseKeys({
'Seconds to wait for collecting logs on failure (https://github.com/iterative/cml/issues/413)'
}
});
exports.DOCSURL = DOCSURL;
1 change: 1 addition & 0 deletions bin/cml/runner/launch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('CML e2e', () => {

Commands:
cml.js runner launch Launch and register a self-hosted runner
https://cml.dev/doc/ref/runner

Global Options:
--log Logging verbosity
Expand Down
7 changes: 6 additions & 1 deletion bin/cml/tensorboard/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@ const launchAndWaitLink = async (opts = {}) => {
};

exports.tbLink = tbLink;

const DESCRIPTION = 'Connect to tensorboard.dev and get a link';
const DOCSURL = 'https://cml.dev/doc/ref/tensorboard';

exports.command = 'connect';
exports.description = 'Connect to tensorboard.dev and get a link';
exports.description = `${DESCRIPTION}\n${DOCSURL}`;

exports.handler = async (opts) => {
const { file, credentials, name, description } = opts;
Expand Down Expand Up @@ -144,3 +148,4 @@ exports.options = kebabcaseKeys({
telemetryData: 'name'
}
});
exports.DOCSURL = DOCSURL;
7 changes: 6 additions & 1 deletion bin/cml/workflow/rerun.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const kebabcaseKeys = require('kebabcase-keys');

const DESCRIPTION = 'Rerun a workflow given the jobId or workflowId';
const DOCSURL = 'https://cml.dev/doc/ref/workflow';

exports.command = 'rerun';
exports.description = 'Rerun a workflow given the jobId or workflowId';
exports.description = `${DESCRIPTION}\n${DOCSURL}`;

exports.handler = async (opts) => {
const { cml } = opts;
Expand All @@ -20,3 +23,5 @@ exports.options = kebabcaseKeys({
description: 'Run identifier to be rerun'
}
});

exports.DOCSURL = DOCSURL;
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.