Skip to content

Commit 8222580

Browse files
committed
Proper error handling, cleaned up output
1 parent 0d99bc4 commit 8222580

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const WebPageTest = require("webpagetest");
22
const core = require("@actions/core");
33
const github = require('@actions/github');
4-
54
const ejs = require('ejs');
65

76
const WPT_BUDGET = core.getInput('budget');
@@ -16,6 +15,7 @@ const runTest = (wpt, url, options) => {
1615
let tempOptions = JSON.parse(JSON.stringify(options));
1716

1817
return new Promise((resolve, reject) => {
18+
core.info(`Submitting test for ${url}...`);
1919
wpt.runTest(url, tempOptions, async(err, result) => {
2020
try {
2121
if (result) {
@@ -45,14 +45,12 @@ async function renderComment(data) {
4545
try {
4646
const octokit = github.getOctokit(GITHUB_TOKEN, {log: console});
4747
const context = github.context;
48-
console.info(data);
4948
let markdown = await ejs.renderFile('./templates/comment.md', data);
5049
markdown
5150
.replace(/\%/g, '%25')
5251
.replace(/\n/g, '%0A')
5352
.replace(/\r/g, '%0D')
5453

55-
core.info(markdown);
5654
//submit a comment
5755
await octokit.issues.createComment({
5856
owner: context.repo.owner,
@@ -61,7 +59,7 @@ async function renderComment(data) {
6159
body: markdown
6260
});
6361
} catch (e) {
64-
core.info(e);
62+
core.setFailed(`Action failed with error ${e}`);
6563
}
6664
}
6765
async function run() {
@@ -137,12 +135,12 @@ async function run() {
137135
return;
138136
}
139137
} catch (e) {
140-
core.info(e);
138+
core.setFailed(`Action failed with error ${e}`);
141139
}
142140

143141
});
144142
} catch (e) {
145-
console.info(e);
143+
core.setFailed(`Action failed with error ${e}`);
146144
}
147145
})).then(() => {
148146
if (GH_EVENT_NAME == 'pull_request') {

0 commit comments

Comments
 (0)