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

feat: add addition override parameters #86

Merged
merged 4 commits into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ The action's step needs to run after your test suite has outputted an LCOV file.
| `parallel-finished` | _optional_ | Set to true in the last job, after the other parallel jobs steps have completed, this will send a webhook to Coveralls to set the build complete. |
| `coveralls-endpoint` | _optional_ | Hostname and protocol: `https://<host>`; Specifies a [Coveralls Enterprise](https://enterprise.coveralls.io/) hostname. |
| `base-path` | _optional_ | Path to the root folder of the project the coverage was collected in. Should be used in monorepos so that coveralls can process the LCOV correctly (e.g. packages/my-project) |
| `git-branch` | _optional_ | Default: GITHUB_REF environment variable. Override the branch name. |
| `git-commit` | _optional_ | Default: GITHUB_SHA environment variable. Override the commit sha. |

### Outputs:

Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ inputs:
base-path:
description: 'The root folder of the project that originally ran the tests'
required: false
git-branch:
description: 'Override the branch name'
required: false
git-commit:
description: 'Override the commit sha'
required: false
outputs:
coveralls-api-result:
description: 'Result status of Coveralls API post.'
Expand Down
10 changes: 9 additions & 1 deletion lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ function run() {
console.log("Event Name: " + process.env.GITHUB_EVENT_NAME);
console.log(event);
}
if (process.env.GITHUB_EVENT_NAME == 'pull_request') {
const gitCommit = core.getInput('git-commit');
const gitBranch = core.getInput('git-branch');
if (gitCommit && gitCommit != '') {
process.env.COVERALLS_GIT_COMMIT = gitCommit;
}
if (gitBranch && gitBranch != '') {
process.env.COVERALLS_GIT_BRANCH = gitBranch;
}
if (process.env.GITHUB_EVENT_NAME == 'pull_request' || process.env.GITHUB_EVENT_NAME == 'pull_request_target') {
process.env.CI_PULL_REQUEST = JSON.parse(event).number;
}
const endpoint = core.getInput('coveralls-endpoint');
Expand Down
13 changes: 12 additions & 1 deletion src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,18 @@ export async function run() {
console.log(event);
}

if (process.env.GITHUB_EVENT_NAME == 'pull_request') {
const gitCommit = core.getInput('git-commit');
const gitBranch = core.getInput('git-branch');

if (gitCommit && gitCommit != '') {
process.env.COVERALLS_GIT_COMMIT = gitCommit;
}

if (gitBranch && gitBranch != '') {
process.env.COVERALLS_GIT_BRANCH = gitBranch;
}

if (process.env.GITHUB_EVENT_NAME == 'pull_request' || process.env.GITHUB_EVENT_NAME == 'pull_request_target') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both pull_request and pull_request_trigger contain this information. However I did not want to add explicit support for pull_request_trigger in the docs as this might confuse users.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mad-it We just stumbled over, that using pull_request_target does not work out of the box with coveralls.

As I know now, we need to provide git-commit as a parameter to the step.

I would suggest to mention this in the documentation, because I think with the switch to native-dependabot some other people will also stumble over this problem.

process.env.CI_PULL_REQUEST = JSON.parse(event).number;
}

Expand Down