Skip to content
This repository has been archived by the owner on Jan 14, 2024. It is now read-only.

Commit

Permalink
Use issue command #3
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Jul 22, 2020
1 parent 175072b commit 898426e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 44 deletions.
7 changes: 4 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ branding:
icon: 'box'
color: 'green'
inputs:
accessToken:
description: 'github token'
required: true
stripFromPath:
description: 'Path to strip from file'
required: false
path:
description: 'glob to junit xml files'
required: true
errorLevel:
description: 'glob to junit xml files'
default: 'warning'
required: true
runs:
using: 'node12'
main: 'dist/index.js'
52 changes: 11 additions & 41 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const core = require('@actions/core');
const github = require('@actions/github');
const glob = require('@actions/glob');
const fs = require('fs');
var parseString = require('xml2js').parseStringPromise;
Expand All @@ -8,10 +7,9 @@ var parseString = require('xml2js').parseStringPromise;
try {
const path = core.getInput('path');
const stripFromPath = core.getInput('stripFromPath');
const accessToken = core.getInput('accessToken');
const errorLevel = core.getInput('errorLevel');

const globber = await glob.create(path, {followSymbolicLinks: false});
let annotations = [];

for await (const file of globber.globGenerator()) {
const data = await fs.promises.readFile(file);
Expand Down Expand Up @@ -41,48 +39,20 @@ var parseString = require('xml2js').parseStringPromise;
line = '1';
}


annotations.push({
path: file,
start_line: line,
end_line: line,
start_column: 0,
end_column: 0,
annotation_level: 'failure',
title: testsuite['$'].name + "::" + testCase['$'].name,
message: testCase.failure[0]['_'],
});
core.issueCommand(
errorLevel,
{
file: file,
line: line,
col: line,
},
testCase.failure[0]['_']
)
}
}
}
}
}

console.log(annotations);

if (annotations.length === 0) {
return;
}

const octokit = new github.GitHub(accessToken);
const req = {
...github.context.repo,
ref: github.context.sha
}
const res = await octokit.checks.listForRef(req);
console.log(res);
const check_run_id = res.data.check_runs.filter(check => check.name === 'build')[0].id

const update_req = {
...github.context.repo,
check_run_id,
output: {
title: "Junit Results",
summary: `jUnit Results`,
annotations: annotations
}
}
await octokit.checks.update(update_req);
}
} catch(error) {
core.setFailed(error.message);
Expand Down

0 comments on commit 898426e

Please sign in to comment.