The intended behavior of the bracketed [github], [bower], [discord] service names in the pull request title is to trigger the designated service tests. That way, affected services can be proven working during code review, without needing to run tests on a dev machine, nor running all the slow (and flaky) service tests. Example pull request titles: - [Travis] Fix timeout issues - [Travis Sonar] Support user token authentication - [CRAN CPAN CTAN] Add test coverage The observed behavior is that, whenever bracketed service names are provided, all of the service tests run. This is due to a Mocha limitation, which is that exclusive tests (it.only and describe.only) can only be applied synchronously. In other words, if we try to fetch the PR title and then add exclusive tests in the callback, all the tests will run anyway. This is true even when using _mocha --delay, as we are, and is true whether I use request or node-fetch. Undoubtedly this could be fixed, though it's not worth it. The problem is obscure and therefore low priority for Mocha, which is quite backlogged. And, there is an easy workaround, which is to generate the list of services to test in a separate process. The pull request script test:services:pr is now split into two parts. First the :prepare script infers the pull request context, fetches the PR title, and writes the list of affected services to a file. Then the :run script reads the list of affected services and runs the appropriate tests. In addition to sidestepping the Mocha bug, this setup makes it easier to reason about and debug these two steps of the test runner on a dev machine, and since I can't get pipefail to work – and want to be able to run the steps separately – I'm not using Node's built in pre scripts. Overall, separating these concerns this makes the test runner easier to reason about.
89 lines
2.6 KiB
JSON
89 lines
2.6 KiB
JSON
{
|
|
"name": "gh-badges",
|
|
"version": "1.3.0",
|
|
"description": "Official Shields.io badge library.",
|
|
"keywords": [
|
|
"GitHub",
|
|
"badge",
|
|
"SVG",
|
|
"image",
|
|
"shields.io"
|
|
],
|
|
"homepage": "http://shields.io",
|
|
"bugs": {
|
|
"url": "https://github.com/badges/shields/issues",
|
|
"email": "thaddee.tyl@gmail.com"
|
|
},
|
|
"license": "CC0-1.0",
|
|
"author": "Thaddée Tyl <thaddee.tyl@gmail.com>",
|
|
"main": "lib/badge.js",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "https://github.com/badges/shields"
|
|
},
|
|
"dependencies": {
|
|
"camp": "~16.2.3",
|
|
"chrome-web-store-item-property": "~1.1.2",
|
|
"dot": "~1.0.3",
|
|
"pretty-bytes": "^3.0.1",
|
|
"gm": "^1.23.0",
|
|
"json-autosave": "~1.1.2",
|
|
"pdfkit": "~0.8.0",
|
|
"redis": "~2.6.2",
|
|
"request": "~2.81.0",
|
|
"semver": "~5.3.0",
|
|
"svgo": "~0.7.1",
|
|
"xml2js": "~0.4.16"
|
|
},
|
|
"scripts": {
|
|
"coverage:test:js": "istanbul cover node_modules/mocha/bin/_mocha '*.spec.js' 'lib/*.spec.js' --dir coverage/js",
|
|
"coverage:test:services": "istanbul cover node_modules/mocha/bin/_mocha service-tests/runner/cli.js --dir coverage/services -- --delay",
|
|
"coverage:test": "npm run coverage:test:js && npm run coverage:test:services",
|
|
"coverage:report": "istanbul report",
|
|
"coverage:report:reopen": "opn coverage/lcov-report/index.html",
|
|
"coverage:report:open": "npm run coverage:report && npm run coverage:report:reopen",
|
|
"lint": "eslint '**/*.js'",
|
|
"test:js": "mocha lib '*.spec.js'",
|
|
"test:services": "mocha --delay service-tests/runner/cli.js",
|
|
"test:services:pr:prepare": "node service-tests/runner/pull-request-services-cli.js > pull-request-services.log",
|
|
"test:services:pr:run": "mocha --delay service-tests/runner/cli.js --stdin < pull-request-services.log",
|
|
"test:services:pr": "npm run test:services:pr:prepare && npm run test:services:pr:run",
|
|
"test": "npm run lint && npm run test:js"
|
|
},
|
|
"bin": {
|
|
"badge": "./gh-badge.js"
|
|
},
|
|
"files": [
|
|
"README.md",
|
|
"gh-badge.js",
|
|
"lib/badge.js",
|
|
"lib/colorscheme.json",
|
|
"lib/lru-cache.js",
|
|
"lib/measure-text.js",
|
|
"lib/svg-to-img.js",
|
|
"templates",
|
|
"logo"
|
|
],
|
|
"devDependencies": {
|
|
"child-process-promise": "^2.2.1",
|
|
"dejavu-fonts-ttf": "^2.37.3",
|
|
"eslint": "^3.18.0",
|
|
"glob": "^7.1.1",
|
|
"icedfrisby": "^1.2.0",
|
|
"icedfrisby-nock": "^1.0.0",
|
|
"is-png": "^1.1.0",
|
|
"is-svg": "^2.1.0",
|
|
"istanbul": "^0.4.5",
|
|
"lodash.difference": "^4.5.0",
|
|
"mocha": "^3.2.0",
|
|
"nock": "^9.0.13",
|
|
"node-fetch": "^1.6.3",
|
|
"opn-cli": "^3.1.0",
|
|
"read-all-stdin-sync": "^1.0.5",
|
|
"sinon": "^2.1.0"
|
|
},
|
|
"engines": {
|
|
"node": ">= 6"
|
|
}
|
|
}
|