From ff9cd208217985251a76677041274159347772e5 Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Sat, 17 Nov 2018 09:37:09 -0500 Subject: [PATCH] Coverage cleanup (#2328) - Stop running daily service tests in the main repo (since they're now handled [over here](https://github.com/badges/daily-tests) - Add coverage and separate daily tests badges with links to coveralls - Update our coverage ignores - Move scripts, which do not need coverage, into `scripts/` - Split out coverage test for npm package - Remove spurious env var Ref: #1584 #2314 --- .circleci/config.yml | 23 ------------------- .nycrc.json | 3 +++ README.md | 9 ++++++++ package.json | 13 ++++++----- .../benchmark-performance.sh | 0 {lib => scripts}/export-badge-examples-cli.js | 2 +- .../export-supported-features-cli.js | 0 {lib => scripts}/refactoring-cli.js | 2 +- 8 files changed, 21 insertions(+), 31 deletions(-) rename benchmark-performance.sh => scripts/benchmark-performance.sh (100%) rename {lib => scripts}/export-badge-examples-cli.js (53%) rename {lib => scripts}/export-supported-features-cli.js (100%) rename {lib => scripts}/refactoring-cli.js (93%) diff --git a/.circleci/config.yml b/.circleci/config.yml index f1605619faa6c..79e54ad033bd9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -227,19 +227,6 @@ jobs: echo 'This is not a pull request. Skipping.' fi - services-daily: - docker: - - image: shieldsio/shields-ci-node-8:0.0.3 - steps: - - checkout - - - restore_cache: - key: v1-dependencies-{{ checksum "package.json" }} - - - run: - name: Run all service tests - command: npm run test:services - workflows: version: 2 @@ -270,13 +257,3 @@ workflows: filters: branches: ignore: /dependabot\/.*/ - - daily: - triggers: - - schedule: - cron: "0 17 * * *" - filters: - branches: - only: master - jobs: - - services-daily diff --git a/.nycrc.json b/.nycrc.json index 5e8ef80f93549..b01698753e632 100644 --- a/.nycrc.json +++ b/.nycrc.json @@ -4,7 +4,10 @@ "exclude": [ "**/*.spec.js", "**/*.integration.js", + "dangerfile.js", "services/**/*.tester.js", + "test-fixtures", + "scripts", "coverage", "build" ], diff --git a/README.md b/README.md index 30b2521ac2598..0175d708eaa3c 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,12 @@ build status + + daily build status + + coverage commits to be deployed @@ -113,12 +119,15 @@ snapshots, and `SNAPSHOT_UPDATE=1 npm run test:js:server` to update them. The server can be configured to use [Sentry][] ([configuration][sentry configuration]) and [Prometheus][] ([configuration][prometheus configuration]). +Daily tests, including a full run of the service tests and overall code coverage, are run via [badges/daily-tests][daily-tests]. + [package manager]: https://nodejs.org/en/download/package-manager/ [snapshot tests]: https://glebbahmutov.com/blog/snapshot-testing/ [Prometheus]: https://prometheus.io/ [prometheus configuration]: doc/self-hosting.md#prometheus [Sentry]: https://sentry.io/ [sentry configuration]: doc/self-hosting.md#sentry +[daily-tests]: https://github.com/badges/daily-tests Hosting your own server ----------------------- diff --git a/package.json b/package.json index f5dd3cc988382..0c75f0c9f170b 100644 --- a/package.json +++ b/package.json @@ -58,11 +58,12 @@ "xpath": "~0.0.27" }, "scripts": { - "coverage:test:server": "HANDLE_INTERNAL_ERRORS=false nyc node_modules/mocha/bin/_mocha \"*.spec.js\" \"lib/**/*.spec.js\" \"gh-badges/**/*.spec.js\" \"services/**/*.spec.js\"", "coverage:test:frontend": "NODE_ENV=mocha nyc node_modules/mocha/bin/_mocha --require @babel/polyfill --require @babel/register \"frontend/**/*.spec.js\"", + "coverage:test:server": "HANDLE_INTERNAL_ERRORS=false nyc node_modules/mocha/bin/_mocha \"*.spec.js\" \"lib/**/*.spec.js\" \"services/**/*.spec.js\"", + "coverage:test:package": "nyc node_modules/mocha/bin/_mocha \"gh-badges/**/*.spec.js\"", "coverage:test:integration": "nyc node_modules/mocha/bin/_mocha \"lib/**/*.integration.js\" \"services/**/*.integration.js\"", "coverage:test:services": "nyc node_modules/mocha/bin/_mocha --delay lib/service-test-runner/cli.js", - "coverage:test": "rimraf .nyc_output coverage; npm run coverage:test:server; npm run coverage:test:frontend; npm run coverage:test:integration; npm run coverage:test:services", + "coverage:test": "rimraf .nyc_output coverage; npm run coverage:test:server; npm run coverage:test:package; npm run coverage:test:frontend; npm run coverage:test:integration; npm run coverage:test:services", "coverage:report": "nyc report", "coverage:report:reopen": "opn coverage/lcov-report/index.html", "coverage:report:open": "npm run coverage:report && npm run coverage:report:reopen", @@ -72,7 +73,7 @@ "danger": "danger", "test:js:frontend": "NODE_ENV=mocha mocha --require @babel/polyfill --require @babel/register \"frontend/**/*.spec.js\"", "test:js:server": "HANDLE_INTERNAL_ERRORS=false mocha \"*.spec.js\" \"lib/**/*.spec.js\" \"services/**/*.spec.js\"", - "test:js:package": "HANDLE_INTERNAL_ERRORS=false mocha \"gh-badges/**/*.spec.js\"", + "test:js:package": "mocha \"gh-badges/**/*.spec.js\"", "test:integration": "mocha \"lib/**/*.integration.js\" \"services/**/*.integration.js\"", "test:services": "HANDLE_INTERNAL_ERRORS=false mocha --delay lib/service-test-runner/cli.js", "test:services:trace": "TRACE_SERVICES=true npm run test:services -- $*", @@ -85,8 +86,8 @@ "depcheck": "check-node-version --node \">= 8.0\"", "postinstall": "npm run depcheck", "prebuild": "npm run depcheck", - "features": "node lib/export-supported-features-cli.js > supported-features.json", - "examples": "node lib/export-badge-examples-cli.js > badge-examples.json", + "features": "node scripts/export-supported-features-cli.js > supported-features.json", + "examples": "node scripts/export-badge-examples-cli.js > badge-examples.json", "build": "npm run examples && npm run features && next build && next export -o build/", "heroku-postbuild": "npm run build", "analyze": "ANALYZE=true LONG_CACHE=false BASE_URL=https://img.shields.io npm run build", @@ -94,7 +95,7 @@ "now-start": "node server", "prestart": "npm run depcheck && npm run examples && npm run features", "start": "concurrently --names server,frontend \"ALLOWED_ORIGIN=http://localhost:3000 npm run start:server\" \"BASE_URL=http://[::]:8080 next dev\"", - "refactoring-report": "node lib/refactoring-cli.js" + "refactoring-report": "node scripts/refactoring-cli.js" }, "lint-staged": { "**/*.js": [ diff --git a/benchmark-performance.sh b/scripts/benchmark-performance.sh similarity index 100% rename from benchmark-performance.sh rename to scripts/benchmark-performance.sh diff --git a/lib/export-badge-examples-cli.js b/scripts/export-badge-examples-cli.js similarity index 53% rename from lib/export-badge-examples-cli.js rename to scripts/export-badge-examples-cli.js index ab1ba8eb49b02..9f1d966a703bf 100644 --- a/lib/export-badge-examples-cli.js +++ b/scripts/export-badge-examples-cli.js @@ -1,5 +1,5 @@ 'use strict' -const allBadgeExamples = require('./all-badge-examples') +const allBadgeExamples = require('../lib/all-badge-examples') process.stdout.write(JSON.stringify(allBadgeExamples)) diff --git a/lib/export-supported-features-cli.js b/scripts/export-supported-features-cli.js similarity index 100% rename from lib/export-supported-features-cli.js rename to scripts/export-supported-features-cli.js diff --git a/lib/refactoring-cli.js b/scripts/refactoring-cli.js similarity index 93% rename from lib/refactoring-cli.js rename to scripts/refactoring-cli.js index 14217cbc24723..4fae5b0c37e10 100644 --- a/lib/refactoring-cli.js +++ b/scripts/refactoring-cli.js @@ -5,7 +5,7 @@ const mapValues = require('lodash.mapvalues') const colorscheme = require('../gh-badges/lib/colorscheme.json') const colorsMap = mapValues(colorscheme, 'colorB') -const { floorCount } = require('./color-formatters') +const { floorCount } = require('../lib/color-formatters') const { loadServiceClasses } = require('../services') const serviceClasses = loadServiceClasses()