Skip coveralls in 'npm test' if not configured

This commit is contained in:
John Whitlock 2022-10-07 10:38:07 -05:00
Родитель 4651ba3dbd
Коммит f3c34bbf59
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 082C735D154FB750
3 изменённых файлов: 29 добавлений и 6 удалений

Просмотреть файл

@ -158,13 +158,11 @@ the `OAUTH_CLIENT_SECRET` value from someone in #fxmonitor-engineering.
## Testing
The full test suite can be run via `npm test`.
The full test suite can be run via `npm test`.
At the beginning of a test suite run, the `test-blurts` database will be populated with test tables and seed data found in `db/seeds/`
At the end of a test suite run, coverage info will be sent to [Coveralls](https://coveralls.io/) to assess coverage changes and provide a neat badge. For this step to complete locally, you need a root `.coveralls.yml` which contains a token – get this from another member of the Monitor team. Alternatively, without the token you can simply ignore the `coveralls` error.
*TODO:* Disable Coveralls step for local testing?
At the end of a test suite run in CircleCI, coverage info will be sent to [Coveralls](https://coveralls.io/) to assess coverage changes and provide a neat badge. To upload coverage locally, you need a root `.coveralls.yml` which contains a token – get this from another member of the Monitor team.
### Individual tests
@ -234,4 +232,4 @@ If you encounter issues with Heroku deploys, be sure to check your environment v
A banner has been added to inform users whether their IP address is being masked by Mozilla VPN. It also uses their IP address to demonstrate geolocation. This can inform users why they might use Mozilla VPN for privacy.
The IP location data includes GeoLite2 data created by MaxMind, available from https://www.maxmind.com. For localhost, a test MaxMind database with limited data is included with this repo. For the Heroku Dev site, the following buildpack is used to enable geolocation: https://github.com/HiMamaInc/heroku-buildpack-geoip-geolite2. For stage and prod environments, a shared database is set via env vars.
The IP location data includes GeoLite2 data created by MaxMind, available from https://www.maxmind.com. For localhost, a test MaxMind database with limited data is included with this repo. For the Heroku Dev site, the following buildpack is used to enable geolocation: https://github.com/HiMamaInc/heroku-buildpack-geoip-geolite2. For stage and prod environments, a shared database is set via env vars.

Просмотреть файл

@ -92,12 +92,13 @@
"fix:css": "stylelint public/css/ --fix",
"test:db:migrate": "NODE_ENV=tests knex migrate:latest --knexfile db/knexfile.js --env tests",
"test:tests": "NODE_ENV=tests HIBP_THROTTLE_DELAY=1000 HIBP_THROTTLE_MAX_TRIES=3 jest --runInBand --coverage tests/",
"test:is_coveralls_configured": "node scripts/is_coveralls_configured.js",
"test:coveralls": "cat ./coverage/lcov.info | coveralls",
"test:integration": "wdio tests/integration/wdio.conf.js",
"test:integration-headless": "MOZ_HEADLESS=1 wdio tests/integration/wdio.conf.js",
"test:integration-headless-ci": "MOZ_HEADLESS=1 ERROR_SHOTS=1 wdio tests/integration/wdio.conf.js",
"test:integration-docker": "MOZ_HEADLESS=1 wdio tests/integration/wdio.docker.js",
"test": "npm run test:db:migrate && npm run test:tests && npm run test:coveralls"
"test": "npm run test:db:migrate && npm run test:tests && (npm run test:is_coveralls_configured && npm run test:coveralls || echo 'Skipping coveralls.')"
},
"workspaces": [
"src"

Просмотреть файл

@ -0,0 +1,24 @@
'use strict'
/*
Check if coveralls configuration is available.
Exit 0 if configured to run coveralls
Exit 1 if coveralls will fail
For required environment variables, see:
https://github.com/nickmerwin/node-coveralls
Coveralls for Ruby also supports .coveralls.yml
*/
const { existsSync } = require('node:fs')
if (process.env.COVERALLS_REPO_TOKEN) {
console.log('coveralls configured with environment variable COVERALLS_REPO_TOKEN.')
process.exit(0)
} else if (existsSync('.coveralls.yml')) {
console.log('coveralls configured with configuration file ".coveralls.yml".')
} else {
console.log('coveralls is not configured.')
process.exit(1)
}