Skip to content

Commit

Permalink
Print github-specific deprecation notice on GH.
Browse files Browse the repository at this point in the history
  • Loading branch information
tasdomas committed Oct 14, 2022
1 parent e17483d commit 082595c
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 16 deletions.
4 changes: 2 additions & 2 deletions bin/legacy/commands/ci.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { deprecationNotice } = require('../deprecation');
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 = deprecationNotice({
exports.builder = addDeprecationNotice({
builder,
notice: '"cml ci" is deprecated, please use "cml repo prepare"'
});
4 changes: 2 additions & 2 deletions bin/legacy/commands/publish.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { deprecationNotice } = require('../deprecation');
const { addDeprecationNotice } = require('../deprecation');
const { builder, handler } = require('../../cml/asset/publish');

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

exports.command = 'rerun-workflow';
exports.description = false;
exports.handler = handler;
exports.builder = deprecationNotice({
exports.builder = addDeprecationNotice({
builder,
notice: '"cml rerun-workflow" is deprecated, please use "cml workflow rerun"'
});
4 changes: 2 additions & 2 deletions bin/legacy/commands/send-comment.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { deprecationNotice } = require('../deprecation');
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 = deprecationNotice({
exports.builder = addDeprecationNotice({
builder,
notice: '"cml send-comment" is deprecated, please use "cml comment create"'
});
4 changes: 2 additions & 2 deletions bin/legacy/commands/send-github-check.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { deprecationNotice } = require('../deprecation');
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 = deprecationNotice({
exports.builder = addDeprecationNotice({
builder,
notice: '"cml send-github-check" is deprecated, please use "cml check create"'
});
4 changes: 2 additions & 2 deletions bin/legacy/commands/tensorboard-dev.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { deprecationNotice } = require('../deprecation');
const { addDeprecationNotice } = require('../deprecation');
const { builder, handler } = require('../../cml/tensorboard/connect');

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

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

exports.deprecationNotice = deprecationNotice;
const deprecationNotice = (opts, notice) => {
const { cml } = opts;
if (cml.driver.warn) {
cml.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.log(`::warning::${message}`);
}

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

2 comments on commit 082595c

@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.