Skip to content

Commit

Permalink
Log running version of tachomter-reporter-action (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewiggins authored Dec 7, 2020
1 parent 5e6c13f commit fc11694
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 11 deletions.
3 changes: 3 additions & 0 deletions dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require('crypto');

const { reportTachResults } = util.src;
const { getLogger, getInputs } = util.util;
const { fullVersion } = util.version;

(async () => {
const token = util.core.getInput("github-token", { required: true });
Expand All @@ -26,6 +27,8 @@ const { getLogger, getInputs } = util.util;
const inputs = getInputs(logger);
const octokit = util.github.getOctokit(token);

logger.info(`Running tachometer-reporter-action ${fullVersion}`);

if (util.github.context.eventName !== "pull_request") {
logger.info(
"Not a pull request event. Skipping this action and doing nothing."
Expand Down
3 changes: 3 additions & 0 deletions dist/pre.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require('crypto');

const { reportTachRunning } = util.src;
const { getLogger, getInputs } = util.util;
const { fullVersion } = util.version;

(async function () {
const token = util.core.getInput("github-token", { required: true });
Expand All @@ -26,6 +27,8 @@ const { getLogger, getInputs } = util.util;
const inputs = getInputs(logger);
const context = util.github.context;

logger.info(`Running tachometer-reporter-action ${fullVersion}`);

logger.debug(() => "Running pre tachometer-reporter-action...");
logger.debug(() => "Report ID: " + JSON.stringify(inputs.reportId));
logger.debug(() => "Issue: " + JSON.stringify(context.issue, null, 2));
Expand Down
20 changes: 15 additions & 5 deletions dist/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -14042,22 +14042,31 @@ var escapeStringRegexp = string => {
.replace(/-/g, '\\x2d');
};

const fullVersion = `v${
"2.1.0"
}`;
const majorVersion = ` v${
2
}`;

var version = {
fullVersion,
majorVersion,
};

const { createMachine: createMachine$1, interpret: interpret$1, assign: assign$2 } = es;

const { majorVersion: majorVersion$1 } = version;

/** @type {(min: number, max: number) => number} */
const randomInt = (min, max) => Math.floor(Math.random() * (max - min)) + min;

/** @type {(ms: number) => Promise<void>} */
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

const version =
2;
const versionStr = ` v${version}`;

/** @type {(actionInfo: import('./global').ActionInfo) => string} */
const getFooter = (actionInfo) =>
`\n\n<sub><a href="https://github.com/andrewiggins/tachometer-reporter-action" target="_blank">tachometer-reporter-action${versionStr}</a> for <a href="${actionInfo.workflow.runsHtmlUrl}" target="_blank">${actionInfo.workflow.name}</a></sub>`;
`\n\n<sub><a href="https://github.com/andrewiggins/tachometer-reporter-action" target="_blank">tachometer-reporter-action${majorVersion$1}</a> for <a href="${actionInfo.workflow.runsHtmlUrl}" target="_blank">${actionInfo.workflow.name}</a></sub>`;

/** @type {(writerId: string) => string} */
const getLockHtml = (writerId) =>
Expand Down Expand Up @@ -15154,3 +15163,4 @@ exports.core = core;
exports.github = github;
exports.src = src;
exports.util = util;
exports.version = version;
4 changes: 3 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const pkg = JSON.parse(
readFileSync(path.join(__dirname, "package.json"), "utf8")
);

const [major] = pkg.version.split(".").map(Number);
const fullVersion = pkg.version;
const [major] = fullVersion.split(".").map(Number);

module.exports = {
input: ["src/actions/main.js", "src/actions/pre.js"],
Expand All @@ -27,6 +28,7 @@ module.exports = {
production: true,
}),
replace({
__PKG_FULL_VERSION__: JSON.stringify(fullVersion),
__PKG_MAJOR_VERSION__: major,
}),
nodeResolve(),
Expand Down
3 changes: 3 additions & 0 deletions src/actions/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const core = require("@actions/core");
const github = require("@actions/github");
const { reportTachResults } = require("../index");
const { getLogger, getInputs } = require("./util");
const { fullVersion } = require("../utils/version");

(async () => {
const token = core.getInput("github-token", { required: true });
Expand All @@ -10,6 +11,8 @@ const { getLogger, getInputs } = require("./util");
const inputs = getInputs(logger);
const octokit = github.getOctokit(token);

logger.info(`Running tachometer-reporter-action ${fullVersion}`);

if (github.context.eventName !== "pull_request") {
logger.info(
"Not a pull request event. Skipping this action and doing nothing."
Expand Down
3 changes: 3 additions & 0 deletions src/actions/pre.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const core = require("@actions/core");
const github = require("@actions/github");
const { reportTachRunning } = require("../index");
const { getLogger, getInputs } = require("./util");
const { fullVersion } = require("../utils/version");

(async function () {
const token = core.getInput("github-token", { required: true });
Expand All @@ -10,6 +11,8 @@ const { getLogger, getInputs } = require("./util");
const inputs = getInputs(logger);
const context = github.context;

logger.info(`Running tachometer-reporter-action ${fullVersion}`);

logger.debug(() => "Running pre tachometer-reporter-action...");
logger.debug(() => "Report ID: " + JSON.stringify(inputs.reportId));
logger.debug(() => "Issue: " + JSON.stringify(context.issue, null, 2));
Expand Down
7 changes: 2 additions & 5 deletions src/comments.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
const { createMachine, interpret, assign } = require("xstate");
const escapeRe = require("escape-string-regexp");
const { majorVersion } = require("./utils/version");

/** @type {(min: number, max: number) => number} */
const randomInt = (min, max) => Math.floor(Math.random() * (max - min)) + min;

/** @type {(ms: number) => Promise<void>} */
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

const version =
typeof __PKG_MAJOR_VERSION__ == "undefined" ? 1 : __PKG_MAJOR_VERSION__;
const versionStr = ` v${version}`;

/** @type {(actionInfo: import('./global').ActionInfo) => string} */
const getFooter = (actionInfo) =>
`\n\n<sub><a href="https://github.com/andrewiggins/tachometer-reporter-action" target="_blank">tachometer-reporter-action${versionStr}</a> for <a href="${actionInfo.workflow.runsHtmlUrl}" target="_blank">${actionInfo.workflow.name}</a></sub>`;
`\n\n<sub><a href="https://github.com/andrewiggins/tachometer-reporter-action" target="_blank">tachometer-reporter-action${majorVersion}</a> for <a href="${actionInfo.workflow.runsHtmlUrl}" target="_blank">${actionInfo.workflow.name}</a></sub>`;

/** @type {(writerId: string) => string} */
const getLockHtml = (writerId) =>
Expand Down
11 changes: 11 additions & 0 deletions src/utils/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const fullVersion = `v${
typeof __PKG_FULL_VERSION__ == "undefined" ? 1 : __PKG_FULL_VERSION__
}`;
const majorVersion = ` v${
typeof __PKG_MAJOR_VERSION__ == "undefined" ? 1 : __PKG_MAJOR_VERSION__
}`;

module.exports = {
fullVersion,
majorVersion,
};

0 comments on commit fc11694

Please sign in to comment.