Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add summary as an action output #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ inputs:
description: "Name of the Check in the github actions UI"
require: true
default: "Junit Results"
outputs:
summary:
description: "The test run summary"
runs:
using: "node12"
main: "index.js"
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const path = require("path");
},
};

core.setOutput("summary", testSummary.toFormattedMessage());
const octokit = new github.GitHub(accessToken);
await octokit.checks.create(createCheckRequest);
} catch (error) {
Expand Down
37 changes: 37 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const index = require("./index");
const process = require("process");
const cp = require("child_process");
const path = require("path");
const fs = require("fs").promises;

Expand Down Expand Up @@ -330,6 +332,41 @@ describe('TestSummary', () => {
});
});

describe('action logic', () => {
// Setup the necessary mocks
const token = 'dummyToken';
const inputPath = '**/TEST-*.xml';
const includeSummary = true;
const numFailures = 10;
const name = 'Junit Results';
const repo = 'foo/bar';
const ref = 'refs/heads/some-ref';
const sha = '1234567890123456789012345678901234567890';

beforeAll(() => {
process.env['INPUT_ACCESS-TOKEN'] = token;
process.env['INPUT_PATH'] = inputPath;
process.env['INPUT_INCLUDESUMMARY'] = includeSummary;
process.env['INPUT_NUMFAILURES'] = numFailures;
process.env['INPUT_NAME'] = name;
process.env['GITHUB_REPOSITORY'] = repo;
process.env['GITHUB_REF'] = ref;
process.env['GITHUB_SHA'] = sha;
});

it('should provide "summary" output', async done => {
const ip = path.join(__dirname, 'index.js');
cp.exec(`node ${ip}`, {env: process.env}, (error, stdout, stderr) => {
try {
expect(stdout).toContain("::set-output name=summary::Junit Results ran 3 in 0.132 seconds 1 Errored, 1 Failed, 0 Skipped");
done();
} catch(error) {
done(error);
}
});
});
});

async function addFile(filePath, content) {
filePath = "tmp/" + filePath;
let dirname = path.dirname(filePath);
Expand Down