Skip to content

Commit

Permalink
feat: add carryforward flags
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox authored Feb 24, 2023
2 parents 3284643 + 3c1bf50 commit 0363cd2
Show file tree
Hide file tree
Showing 3,940 changed files with 21,328 additions and 1,341,186 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The action's step needs to run after your test suite has outputted an LCOV file.
| `flag-name` | _optional (unique required if parallel)_ | Job flag name, e.g. "Unit", "Functional", or "Integration". Will be shown in the Coveralls UI. |
| `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 }}` |
| `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. |
| `carryforward` | _optional_ | Comma separated flags used to carryforward results from previous builds if some of the parallel jobs are missing. Used only with `parallel-finished`. |
| `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. |
Expand Down Expand Up @@ -46,10 +47,10 @@ jobs:

- uses: actions/checkout@v1

- name: Use Node.js 10.x
uses: actions/setup-node@v1
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 10.x
node-version: 16.x

- name: npm install, make test-coverage
run: |
Expand Down Expand Up @@ -78,11 +79,11 @@ jobs:
- 1
- 2
steps:
- uses: actions/checkout@master
- name: Use Node.js 10.x
uses: actions/setup-node@master
- uses: actions/checkout@3
- name: Use Node.js 16.x
uses: actions/setup-node@3
with:
version: 10.x
node-version: 16.x

- name: npm install
run: npm install
Expand All @@ -98,13 +99,15 @@ jobs:

finish:
needs: test
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
carryforward: "run-1,run-2"
```
The "Coveralls Finished" step needs to run after all other steps have completed; it will let Coveralls know that all jobs in the build are done and aggregate coverage calculation can be calculated and notifications sent.
Expand Down
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ inputs:
parallel-finished:
description: 'Set to true for the last action when using "parallel: true".'
required: false
carryforward:
description: 'Comma separated flags used to carryforward results from previous builds if some of the parallel jobs are missing.'
required: false
coveralls-endpoint:
description: 'Coveralls Enterprise server (more info: https://enterprise.coveralls.io)'
required: false
Expand All @@ -38,5 +41,5 @@ branding:
color: 'green'
icon: 'percent'
runs:
using: 'node12'
using: 'node16'
main: './lib/main.js'
3 changes: 1 addition & 2 deletions lib/lcov-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ const path_1 = __importDefault(require("path"));
* @param lcovFile a string containing an entire LCOV file
* @param basePath the base path to join with the LCOV file paths
*/
const adjustLcovBasePath = (lcovFile, basePath) => lcovFile.replace(/^SF:(.+)$/gm, (_, match) => `SF:${path_1.default.join(basePath, match)}`);
exports.adjustLcovBasePath = adjustLcovBasePath;
exports.adjustLcovBasePath = (lcovFile, basePath) => lcovFile.replace(/^SF:(.+)$/gm, (_, match) => `SF:${path_1.default.join(basePath, match)}`);
8 changes: 7 additions & 1 deletion lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Expand Down Expand Up @@ -71,12 +71,18 @@ function run() {
}
const runId = process.env.GITHUB_RUN_ID;
process.env.COVERALLS_SERVICE_JOB_ID = runId;
const carryforward = core.getInput('carryforward');
if (carryforward != '') {
process.env.COVERALLS_CARRYFORWARD_FLAGS = carryforward;
}
if (core.getInput('parallel-finished') != '') {
const payload = {
"repo_token": githubToken,
"carryforward": process.env.COVERALLS_CARRYFORWARD_FLAGS,
"repo_name": process.env.GITHUB_REPOSITORY,
"payload": { "build_num": runId, "status": "done" }
};
console.log('Sending to coveralls', payload);
request_1.default.post({
url: `${process.env.COVERALLS_ENDPOINT || 'https://coveralls.io'}/webhook`,
body: payload,
Expand Down
3 changes: 2 additions & 1 deletion lib/run.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Expand Down Expand Up @@ -64,6 +64,7 @@ describe('Run', () => {
it('should run parallel finished', () => {
setup();
getInput.withArgs('parallel-finished').returns(1);
getInput.withArgs('carryforward').returns('job1,job2');
getInput.withArgs('coveralls-endpoint').returns('https://coveralls.io');
sandbox.stub(request, 'post');
run_1.run().then((result) => {
Expand Down
1 change: 0 additions & 1 deletion node_modules/.bin/_mocha

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/.bin/flat

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/.bin/handlebars

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/.bin/he

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/.bin/jsesc

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/.bin/mkdirp

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/.bin/mocha

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/.bin/nyc

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/.bin/parser

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/.bin/rimraf

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/.bin/semver

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/.bin/ts-node

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/.bin/tsc

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/.bin/tsserver

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/.bin/uglifyjs

This file was deleted.

2 changes: 1 addition & 1 deletion node_modules/.bin/uuid

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion node_modules/.bin/which

This file was deleted.

Loading

0 comments on commit 0363cd2

Please sign in to comment.