Skip to content

Commit 198c793

Browse files
committed
Better parallel handling; flag_name support
* use GITHUB_RUN_ID instead of SHA
1 parent 78f494c commit 198c793

529 files changed

Lines changed: 8514 additions & 7603 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.DS_Store
2+
.idea
23
coverage

‎README.md‎

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ The action's step needs to run after your test suite has outputted an LCOV file.
1616
| --------------------- | ----------- | ----------- |
1717
| `github-token` | _required_ | Must be in form `github-token: ${{ secrets.GITHUB_TOKEN }}`; Coveralls uses this token to verify the posted coverage data on the repo and create a new check based on the results. It is built into Github Actions and does not need to be manually specified in your secrets store. [More Info](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token)|
1818
| `path-to-lcov` | _optional_ | Default: "./coverage/lcov.info". Local path to the lcov output file produced by your test suite. An error will be thrown if the file can't be found. This is the file that will be sent to the Coveralls API. |
19-
| `parallel` | _optional_ | Set to true for parallel (or matrix) based steps, where multiple posts to Coveralls will be performed in the check. |
19+
| `flag-name` | _optional (unique required if parallel)_ | Job flag name, e.g. "Unit", "Functional", or "Integration". Will be shown in the Coveralls UI. |
20+
| `parallel` | _optional_ | Set to true for parallel (or matrix) based steps, where multiple posts to Coveralls will be performed in the check. `flag-name` needs to be set and unique, e.g. `flag-name: run-${{ matrix.test_number }}` |
2021
| `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. |
2122
| `coveralls-endpoint` | _optional_ | Hostname and protocol: `https://<host>`; Specifies a [Coveralls Enterprise](https://enterprise.coveralls.io/) hostname. |
2223
| `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) |
@@ -67,35 +68,49 @@ on: ["push", "pull_request"]
6768
name: Test Coveralls Parallel
6869

6970
jobs:
70-
71-
build:
72-
name: Build
71+
test:
7372
runs-on: ubuntu-latest
73+
strategy:
74+
matrix:
75+
test_number:
76+
- 1
77+
- 2
7478
steps:
75-
76-
- uses: actions/checkout@v1
77-
79+
- uses: actions/checkout@master
7880
- name: Use Node.js 10.x
79-
uses: actions/setup-node@v1
81+
uses: actions/setup-node@master
8082
with:
81-
node-version: 10.x
83+
version: 10.x
8284

83-
- name: npm install, make test-coverage
84-
run: |
85-
npm install
86-
make test-coverage
85+
- name: npm install
86+
run: npm install
8787

88+
- name: Test ${{ matrix.test_number }}
89+
run: make test-coverage-${{ matrix.test_number }}
8890
- name: Coveralls Parallel
8991
uses: coverallsapp/github-action@master
9092
with:
91-
github-token: ${{ secrets.GITHUB_TOKEN }}
93+
github-token: ${{ secrets.github_token }}
94+
flag-name: run-${{ matrix.test_number }}
9295
parallel: true
93-
path-to-lcov: ./coverage/lcov.info # optional (default value)
96+
97+
finish:
98+
needs: test
99+
runs-on: ubuntu-latest
100+
steps:
101+
- uses: actions/checkout@master
102+
- name: Use Node.js 10.x
103+
uses: actions/setup-node@master
104+
with:
105+
version: 10.x
106+
107+
- name: npm install
108+
run: npm install
94109

95110
- name: Coveralls Finished
96111
uses: coverallsapp/github-action@master
97112
with:
98-
github-token: ${{ secrets.GITHUB_TOKEN }}
113+
github-token: ${{ secrets.github_token }}
99114
parallel-finished: true
100115
```
101116

‎lib/run.js‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,26 @@ function run() {
3434
process.env.COVERALLS_SERVICE_NAME = 'github';
3535
process.env.COVERALLS_GIT_COMMIT = process.env.GITHUB_SHA.toString();
3636
process.env.COVERALLS_GIT_BRANCH = process.env.GITHUB_REF.toString();
37+
process.env.COVERALLS_FLAG_NAME = process.env.COVERALLS_FLAG_NAME || core.getInput('flag-name');
3738
const event = fs_1.default.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8');
3839
if (process.env.COVERALLS_DEBUG) {
3940
console.log("Event Name: " + process.env.GITHUB_EVENT_NAME);
4041
console.log(event);
4142
}
42-
const sha = process.env.GITHUB_SHA.toString();
43-
let jobId;
4443
if (process.env.GITHUB_EVENT_NAME == 'pull_request') {
45-
const pr = JSON.parse(event).number;
46-
process.env.CI_PULL_REQUEST = pr;
47-
jobId = `${sha}-PR-${pr}`;
44+
process.env.CI_PULL_REQUEST = JSON.parse(event).number;
4845
}
49-
else {
50-
jobId = sha;
51-
}
52-
process.env.COVERALLS_SERVICE_JOB_ID = jobId;
5346
const endpoint = core.getInput('coveralls-endpoint');
5447
if (endpoint != '') {
5548
process.env.COVERALLS_ENDPOINT = endpoint;
5649
}
50+
const runId = process.env.GITHUB_RUN_ID;
51+
process.env.COVERALLS_SERVICE_JOB_ID = runId;
5752
if (core.getInput('parallel-finished') != '') {
5853
const payload = {
5954
"repo_token": githubToken,
6055
"repo_name": process.env.GITHUB_REPOSITORY,
61-
"payload": { "build_num": jobId, "status": "done" }
56+
"payload": { "build_num": runId, "status": "done" }
6257
};
6358
request_1.default.post({
6459
url: `${process.env.COVERALLS_ENDPOINT || 'https://coveralls.io'}/webhook`,

‎lib/run.spec.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ describe('Run', () => {
2424
const setup = () => {
2525
getInput = sandbox.stub(core, 'getInput');
2626
getInput.withArgs('github-token').returns('v1.asdf');
27+
process.env.GITHUB_RUN_NUMBER = "1234";
28+
process.env.GITHUB_RUN_ID = "1234567";
2729
process.env.GITHUB_SHA = "asdfasdf";
2830
process.env.GITHUB_REF = "master";
2931
process.env.GITHUB_EVENT_NAME = "pull_request";

‎node_modules/.bin/lcov-parse‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎node_modules/@actions/core/README.md‎

Lines changed: 146 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎node_modules/@actions/core/lib/command.d.ts‎

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)