Skip to content

Commit

Permalink
Fix code coverage reporting (#1751)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc authored Jul 2, 2020
1 parent 524103a commit 579ed31
Show file tree
Hide file tree
Showing 122 changed files with 469 additions and 291 deletions.
7 changes: 1 addition & 6 deletions bamboo/unit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,4 @@ set -ex
. ./bamboo/abort-if-not-pr.sh
docker ps -a ## Show running containers for output logs

# Run unit tests (excluding integration/api tests)
docker exec -i ${container_id}\_build_env_1 /bin/bash -c "cd $UNIT_TEST_BUILD_DIR; nyc ./node_modules/.bin/lerna run test --ignore @cumulus/api --ignore @cumulus/cumulus-integration-tests"
# Run api tests
docker exec -i ${container_id}\_build_env_1 /bin/bash -c "cd $UNIT_TEST_BUILD_DIR/packages/api; npm run test-coverage"
# Report combined code coverage
docker exec -i ${container_id}\_build_env_1 /bin/bash -c "cd /source; mkdir .nyc_output; cp -a $UNIT_TEST_BUILD_DIR/.nyc_output/. /source/.nyc_output/; cp -a $UNIT_TEST_BUILD_DIR/packages/api/.nyc_output/. /source/.nyc_output/; nyc report;"
docker exec -i ${container_id}\_build_env_1 /bin/bash -c "cd $UNIT_TEST_BUILD_DIR && npm run test:ci"
3 changes: 1 addition & 2 deletions docs/development/quality-and-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ repository. To create an html report, run `nyc report --reporter html` and open
the `index.html` file in the coverage folder.

To run code coverage on an individual package during development, run
`npm run test-coverage`. This will output the coverage in the terminal. An html
report can be created using `nyc report --reporter html` as described above.
`npm run test`. This will output the coverage in the terminal.

## Code quality checking

Expand Down
3 changes: 2 additions & 1 deletion example/.npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/nyc.config.js
/spec/
/scripts/tests/
/scripts/tests/
6 changes: 6 additions & 0 deletions example/nyc.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

module.exports = {
extends: '../nyc.config.js',
include: ['scripts']
};
11 changes: 6 additions & 5 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
"timeout": "15m"
},
"scripts": {
"test": "../node_modules/.bin/ava && for x in lambdas/*; do cd $x && npm run test && cd -; done",
"int-test": "../node_modules/.bin/jasmine && npm run parallel-tests",
"parallel-tests": "sh scripts/tests-parallel.sh",
"redeploy-test": "../node_modules/.bin/jasmine spec/standalone/redeployment/*.js",
"all-tests": "npm run parallel-tests && ../node_modules/.bin/jasmine && npm run redeploy-test",
"install-python-deps": "for x in lambdas/*; do cd $x && npm run install-python-deps || true && cd -; done",
"int-test": "../node_modules/.bin/jasmine && npm run parallel-tests",
"package": "for x in lambdas/*; do cd $x && npm run package && cd -; done",
"parallel-tests": "sh scripts/tests-parallel.sh",
"python-lint": "for x in lambdas/*; do cd $x && npm run python-lint && cd -; done",
"install-python-deps": "for x in lambdas/*; do cd $x && npm run install-python-deps || true && cd -; done"
"redeploy-test": "../node_modules/.bin/jasmine spec/standalone/redeployment/*.js",
"test": "../node_modules/.bin/nyc npm run test:ava && for x in lambdas/*; do cd $x && npm run test && cd -; done",
"test:ava": "../node_modules/.bin/ava"
},
"author": "Cumulus Authors",
"license": "Apache-2.0",
Expand Down
11 changes: 11 additions & 0 deletions nyc.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

const path = require('path');

module.exports = {
all: true,
clean: process.env.NYC_CLEAN !== 'false',
silent: process.env.NYC_SILENT === 'true',
'cache-dir': path.join(__dirname, 'node_modules', '.cache', 'nyc'),
'temp-dir': path.join(__dirname, '.nyc_output')
};
12 changes: 3 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"lint": "npm run lint-package-json && npm run eslint && lerna run python-lint && npm run lint-md",
"lint-md": "markdownlint docs/**/*.md docs/*.md tf-modules/**/*.md tf-modules/*.md",
"lint-package-json": "npmPkgJsonLint .",
"test": "nyc lerna run --concurrency 1 test",
"test": "rm -rf .nyc_output coverage && env NYC_CLEAN=false NYC_SILENT=true lerna run --concurrency 1 test && nyc report --reporter=text --reporter=html",
"test:ci": "rm -rf .nyc_output coverage && env NYC_CLEAN=false NYC_SILENT=true lerna run --ignore @cumulus/cumulus-integration-tests --concurrency 1 test && nyc report --reporter=text --reporter=html",
"tsc": "lerna run tsc",
"package": "lerna run package",
"bootstrap": "lerna bootstrap --no-ci --force-local && npm run package",
Expand Down Expand Up @@ -48,13 +49,6 @@
"bin": {
"build-tasks-doc": "./bin/build-tasks-doc.js"
},
"nyc": {
"exclude": [
"**/tests",
"**/test",
"packages/common/.tmp"
]
},
"keywords": [
"GIBS",
"CUMULUS",
Expand Down Expand Up @@ -120,7 +114,7 @@
"moment": "2.24.0",
"nock": "^12.0.3",
"npm-package-json-lint": "^5.1.0",
"nyc": "^14.0.0",
"nyc": "^15.1.0",
"p-all": "^3.0.0",
"p-map": "^4.0.0",
"p-retry": "^4.2.0",
Expand Down
1 change: 1 addition & 0 deletions packages/api-client/.npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/nyc.config.js
/tests/
7 changes: 7 additions & 0 deletions packages/api-client/nyc.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

module.exports = {
extends: '../../nyc.config.js',
include: ['*.js'],
'exclude-after-remap': false
};
12 changes: 3 additions & 9 deletions packages/api-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
"scripts": {
"clean": "rm -f ./*.js ./*.d.ts",
"prepare": "npm run tsc",
"test-coverage": "../../node_modules/.bin/nyc npm test",
"test": "../../node_modules/.bin/ava",
"test": "../../node_modules/.bin/nyc npm run test:ava",
"test:ava": "../../node_modules/.bin/ava",
"tsc": "../../node_modules/.bin/tsc",
"watch-test": "../../node_modules/.bin/tsc-watch --onsuccess 'npm test'"
"watch-test": "../../node_modules/.bin/tsc-watch --onsuccess 'env NYC_SILENT=true npm test'"
},
"ava": {
"files": [
Expand All @@ -34,12 +34,6 @@
"verbose": true,
"timeout": "15m"
},
"nyc": {
"exclude": [
"tests",
"test"
]
},
"author": "Cumulus Authors",
"license": "Apache-2.0",
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/api/.npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/nyc.config.js
/tests/
16 changes: 16 additions & 0 deletions packages/api/nyc.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

module.exports = {
extends: '../../nyc.config.js',
include: [
'*.js',
'app',
'bin',
'endpoints',
'es',
'lambdas',
'lib',
'migrations',
'models'
]
};
27 changes: 11 additions & 16 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
"cumulus-api": "./bin/cli.js"
},
"scripts": {
"test": "../../node_modules/.bin/ava",
"test-coverage": "../../node_modules/.bin/nyc npm test",
"build-lambda-zips": "for x in $(ls dist); do (cd dist/${x} && rm -f lambda.zip && find . | xargs node ../../../../bin/zip.js lambda.zip && echo zipped ${x}); done",
"build": "../../node_modules/.bin/webpack",
"watch": "../../node_modules/.bin/webpack --progress -w",
"serve": "LOCALSTACK_HOST=localhost LOCAL_ES_HOST=localhost NODE_ENV=test FAKE_AUTH=true cumulus-api serve",
"serve-oauth": "LOCALSTACK_HOST=localhost LOCAL_ES_HOST=localhost NODE_ENV=test cumulus-api serve",
"serve-remote": "cumulus-api serve",
"serve-dist": "LOCALSTACK_HOST=localhost NODE_ENV=test FAKE_AUTH=true cumulus-api serve-dist",
"serve-dist-oauth": "LOCALSTACK_HOST=localhost NODE_ENV=test cumulus-api serve-dist",
"serve-dist-remote": "cumulus-api serve-dist",
"reset-tables": "LOCALSTACK_HOST=localhost NODE_ENV=test FAKE_AUTH=true cumulus-api reset-tables",
"link-api-bin": "sh ./bin/link-api-bin.sh",
"package": "npm run build && npm run link-api-bin && npm run build-lambda-zips",
"build-lambda-zips": "for x in $(ls dist); do (cd dist/${x} && rm -f lambda.zip && find . | xargs node ../../../../bin/zip.js lambda.zip && echo zipped ${x}); done"
"reset-tables": "LOCALSTACK_HOST=localhost NODE_ENV=test FAKE_AUTH=true cumulus-api reset-tables",
"serve-dist-oauth": "LOCALSTACK_HOST=localhost NODE_ENV=test cumulus-api serve-dist",
"serve-dist-remote": "cumulus-api serve-dist",
"serve-dist": "LOCALSTACK_HOST=localhost NODE_ENV=test FAKE_AUTH=true cumulus-api serve-dist",
"serve-oauth": "LOCALSTACK_HOST=localhost LOCAL_ES_HOST=localhost NODE_ENV=test cumulus-api serve",
"serve-remote": "cumulus-api serve",
"serve": "LOCALSTACK_HOST=localhost LOCAL_ES_HOST=localhost NODE_ENV=test FAKE_AUTH=true cumulus-api serve",
"test:ava": "../../node_modules/.bin/ava",
"test": "../../node_modules/.bin/nyc npm run test:ava",
"watch": "../../node_modules/.bin/webpack --progress -w"
},
"ava": {
"files": [
Expand All @@ -35,11 +35,6 @@
"verbose": true,
"timeout": "15m"
},
"nyc": {
"exclude": [
"tests"
]
},
"publishConfig": {
"access": "public"
},
Expand Down
1 change: 1 addition & 0 deletions packages/aws-client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ config/authorized_keys
config/cloudformation.yml
cache-invalidation/config/runtime_config.json
/*.js
!/nyc.config.js
/*.d.ts
/lib/*.js
/lib/*.d.ts
1 change: 1 addition & 0 deletions packages/aws-client/.npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/nyc.config.js
/tests/
10 changes: 10 additions & 0 deletions packages/aws-client/nyc.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

module.exports = {
extends: '../../nyc.config.js',
include: [
'*.js',
'lib/*.js'
],
'exclude-after-remap': false
};
11 changes: 3 additions & 8 deletions packages/aws-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
},
"scripts": {
"build-docs": "npm run tsc && ../../node_modules/.bin/jsdoc2md -t templates/README.hbs *.js > README.md",
"clean": "rm -rf lib *.map *.d.ts *.js",
"prepare": "npm run tsc",
"test": "../../node_modules/.bin/ava",
"test-coverage": "../../node_modules/.bin/nyc npm test",
"test": "../../node_modules/.bin/nyc npm run test:ava",
"test:ava": "../../node_modules/.bin/ava",
"tsc": "../../node_modules/.bin/tsc",
"watch-test": "../../node_modules/.bin/tsc-watch --onsuccess 'npm test'"
},
Expand All @@ -38,12 +39,6 @@
],
"verbose": true
},
"nyc": {
"exclude": [
"tests",
"test"
]
},
"author": "Cumulus Authors",
"license": "Apache-2.0",
"dependencies": {
Expand Down
4 changes: 4 additions & 0 deletions packages/checksum/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/nyc.config.js
/src/
/templates/
/tests/
7 changes: 7 additions & 0 deletions packages/checksum/nyc.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

module.exports = {
extends: '../../nyc.config.js',
include: ['dist'],
'exclude-after-remap': false
};
15 changes: 5 additions & 10 deletions packages/checksum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,15 @@
],
"scripts": {
"build-docs": "npm run tsc && ../../node_modules/.bin/jsdoc2md -t templates/README.md.hbs ./dist/*.js > README.md",
"test": "../../node_modules/.bin/ava",
"test-coverage": "../../node_modules/.bin/nyc npm test",
"debug": "NODE_ENV=test node --inspect-brk node_modules/ava/profile.js --serial tests/*.js",
"tsc": "../../node_modules/.bin/tsc",
"prepare": "npm run tsc"
"clean": "rm -rf dist",
"prepare": "npm run tsc",
"test": "../../node_modules/.bin/nyc npm run test:ava",
"test:ava": "../../node_modules/.bin/ava",
"tsc": "../../node_modules/.bin/tsc"
},
"ava": {
"timeout": "15m"
},
"nyc": {
"exclude": [
"tests"
]
},
"keywords": [
"CUMULUS"
],
Expand Down
1 change: 1 addition & 0 deletions packages/cmr-client/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/*.d.ts
/*.js
!/nyc.config.js
1 change: 1 addition & 0 deletions packages/cmr-client/.npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/nyc.config.js
/tests/
7 changes: 7 additions & 0 deletions packages/cmr-client/nyc.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

module.exports = {
extends: '../../nyc.config.js',
include: ['*.js'],
'exclude-after-remap': false
};
12 changes: 3 additions & 9 deletions packages/cmr-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,16 @@
"scripts": {
"build-docs": "../../node_modules/.bin/jsdoc2md --heading-depth 2 --template templates/API.hbs CMR.js CMRSearchConceptQueue.js > API.md",
"clean": "rm -f ./*.js ./*.d.ts",
"debug": "NODE_ENV=test node --inspect-brk node_modules/ava/profile.js --serial tests/*.js",
"prepare": "npm run tsc",
"test-coverage": "../../node_modules/.bin/nyc npm test",
"test": "../../node_modules/.bin/ava",
"test": "../../node_modules/.bin/nyc npm run test:ava",
"test:ava": "../../node_modules/.bin/ava",
"tsc": "../../node_modules/.bin/tsc",
"watch-test": "../../node_modules/.bin/tsc-watch --onsuccess 'npm test'"
"watch-test": "../../node_modules/.bin/tsc-watch --onsuccess 'npm test:ava'"
},
"ava": {
"fail-fast": true,
"timeout": "15m"
},
"nyc": {
"exclude": [
"tests"
]
},
"keywords": [
"CUMULUS"
],
Expand Down
1 change: 1 addition & 0 deletions packages/cmrjs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/*.d.ts
/*.js
!/nyc.config.js
1 change: 1 addition & 0 deletions packages/cmrjs/.npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/nyc.config.js
/tests/
7 changes: 7 additions & 0 deletions packages/cmrjs/nyc.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

module.exports = {
extends: '../../nyc.config.js',
include: ['*.js'],
'exclude-after-remap': false
};
9 changes: 2 additions & 7 deletions packages/cmrjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,15 @@
"scripts": {
"clean": "rm -f ./*.js ./*.d.ts",
"prepare": "npm run tsc",
"test-coverage": "../../node_modules/.bin/nyc npm test",
"test": "../../node_modules/.bin/ava",
"test": "../../node_modules/.bin/nyc npm run test:ava",
"test:ava": "../../node_modules/.bin/ava",
"tsc": "../../node_modules/.bin/tsc",
"watch-test": "../../node_modules/.bin/tsc-watch --onsuccess 'npm test'"
},
"ava": {
"serial": true,
"timeout": "15m"
},
"nyc": {
"exclude": [
"tests"
]
},
"keywords": [
"CUMULUS"
],
Expand Down
1 change: 1 addition & 0 deletions packages/collection-config-store/.npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/nyc.config.js
/tests/
6 changes: 6 additions & 0 deletions packages/collection-config-store/nyc.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

module.exports = {
extends: '../../nyc.config.js',
include: ['*.js']
};
Loading

0 comments on commit 579ed31

Please sign in to comment.