Skip to content

Commit

Permalink
add version (#13)
Browse files Browse the repository at this point in the history
* test

* test

* try workflow again

* hmm

* add version input

* install the specified version

* update summary

* show actual version

* fix
  • Loading branch information
larshp authored Apr 13, 2020
1 parent e46193d commit 4614461
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ branding:
runs:
using: 'docker'
image: 'Dockerfile'
inputs:
version:
description: 'abaplint version'
required: false
default: 'latest'
3 changes: 2 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/sh
npm install @abaplint/cli -g
echo $INPUT_VERSION
npm install @abaplint/cli@$INPUT_VERSION -g
abaplint -f total --outformat json --outfile /result.json
cd /
npm install @octokit/[email protected] --loglevel=error
Expand Down
31 changes: 19 additions & 12 deletions logic.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const octokit = require('@octokit/rest')();
const childProcess = require("child_process");
const fs = require('fs');
const octokit = require('@octokit/rest')();

function buildAnnotations() {
const issues = JSON.parse(fs.readFileSync("/result.json", "utf-8"));
const annotations = [];

for(let issue of issues) {
annotations.push({
path: issue.file.substring(2),
Expand All @@ -16,30 +17,36 @@ function buildAnnotations() {
if (annotations.length === 50) {
break; // only 50 annotations allowed, see https://developer.github.com/v3/checks/runs/
}
}
}

return annotations;
}

function buildSummary() {
const issues = JSON.parse(fs.readFileSync("/result.json", "utf-8"));
return issues.length + " issues found(first 50 shown)";

const actual = childProcess.execSync(`abaplint --version`).toString();

const first = issues.length > 50 ? "(first 50 shown)" : "";
return issues.length + " issues found"+ first + "\n\n" +
"Installed @abaplint/cli@" + process.env.INPUT_VERSION + "\n\n" +
"Actual " + actual;
}

async function run() {
const annotations = buildAnnotations();
const summary = buildSummary();
const annotations = buildAnnotations();
const summary = buildSummary();

octokit.authenticate({
type: 'token',
token: process.env.GITHUB_TOKEN,
});

const repo = process.env.GITHUB_REPOSITORY.split("/");

const create = await octokit.checks.create({
owner: repo[0],
repo: repo[1],
owner: repo[0],
repo: repo[1],
name: "results",
status: "completed",
conclusion: annotations.length === 0 ? "success" : "failure",
Expand Down

0 comments on commit 4614461

Please sign in to comment.