diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7edd82e3ae9d..b79f775d350dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,16 +37,18 @@ jobs: - name: Install dependencies run: node . install - # Run the tests + # Run the tests, but not if we're just gonna do coveralls later anyway - name: Run Tap tests - run: node . test -- -t600 -Rclassic -c + if: matrix.platform.os != 'ubuntu-latest' || matrix.node-version != '12.x' + run: node . test -- -t600 -Rbase -c env: DEPLOY_VERSION: testing # Run coverage check - name: Run coverage report - if: matrix.os == 'ubuntu-latest' && matrix.node-version == '12.x' - run: node . test -- -t600 -Rclassic -c + if: matrix.platform.os == 'ubuntu-latest' && matrix.node-version == '12.x' + # turn off --check-coverage until 100%, so CI failure is relevant + run: node . run check-coverage -- -t600 --no-check-coverage -Rbase -c env: DEPLOY_VERSION: testing COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_OPTIONAL_TOKEN }} @@ -55,5 +57,7 @@ jobs: # if: matrix.os == 'ubuntu-latest' # run: sudo PATH=$PATH $(which node) . test -- --coverage --timeout 600 + # no need to check licenses everywhere, they don't change between versions - name: Validate licenses + if: matrix.os == 'ubuntu-latest' && matrix.node-version == '12.x' run: node . run licenses diff --git a/package.json b/package.json index afd7075bbb2b4..cd85746de00c6 100644 --- a/package.json +++ b/package.json @@ -224,6 +224,7 @@ "preversion": "bash scripts/update-authors.sh && git add AUTHORS && git commit -m \"update AUTHORS\" || true", "licenses": "licensee --production --errors-only", "test": "tap", + "check-coverage": "tap", "snap": "tap", "test:nocleanup": "NO_TEST_CLEANUP=1 npm run test --", "sudotest": "sudo npm run test --", diff --git a/test/coverage-map.js b/test/coverage-map.js index 9c9dde834facd..cb2670129e9c0 100644 --- a/test/coverage-map.js +++ b/test/coverage-map.js @@ -1,6 +1,14 @@ 'use strict' +const full = process.env.npm_lifecycle_event === 'check-coverage' const coverageMap = (filename) => { + if (full && /load-all.js$/.test(filename)) { + const glob = require('glob') + const { resolve, relative } = require('path') + const dir = resolve(__dirname, '../lib') + return glob.sync(`${dir}/**/*.js`) + .map(f => relative(process.cwd(), f)) + } if (/^test\/(lib|bin)\//.test(filename)) { return filename.replace(/^test\//, '') } diff --git a/test/lib/load-all.js b/test/lib/load-all.js new file mode 100644 index 0000000000000..72879c2c4448a --- /dev/null +++ b/test/lib/load-all.js @@ -0,0 +1,30 @@ +const t = require('tap') +const glob = require('glob') +const { resolve } = require('path') + +const full = process.env.npm_lifecycle_event === 'check-coverage' + +if (!full) { + t.pass('nothing to do here, not checking for full coverage') +} else { + // some files do config.get() on load, so have to load npm first + const npm = require('../../lib/npm.js') + t.test('load npm first', t => npm.load(t.end)) + + t.test('load all the files', t => { + // just load all the files so we measure coverage for the missing tests + const dir = resolve(__dirname, '../../lib') + for (const f of glob.sync(`${dir}/**/*.js`)) { + require(f) + t.pass('loaded ' + f) + } + t.pass('loaded all files') + t.end() + }) + + t.test('call the error handle so we dont freak out', t => { + const errorHandler = require('../../lib/utils/error-handler.js') + errorHandler() + t.end() + }) +}