Skip to content

Commit

Permalink
Add Coveralls to package.json [1/2] (#21017)
Browse files Browse the repository at this point in the history
Summary:
Adds a new step to the test suite. Test coverage is now collected and sent to Coveralls.

Initial configuration is limited to the Libraries/ and local-cli/ directories. Please let me know if additional directories should be considered.

I have enabled this repo on the coveralls service. The coveralls token has been added to React Native's Circle CI environment variables.

- Track coverage on PRs, and fail PRs that lower the coverage %
- Increase coverage :)

[INTERNAL] [ENHANCEMENT] [.circleci/config.yml] - Start tracking code coverage (JS)

Pull Request resolved: #21017

Differential Revision: D9724396

Pulled By: hramos

fbshipit-source-id: 61da4478877805f9a9a3c9670b54ddc4e40e958b
  • Loading branch information
hramos authored and facebook-github-bot committed Dec 1, 2018
1 parent 0f3be77 commit 69e9c9d
Show file tree
Hide file tree
Showing 3 changed files with 204 additions and 144 deletions.
28 changes: 28 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ aliases:
./scripts/circleci/validate_yarn_lockfile.sh
when: always

- &js-coverage
name: Test coverage
command: |
yarn test --coverage --maxWorkers=2
cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
when: always

- &download-dependencies-gradle
name: Download Dependencies Using Gradle
command: ./scripts/circleci/gradle_download_deps.sh
Expand Down Expand Up @@ -626,6 +633,17 @@ jobs:
when: always
- save-cache: *save-cache-analysis

# Test Coverage
js_coverage:
<<: *js_defaults
steps:
- checkout
- restore-cache: *restore-yarn-cache
- run: *yarn
- run: *js-coverage
- store_artifacts:
path: ~/react-native/coverage/

# Publishes new version onto npm
# Only works on stable branches when a properly tagged commit is pushed
publish_npm_package:
Expand Down Expand Up @@ -720,6 +738,8 @@ workflows:
- test_node10:
filters: *filter-ignore-gh-pages

releases:
jobs:
# Only runs on vX.X.X tags if all tests are green
- publish_npm_package:
filters:
Expand All @@ -730,8 +750,16 @@ workflows:
tags:
only: /v[0-9]+(\.[0-9]+)*(\-rc(\.[0-9]+)?)?/

analysis:
jobs:
# Run code checks on PRs from forks
- analyze_pr:
filters:
branches:
only: /^pull\/.*$/

# Gather coverage on master
- js_coverage:
filters:
branches:
only: master
13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,17 @@
"denodeify",
"fbjs"
],
"testEnvironment": "node"
"testEnvironment": "node",
"collectCoverageFrom": [
"Libraries/**/*.js",
"local-cli/**/*.js"
],
"coveragePathIgnorePatterns": [
"/__tests__/",
"/vendor/",
"<rootDir>/Libraries/react-native/",
"<rootDir>/local-cli/templates/"
]
},
"main": "Libraries/react-native/react-native-implementation.js",
"files": [
Expand Down Expand Up @@ -212,6 +222,7 @@
"babel-eslint": "9.0.0",
"babel-generator": "^6.26.0",
"detox": "9.0.4",
"coveralls": "^3.0.2",
"eslint": "5.1.0",
"eslint-config-fb-strict": "22.1.0",
"eslint-config-fbjs": "2.0.1",
Expand Down
Loading

0 comments on commit 69e9c9d

Please sign in to comment.