Skip to content

Commit 499b09e

Browse files
committed
ci: combined coverage
1 parent 9538bf4 commit 499b09e

File tree

8 files changed

+81
-17
lines changed

8 files changed

+81
-17
lines changed

.c8rc.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"src": "lib",
3+
"include": "lib",
4+
"reporter": []
5+
}

.github/workflows/test.yml

+53-3
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ jobs:
7878
run: npx panva/npm-install-retry
7979
if: ${{ steps.node_modules.outputs.cache-hit != 'true' }}
8080
- run: npm run ci
81+
- uses: actions/upload-artifact@v2
82+
if: ${{ matrix.node-version == 14 && matrix.os == 'ubuntu-latest' }}
83+
with:
84+
if-no-files-found: warn
85+
retention-days: 1
86+
name: coverage-data
87+
path: coverage/
8188

8289
conformance-suite:
8390
runs-on: ubuntu-latest
@@ -299,7 +306,7 @@ jobs:
299306
- name: Setup node
300307
uses: actions/setup-node@v2-beta
301308
with:
302-
node-version: 12
309+
node-version: 14
303310
- name: Store node version variable
304311
id: node
305312
run: |
@@ -314,14 +321,14 @@ jobs:
314321
run: npx panva/npm-install-retry
315322
if: ${{ steps.node_modules.outputs.cache-hit != 'true' }}
316323
- name: Run oidc-provider (OIDC)
317-
run: node certification/docker &
324+
run: npx c8 node certification/docker &
318325
if: ${{ startsWith(matrix.setup.plan, 'oidcc') }}
319326
env:
320327
PORT: 3000
321328
ISSUER: https://172.17.0.1:3000
322329
NODE_TLS_REJECT_UNAUTHORIZED: 0
323330
- name: Run oidc-provider (FAPI)
324-
run: node certification/fapi &
331+
run: npx c8 node certification/fapi &
325332
if: ${{ startsWith(matrix.setup.plan, 'fapi') }}
326333
env:
327334
ISSUER: https://172.17.0.1:3000
@@ -369,9 +376,52 @@ jobs:
369376
if: ${{ always() }}
370377
- name: Stop Conformance Suite
371378
run: |
379+
killall -SIGINT node
372380
cd conformance-suite
373381
docker-compose -f docker-compose-dev.yml down
374382
sudo rm -rf mongo
383+
- uses: actions/upload-artifact@v2
384+
with:
385+
if-no-files-found: warn
386+
retention-days: 1
387+
name: coverage-data
388+
path: coverage/
389+
390+
coverage:
391+
runs-on: ubuntu-latest
392+
needs:
393+
- test
394+
- conformance-suite
395+
steps:
396+
- name: Checkout
397+
uses: actions/checkout@master
398+
- name: Setup node
399+
uses: actions/setup-node@v2-beta
400+
with:
401+
node-version: 14
402+
- name: Store node version variable
403+
id: node
404+
run: |
405+
echo "::set-output name=version::$(node -v)"
406+
- name: Cache node_modules
407+
uses: actions/cache@v2
408+
id: node_modules
409+
with:
410+
path: node_modules
411+
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package.json') }}-${{ steps.node.outputs.version }}
412+
- name: Install dependencies
413+
run: npx panva/npm-install-retry
414+
if: ${{ steps.node_modules.outputs.cache-hit != 'true' }}
415+
- uses: actions/download-artifact@v2
416+
with:
417+
name: coverage-data
418+
path: coverage/
419+
- run: npx c8 report --reporter=lcov --reporter=text-summary
420+
- uses: actions/upload-artifact@v2
421+
with:
422+
if-no-files-found: warn
423+
name: coverage-report
424+
path: coverage/lcov-report/
375425

376426
deploy:
377427
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'panva/node-oidc-provider' }}

.nycrc.json

-6
This file was deleted.

certification/docker.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,9 @@ render(provider.app, {
4040
});
4141
provider.use(routes(provider).routes());
4242
const server = https.createServer(pem, provider.callback());
43-
server.listen(PORT);
43+
server.listen(PORT, () => {
44+
console.log(`application is listening on port ${PORT}, check its /.well-known/openid-configuration`);
45+
process.on('SIGINT', () => {
46+
process.exit(0);
47+
});
48+
});

certification/fapi/index.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable no-console */
2+
13
const { readFileSync } = require('fs');
24
const path = require('path');
35
const { randomBytes } = require('crypto');
@@ -212,5 +214,10 @@ if (SUITE_BASE_URL === OFFICIAL_CERTIFICATION) {
212214
...pem,
213215
}, fapi.callback());
214216

215-
server.listen(PORT);
217+
server.listen(PORT, () => {
218+
console.log(`application is listening on port ${PORT}, check its /.well-known/openid-configuration`);
219+
process.on('SIGINT', () => {
220+
process.exit(0);
221+
});
222+
});
216223
}

certification/oidc.js

+3
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ let server;
134134
provider.use(routes(provider).routes());
135135
server = provider.listen(PORT, () => {
136136
console.log(`application is listening on port ${PORT}, check its /.well-known/openid-configuration`);
137+
process.on('SIGINT', () => {
138+
process.exit(0);
139+
});
137140
});
138141
})().catch((err) => {
139142
if (server && server.listening) server.close();

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"main": "lib/index.js",
4141
"scripts": {
4242
"ci": "node ./test/ci",
43-
"coverage": "nyc node ./test/run",
43+
"coverage": "c8 node ./test/run",
4444
"heroku-postbuild": "npm install mongodb@^3.0.0 openid-client@^4.0.0",
4545
"lint": "eslint lib example certification test",
4646
"lint-fix": "eslint lib example certification test --fix",
@@ -67,6 +67,7 @@
6767
"@hapi/hapi": "^20.0.1",
6868
"babel-eslint": "^10.1.0",
6969
"base64url": "^3.0.1",
70+
"c8": "^7.7.2",
7071
"chai": "^4.2.0",
7172
"clear-module": "^4.1.1",
7273
"connect": "^3.7.0",
@@ -88,7 +89,6 @@
8889
"mocha.parallel": "^0.15.6",
8990
"moment": "^2.29.1",
9091
"nock": "^13.0.4",
91-
"nyc": "^15.1.0",
9292
"sinon": "^10.0.0",
9393
"supertest": "^6.1.3",
9494
"timekeeper": "^2.2.0"

test/ci.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ let first = true;
55

66
function pass({ mountTo, mountVia } = {}) {
77
const child = spawn(
8-
'nyc',
9-
['--silent', first ? '' : '--no-clean', 'npm', 'run', 'test'].filter(Boolean),
8+
'c8',
9+
[first ? '' : '--clean=false', 'npm', 'run', 'test'].filter(Boolean),
1010
{
1111
stdio: 'inherit',
1212
shell: true,
@@ -34,8 +34,8 @@ function pass({ mountTo, mountVia } = {}) {
3434

3535
function report() {
3636
const child = spawn(
37-
'nyc',
38-
['report'],
37+
'c8',
38+
['report', '--reporter=lcov', '--reporter=text-summary'],
3939
{
4040
stdio: 'inherit',
4141
shell: true,

0 commit comments

Comments
 (0)