Skip to content

Commit

Permalink
fix: ci tests
Browse files Browse the repository at this point in the history
  • Loading branch information
freddi301 committed Apr 3, 2022
1 parent ac2947f commit f6b56b1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/relying-party-test-node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '12', '14', '16' ]
node: [ '14', '16' ]
name: Node ${{ matrix.node }} sample
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion relying-party/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPID/CIE OIDC Federation Relying Party, for Node.js

[![Relying Party Test Node.js CI](https://github.com/italia/spid-cie-oidc-nodejs/actions/workflows/relying-party-test-node.js.yml/badge.svg)](https://github.com/italia/spid-cie-oidc-nodejs/actions/workflows/relying-party-test-node.js.yml) [![npm](https://img.shields.io/npm/v/spid-cie-oidc.svg)](https://www.npmjs.com/package/spid-cie-oidc)
[![npm](https://img.shields.io/npm/v/spid-cie-oidc.svg)](https://www.npmjs.com/package/spid-cie-oidc) [![Relying Party Test Node.js CI](https://github.com/italia/spid-cie-oidc-nodejs/actions/workflows/relying-party-test-node.js.yml/badge.svg)](https://github.com/italia/spid-cie-oidc-nodejs/actions/workflows/relying-party-test-node.js.yml) ![coverage](https://img.shields.io/badge/test%20coverage-67%25-yellow)

This package includes building blocks to implement openid federation relaying party into your application.

Expand Down
14 changes: 14 additions & 0 deletions relying-party/coverage-badge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const fs = require("fs");

const coverage = Math.round(
Object.values(JSON.parse(fs.readFileSync("coverage/coverage-summary.json")).total)
.filter((entry) => entry.total)
.map((entry) => entry.pct)
.reduce((m, v, i, a) => m + v / a.length, 0)
);

const badge = `https://img.shields.io/badge/coverage-${coverage}%25-${
coverage > 90 ? "green" : coverage > 50 ? "yellow" : "orange"
}.svg`;

console.log("\x1b[36m%s\x1b[0m", "Coverage badge:", badge);
3 changes: 2 additions & 1 deletion relying-party/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"build": "rollup -c",
"format": "prettier --write src",
"test": "jest",
"test:coverage": "jest --coverage --collectCoverageFrom=\"./src/**\""
"test:coverage": "jest --coverage --collectCoverageFrom=\"./src/**\"",
"ci:coverage": "jest --silent --coverage --collectCoverageFrom=\"./src/**\" --coverageReporters=\"json-summary\" && node coverage-badge.js"
},
"dependencies": {
"ajv": "^8.11.0",
Expand Down

0 comments on commit f6b56b1

Please sign in to comment.