Skip to content

Commit

Permalink
Merge branch 'master' into cli-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
0x2b3bfa0 committed Oct 14, 2022
2 parents 90238b7 + 3087980 commit 7c204f4
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 6 deletions.
6 changes: 5 additions & 1 deletion bin/legacy/commands/ci.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const { addDeprecationNotice } = require('../deprecation');
const { builder, handler } = require('../../cml/repo/prepare');

exports.command = 'ci';
exports.description = 'Prepare Git repository for CML operations';
exports.handler = handler;
exports.builder = builder;
exports.builder = addDeprecationNotice({
builder,
notice: '"cml ci" is deprecated, please use "cml repo prepare"'
});
6 changes: 5 additions & 1 deletion bin/legacy/commands/publish.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const { addDeprecationNotice } = require('../deprecation');
const { builder, handler } = require('../../cml/asset/publish');

exports.command = 'publish <asset>';
exports.description = false;
exports.handler = handler;
exports.builder = builder;
exports.builder = addDeprecationNotice({
builder,
notice: '"cml publish" is deprecated, please use "cml asset publish"'
});
6 changes: 5 additions & 1 deletion bin/legacy/commands/rerun-workflow.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const { addDeprecationNotice } = require('../deprecation');
const { builder, handler } = require('../../cml/workflow/rerun');

exports.command = 'rerun-workflow';
exports.description = false;
exports.handler = handler;
exports.builder = builder;
exports.builder = addDeprecationNotice({
builder,
notice: '"cml rerun-workflow" is deprecated, please use "cml workflow rerun"'
});
6 changes: 5 additions & 1 deletion bin/legacy/commands/send-comment.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const { addDeprecationNotice } = require('../deprecation');
const { builder, handler } = require('../../cml/comment/create');

exports.command = 'send-comment <markdown file>';
exports.description = false;
exports.handler = handler;
exports.builder = builder;
exports.builder = addDeprecationNotice({
builder,
notice: '"cml send-comment" is deprecated, please use "cml comment create"'
});
6 changes: 5 additions & 1 deletion bin/legacy/commands/send-github-check.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const { addDeprecationNotice } = require('../deprecation');
const { builder, handler } = require('../../cml/check/create');

exports.command = 'send-github-check <markdown file>';
exports.description = false;
exports.handler = handler;
exports.builder = builder;
exports.builder = addDeprecationNotice({
builder,
notice: '"cml send-github-check" is deprecated, please use "cml check create"'
});
7 changes: 6 additions & 1 deletion bin/legacy/commands/tensorboard-dev.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
const { addDeprecationNotice } = require('../deprecation');
const { builder, handler } = require('../../cml/tensorboard/connect');

exports.command = 'tensorboard-dev';
exports.description = false;
exports.handler = handler;
exports.builder = builder;
exports.builder = addDeprecationNotice({
builder,
notice:
'"cml tensorboard-dev" is deprecated, please use "cml tensorboard connect"'
});
20 changes: 20 additions & 0 deletions bin/legacy/deprecation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const winston = require('winston');

// addDeprecationNotice adds middleware to the yargs chain to display a deprecation notice.
const addDeprecationNotice = (opts = {}) => {
const { builder, notice } = opts;
return (yargs) =>
builder(yargs).middleware([(opts) => deprecationNotice(opts, notice)]);
};

const deprecationNotice = (opts, notice) => {
const { cml } = opts;
const driver = cml.getDriver();
if (driver.warn) {
driver.warn(notice);
} else {
winston.warn(notice);
}
};

exports.addDeprecationNotice = addDeprecationNotice;
4 changes: 4 additions & 0 deletions src/drivers/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,10 @@ class Github {
return command;
}

warn(message) {
console.error(`::warning::${message}`);
}

get sha() {
if (GITHUB_EVENT_NAME === 'pull_request')
return github.context.payload.pull_request.head.sha;
Expand Down

2 comments on commit 7c204f4

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Test Comment

CML watermark

Please sign in to comment.