Skip to content

Commit

Permalink
ci: merge coverage reports (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jul 31, 2021
1 parent d122b47 commit ee38cb8
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ jobs:
run: npm install --no-package-lock
- name: Test
run: npm test
- name: Coverage
run: npm run coverage
- name: Upload
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"concurrently": "latest",
"finepack": "latest",
"git-authors-cli": "latest",
"glob": "latest",
"gulp": "latest",
"gulp-autoprefixer": "latest",
"gulp-concat": "latest",
Expand All @@ -76,8 +77,11 @@
"gulp-uglify": "latest",
"lerna": "latest",
"lint-staged": "latest",
"make-dir": "latest",
"npm-check-updates": "latest",
"nyc": "latest",
"prettier-standard": "latest",
"rimraf": "latest",
"simple-git-hooks": "latest",
"standard": "latest"
},
Expand All @@ -88,7 +92,7 @@
"build": "gulp build",
"clean": "lerna clean --yes && rm -rf node_modules",
"contributors": "(lerna exec finepack --parallel && git-authors-cli && finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
"coverage": "lerna exec npm run coverage --parallel",
"coverage": "node scripts/merge-reports && mkdir -p coverage && nyc report --reporter=text-lcov > coverage/lcov.info",
"dev": "concurrently \"gulp\" \"npm run dev:server\"",
"dev:server": "browser-sync start --server --files \"index.html, README.md, static/**/*.(css|js)\"",
"install": "lerna bootstrap --force-local --no-ci",
Expand Down
3 changes: 2 additions & 1 deletion packages/devices/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"devDependencies": {
"ava": "latest",
"lodash": "latest",
"nyc": "latest",
"puppeteer": "latest"
},
"engines": {
Expand All @@ -44,7 +45,7 @@
"src"
],
"scripts": {
"test": "NODE_ENV=test ava"
"test": "NODE_ENV=test nyc ava"
},
"license": "MIT",
"ava": {
Expand Down
5 changes: 3 additions & 2 deletions packages/errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"whoops": "~4.1.0"
},
"devDependencies": {
"ava": "latest"
"ava": "latest",
"nyc": "latest"
},
"engines": {
"node": ">= 12"
Expand All @@ -43,7 +44,7 @@
"index.js"
],
"scripts": {
"test": "NODE_ENV=test ava"
"test": "NODE_ENV=test nyc ava"
},
"license": "MIT",
"ava": {
Expand Down
3 changes: 2 additions & 1 deletion packages/function/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
},
"devDependencies": {
"ava": "latest",
"nyc": "latest",
"browserless": "latest",
"puppeteer": "latest"
},
Expand All @@ -53,7 +54,7 @@
"src"
],
"scripts": {
"test": "NODE_ENV=test ava"
"test": "NODE_ENV=test nyc ava"
},
"license": "MIT",
"ava": {
Expand Down
3 changes: 2 additions & 1 deletion packages/lighthouse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
},
"devDependencies": {
"ava": "latest",
"nyc": "latest",
"browserless": "latest"
},
"engines": {
Expand All @@ -44,7 +45,7 @@
"src"
],
"scripts": {
"test": "NODE_ENV=test ava"
"test": "NODE_ENV=test nyc ava"
},
"license": "MIT",
"ava": {
Expand Down
5 changes: 3 additions & 2 deletions packages/pool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"devDependencies": {
"@browserless/test": "latest",
"ava": "latest",
"browserless": "latest"
"browserless": "latest",
"nyc": "latest"
},
"engines": {
"node": ">= 12"
Expand All @@ -41,7 +42,7 @@
"src"
],
"scripts": {
"test": "NODE_ENV=test ava"
"test": "NODE_ENV=test nyc ava"
},
"license": "MIT",
"ava": {
Expand Down
38 changes: 38 additions & 0 deletions scripts/merge-reports
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env node

'use strict'

const { spawnSync } = require('child_process')
const makeDir = require('make-dir')
const rimraf = require('rimraf')
const glob = require('glob')
const path = require('path')

const rooPath = path.resolve(__dirname, '..')

process.chdir(rooPath)
rimraf.sync('.nyc_output')
makeDir.sync('.nyc_output')

// Merge coverage data from each package so we can generate a complete report
glob.sync('packages/*/.nyc_output').forEach(nycOutput => {
const cwd = path.dirname(nycOutput)
const { status, stderr } = spawnSync(
'nyc',
[
'merge',
'.nyc_output',
path.join(rooPath, '.nyc_output', path.basename(cwd) + '.json')
],
{
encoding: 'utf8',
shell: true,
cwd
}
)

if (status !== 0) {
console.error(stderr)
process.exit(status)
}
})

0 comments on commit ee38cb8

Please sign in to comment.