mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-17 06:47:09 +01:00
chore: add create pr comment flag
This commit is contained in:
parent
0693dd14d6
commit
e622ff7921
3 changed files with 32 additions and 10 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
name: Test Reporter
|
name: Test Reporter
|
||||||
description: |
|
description: |
|
||||||
Shows test results in GitHub UI: .NET (xUnit, NUnit, MSTest), Dart, Flutter, Java (JUnit), JavaScript (JEST, Mocha)
|
Shows test results in GitHub UI: .NET (xUnit, NUnit, MSTest), Dart, Flutter, Java (JUnit), JavaScript (JEST, Mocha), Apex (Salesforce via json)
|
||||||
author: Michal Dorner <dorner.michal@gmail.com>
|
author: Michal Dorner <dorner.michal@gmail.com>
|
||||||
inputs:
|
inputs:
|
||||||
artifact:
|
artifact:
|
||||||
|
|
@ -90,6 +90,12 @@ inputs:
|
||||||
description: GitHub Access Token
|
description: GitHub Access Token
|
||||||
required: false
|
required: false
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
|
create-pr-comment:
|
||||||
|
description: |
|
||||||
|
Allows you to create a comment on the pull request with the test results.
|
||||||
|
If enabled, the comment will contain a summary of the test results
|
||||||
|
default: 'false'
|
||||||
|
required: false
|
||||||
outputs:
|
outputs:
|
||||||
conclusion:
|
conclusion:
|
||||||
description: |
|
description: |
|
||||||
|
|
|
||||||
13
dist/index.js
generated
vendored
13
dist/index.js
generated
vendored
|
|
@ -279,6 +279,7 @@ class TestReporter {
|
||||||
useActionsSummary = core.getInput('use-actions-summary', { required: false }) === 'true';
|
useActionsSummary = core.getInput('use-actions-summary', { required: false }) === 'true';
|
||||||
badgeTitle = core.getInput('badge-title', { required: false });
|
badgeTitle = core.getInput('badge-title', { required: false });
|
||||||
token = core.getInput('token', { required: true });
|
token = core.getInput('token', { required: true });
|
||||||
|
createPRComment = core.getInput('create-pr-comment', { required: false }) === 'true';
|
||||||
octokit;
|
octokit;
|
||||||
context = (0, github_utils_1.getCheckRunContext)();
|
context = (0, github_utils_1.getCheckRunContext)();
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -418,6 +419,18 @@ class TestReporter {
|
||||||
core.info(`Check run HTML: ${resp.data.html_url}`);
|
core.info(`Check run HTML: ${resp.data.html_url}`);
|
||||||
core.setOutput('url', resp.data.url);
|
core.setOutput('url', resp.data.url);
|
||||||
core.setOutput('url_html', resp.data.html_url);
|
core.setOutput('url_html', resp.data.html_url);
|
||||||
|
if (this.createPRComment) {
|
||||||
|
const { pull_request } = github.context.payload;
|
||||||
|
if (pull_request) {
|
||||||
|
core.info('Attaching Test Summary as a comment to the PR');
|
||||||
|
const comment = `## Test Summary\n\n${summary}`;
|
||||||
|
await this.octokit.rest.issues.createComment({
|
||||||
|
...github.context.repo,
|
||||||
|
issue_number: pull_request.number,
|
||||||
|
body: comment
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ class TestReporter {
|
||||||
readonly useActionsSummary = core.getInput('use-actions-summary', {required: false}) === 'true'
|
readonly useActionsSummary = core.getInput('use-actions-summary', {required: false}) === 'true'
|
||||||
readonly badgeTitle = core.getInput('badge-title', {required: false})
|
readonly badgeTitle = core.getInput('badge-title', {required: false})
|
||||||
readonly token = core.getInput('token', {required: true})
|
readonly token = core.getInput('token', {required: true})
|
||||||
|
readonly createPRComment = core.getInput('create-pr-comment', {required: false}) === 'true'
|
||||||
readonly octokit: InstanceType<typeof GitHub>
|
readonly octokit: InstanceType<typeof GitHub>
|
||||||
readonly context = getCheckRunContext()
|
readonly context = getCheckRunContext()
|
||||||
|
|
||||||
|
|
@ -220,6 +221,7 @@ class TestReporter {
|
||||||
core.setOutput('url', resp.data.url)
|
core.setOutput('url', resp.data.url)
|
||||||
core.setOutput('url_html', resp.data.html_url)
|
core.setOutput('url_html', resp.data.html_url)
|
||||||
|
|
||||||
|
if (this.createPRComment) {
|
||||||
const {pull_request} = github.context.payload
|
const {pull_request} = github.context.payload
|
||||||
|
|
||||||
if (pull_request) {
|
if (pull_request) {
|
||||||
|
|
@ -234,6 +236,7 @@ class TestReporter {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue