Enable code coverage in CI (#2497)

* Enable code coverage in CI

* Disable codecov comment

* Ignore some statements from coverage reports
master
Lucas Azzola 2017-07-16 21:49:37 +10:00 committed by GitHub
parent 188c466cd5
commit b7fa01af17
9 changed files with 94 additions and 17 deletions

1
.codecov.yml Normal file
View File

@ -0,0 +1 @@
comment: off

1
.gitignore vendored
View File

@ -8,3 +8,4 @@ npm-debug.log
/dist
/website/node_modules
.DS_Store
coverage

View File

@ -21,10 +21,11 @@ before_script:
script:
- yarn lint
- AST_COMPARE=1 yarn test -- --runInBand
- if [ "${NODE_ENV}" = "development" ]; then yarn codecov; fi
deploy:
provider: script
script: website/deploy.sh
skip_cleanup: true
skip_cleanup: true
on:
branch: master
node: stable

View File

@ -343,6 +343,7 @@ module.exports = {
version,
/* istanbul ignore next */
__debug: {
parse: function(text, opts) {
return parser.parse(text, opts);

17
jest.config.js Normal file
View File

@ -0,0 +1,17 @@
"use strict";
const ENABLE_COVERAGE = !!process.env.CI;
module.exports = {
setupFiles: ["<rootDir>/tests_config/run_spec.js"],
snapshotSerializers: ["<rootDir>/tests_config/raw-serializer.js"],
testRegex: "jsfmt\\.spec\\.js$|__tests__/.*\\.js$",
testPathIgnorePatterns: ["tests/new_react", "tests/more_react"],
collectCoverage: ENABLE_COVERAGE,
collectCoverageFrom: ["src/**/*.js", "index.js"],
coveragePathIgnorePatterns: [
"<rootDir>/src/doc-debug.js",
"<rootDir>/src/clean-ast.js",
"<rootDir>/src/deprecated.js"
]
};

View File

@ -41,6 +41,7 @@
"devDependencies": {
"babel-cli": "6.24.1",
"babel-preset-es2015": "6.24.1",
"codecov": "2.2.0",
"cross-env": "5.0.1",
"cross-spawn": "5.1.0",
"eslint": "4.1.1",
@ -69,18 +70,5 @@
"test-integration": "jest tests_integration",
"lint": "cross-env EFF_NO_LINK_RULES=true eslint . --format node_modules/eslint-friendly-formatter",
"build": "./scripts/build/build.js"
},
"jest": {
"setupFiles": [
"<rootDir>/tests_config/run_spec.js"
],
"snapshotSerializers": [
"<rootDir>/tests_config/raw-serializer.js"
],
"testRegex": "jsfmt\\.spec\\.js$|__tests__/.*\\.js$",
"testPathIgnorePatterns": [
"tests/new_react",
"tests/more_react"
]
}
}

View File

@ -12,9 +12,10 @@ function parse(text) {
ast = tryParseTypeScript(text, jsx);
} catch (e) {
// But if we get it wrong, try the opposite.
/* istanbul ignore next */
ast = tryParseTypeScript(text, !jsx);
}
} catch (e) {
} catch (e) /* istanbul ignore next */ {
if (typeof e.lineNumber === "undefined") {
throw e;
}

View File

@ -117,6 +117,7 @@ function genericPrint(path, options, printPath, args) {
try {
return multiparser.printSubtree(next, path, printPath, options);
} catch (error) {
/* istanbul ignore if */
if (process.env.PRETTIER_DEBUG) {
const e = new Error(error);
e.parser = next.options.parser;
@ -1230,6 +1231,7 @@ function genericPrintNoParens(path, options, print, args) {
case "DirectiveLiteral":
return nodeStr(n, options);
case "ModuleSpecifier":
/* istanbul ignore if */
if (n.local) {
throw new Error("The ESTree ModuleSpecifier type should be abstract");
}
@ -1798,6 +1800,7 @@ function genericPrintNoParens(path, options, print, args) {
case "JSXClosingElement":
return concat(["</", path.call(print, "name"), ">"]);
case "JSXText":
/* istanbul ignore next */
throw new Error("JSXTest should be handled by JSXElement");
case "JSXEmptyExpression": {
const requiresHardline =
@ -1981,6 +1984,7 @@ function genericPrintNoParens(path, options, print, args) {
case "Comment":
case "MemberTypeAnnotation": // Flow
case "Type":
/* istanbul ignore next */
throw new Error("unprintable type: " + JSON.stringify(n.type));
// Type Annotations for Facebook Flow, typically stripped out or
// transformed away before printing.
@ -2764,6 +2768,7 @@ function genericPrintNoParens(path, options, print, args) {
return '"' + n.value + '"';
default:
/* istanbul ignore next */
throw new Error("unknown type: " + JSON.stringify(n.type));
}
}

View File

@ -119,6 +119,10 @@ argparse@^1.0.7:
dependencies:
sprintf-js "~1.0.2"
argv@0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/argv/-/argv-0.0.2.tgz#ecbd16f8949b157183711b1bda334f37840185ab"
arr-diff@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf"
@ -840,6 +844,10 @@ camelcase@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-3.0.0.tgz#32fc4b9fcdaf845fcdf7e73bb97cac2261f0ab0a"
caseless@~0.11.0:
version "0.11.0"
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7"
caseless@~0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
@ -936,6 +944,14 @@ code-point-at@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
codecov@2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/codecov/-/codecov-2.2.0.tgz#2d06817ceb8891eca6368836d4fb6bf6cc04ffd1"
dependencies:
argv "0.0.2"
request "2.79.0"
urlgrey "0.4.4"
color-convert@^1.0.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.0.tgz#1accf97dd739b983bf994d56fec8f95853641b7a"
@ -952,7 +968,7 @@ combined-stream@^1.0.5, combined-stream@~1.0.5:
dependencies:
delayed-stream "~1.0.0"
commander@^2.8.1, commander@~2.9.0:
commander@^2.8.1, commander@^2.9.0, commander@~2.9.0:
version "2.9.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4"
dependencies:
@ -1709,6 +1725,15 @@ har-schema@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e"
har-validator@~2.0.6:
version "2.0.6"
resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-2.0.6.tgz#cdcbc08188265ad119b6a5a7c8ab70eecfb5d27d"
dependencies:
chalk "^1.1.1"
commander "^2.9.0"
is-my-json-valid "^2.12.4"
pinkie-promise "^2.0.0"
har-validator@~4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a"
@ -1952,7 +1977,7 @@ is-glob@^2.0.0, is-glob@^2.0.1:
dependencies:
is-extglob "^1.0.0"
is-my-json-valid@^2.16.0:
is-my-json-valid@^2.12.4, is-my-json-valid@^2.16.0:
version "2.16.0"
resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.16.0.tgz#f079dd9bfdae65ee2038aae8acbc86ab109e3693"
dependencies:
@ -3067,6 +3092,10 @@ punycode@^1.2.4, punycode@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e"
qs@~6.3.0:
version "6.3.2"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.2.tgz#e75bd5f6e268122a2a0e0bda630b2550c166502c"
qs@~6.4.0:
version "6.4.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233"
@ -3217,6 +3246,31 @@ repeating@^2.0.0:
dependencies:
is-finite "^1.0.0"
request@2.79.0:
version "2.79.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.79.0.tgz#4dfe5bf6be8b8cdc37fcf93e04b65577722710de"
dependencies:
aws-sign2 "~0.6.0"
aws4 "^1.2.1"
caseless "~0.11.0"
combined-stream "~1.0.5"
extend "~3.0.0"
forever-agent "~0.6.1"
form-data "~2.1.1"
har-validator "~2.0.6"
hawk "~3.1.3"
http-signature "~1.1.0"
is-typedarray "~1.0.0"
isstream "~0.1.2"
json-stringify-safe "~5.0.1"
mime-types "~2.1.7"
oauth-sign "~0.8.1"
qs "~6.3.0"
stringstream "~0.0.4"
tough-cookie "~2.3.0"
tunnel-agent "~0.4.1"
uuid "^3.0.0"
request@^2.79.0, request@^2.81.0:
version "2.81.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0"
@ -3740,6 +3794,10 @@ tunnel-agent@^0.6.0:
dependencies:
safe-buffer "^5.0.1"
tunnel-agent@~0.4.1:
version "0.4.3"
resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb"
tweetnacl@^0.14.3, tweetnacl@~0.14.0:
version "0.14.5"
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
@ -3800,6 +3858,10 @@ url@^0.11.0:
punycode "1.3.2"
querystring "0.2.0"
urlgrey@0.4.4:
version "0.4.4"
resolved "https://registry.yarnpkg.com/urlgrey/-/urlgrey-0.4.4.tgz#892fe95960805e85519f1cd4389f2cb4cbb7652f"
user-home@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190"