Skip to content

Commit

Permalink
chore: add coverage reports upload to ci config
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcamargo committed Apr 2, 2023
1 parent 1927364 commit a4768be
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 10 deletions.
60 changes: 50 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ defaults: &defaults
jobs:
install:
<<: *defaults

steps:
- checkout
- restore_cache:
Expand All @@ -30,7 +29,6 @@ jobs:

build:
<<: *defaults

steps:
- attach_workspace:
at: ~/glorious-taslonic
Expand All @@ -44,27 +42,62 @@ jobs:

format:
<<: *defaults

steps:
- attach_workspace:
at: ~/glorious-taslonic
- run:
name: Format
command: npm run format

test:
test_react:
<<: *defaults
steps:
- attach_workspace:
at: ~/glorious-taslonic
- run:
name: Test React
command: |
npm run test -w=packages/react -- --runInBand --coverage --coverageReporters=lcov && \
npm run format:coverage -w=packages/react
- persist_to_workspace:
root: "."
paths:
- "./packages/react/coverage/lcov.info"

test_vue:
<<: *defaults
steps:
- attach_workspace:
at: ~/glorious-taslonic
- run:
name: Test
command: npm run test
name: Test Vue
command: |
npm run test -w=packages/vue -- --runInBand --coverage --coverageReporters=lcov && \
npm run format:coverage -w=packages/vue
- persist_to_workspace:
root: "."
paths:
- "./packages/vue/coverage/lcov.info"

docs:
test_coverage_upload:
<<: *defaults
steps:
- attach_workspace:
at: ~/glorious-taslonic
- run:
name: Install Coveralls CLI
command: curl -L https://coveralls.io/coveralls-linux.tar.gz | tar -xz -C /usr/local/bin
- run:
name: Upload Coverage Reports
command: |
coveralls --repo-token=$COVERALLS_REPO_TOKEN && \
coveralls --file ./packages/react/coverage/lcov.info --parallel && \
coveralls --file ./packages/vue/coverage/lcov.info --parallel && \
coveralls --done
docs:
<<: *defaults
steps:
- attach_workspace:
at: ~/glorious-taslonic
Expand All @@ -78,7 +111,6 @@ jobs:

deploy:
<<: *defaults

steps:
- attach_workspace:
at: ~/glorious-taslonic
Expand All @@ -102,15 +134,23 @@ workflows:
- format:
requires:
- install
- test:
- test_react:
requires:
- install
- test_vue:
requires:
- install
- test_coverage_upload:
requires:
- test_react
- test_vue
- deploy:
requires:
- build
- docs
- format
- test
- test_react
- test_vue
filters:
branches:
only:
Expand Down
3 changes: 3 additions & 0 deletions packages/react/format-coverage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const coverageReportService = require('../../scripts/coverage-report');

coverageReportService.format('react');
1 change: 1 addition & 0 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"scripts": {
"build": "webpack",
"format": "eslint './src/**/*.js'",
"format:coverage": "node ./format-coverage.js",
"test": "jest",
"prepublishOnly": "bash ../../scripts/build-packages.sh",
"log": "conventional-changelog -i CHANGELOG.md -s --commit-path ."
Expand Down
3 changes: 3 additions & 0 deletions packages/vue/format-coverage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const coverageReportService = require('../../scripts/coverage-report');

coverageReportService.format('vue');
1 change: 1 addition & 0 deletions packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"scripts": {
"build": "webpack",
"format": "eslint './src/**/*.js'",
"format:coverage": "node ./format-coverage.js",
"test": "jest",
"prepublishOnly": "bash ../../scripts/build-packages.sh",
"log": "conventional-changelog -i CHANGELOG.md -s --commit-path ."
Expand Down
13 changes: 13 additions & 0 deletions scripts/coverage-report.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const fs = require('fs');
const path = require('path');

const _public = {};

_public.format = project => {
const basePath = `packages/${project}`;
const lcovFilepath = path.join(__dirname, `../${basePath}/coverage/lcov.info`);
const lcov = fs.readFileSync(lcovFilepath, 'utf-8');
fs.writeFileSync(lcovFilepath, lcov.replace(/SF:src\//g, `SF:${basePath}/src/`));
}

module.exports = _public;

0 comments on commit a4768be

Please sign in to comment.