Skip to content

Commit

Permalink
chore(frontend): add code coverage (#80)
Browse files Browse the repository at this point in the history
* chore(frontend): use Codecov for test coverage

* chore(frontend): add Codecov badge

* chore(frontend): use Codecov token

* chore(frontend): run validation for main branch to get base coverage

* chore(frontend): add working directory for Codecov action

* chore(frontend): attempt to set the working directory for Codecov
  • Loading branch information
Lodin authored Sep 1, 2021
1 parent bd4c9d0 commit b009a6b
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 9 deletions.
31 changes: 26 additions & 5 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: Frontend CI

on:
push:
branches: [main]
paths:
- '.github/workflows/frontend.yml'
- 'frontend/**/*'
- '!frontend/.simple-git-hooks.json'
- '!frontend/.lintstagedrc.json'
pull_request:
paths:
- '.github/workflows/frontend.yml'
Expand All @@ -27,13 +34,27 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: 16.x
- name: Installation
- name: Install
run: npm ci
- name: Building
- name: Build
run: npm run build
- name: Linting
- name: Lint
run: npm run check
- name: Testing
run: npm run test
- name: Test
run: npm run test:coverage
env:
CI: true
- name: Collect Coverage
run: |
echo "${{ github.workspace }}/frontend"
COVFILES=$(find packages -wholename '*/.coverage/lcov.info' | tr '\n' ',' | sed '$s/,$//')
echo "COVFILES=$COVFILES" >> $GITHUB_ENV
- name: Send Coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ env.COVFILES }}
flags: unittests
fail_ci_if_error: true
verbose: true
working-directory: ${{ github.workspace }}/frontend
1 change: 1 addition & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ packages/*/*.d.ts
packages/*/*.d.ts.map
packages/*/*.js
packages/*/*.js.map
packages/*/.coverage
3 changes: 3 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Vaadin Frontend

![Frontend CI](https://github.com/vaadin/fusion/actions/workflows/frontend.yml/badge.svg)
[![codecov](https://codecov.io/gh/vaadin/fusion/branch/main/graph/badge.svg?token=PQMTMS8ECC)](https://codecov.io/gh/vaadin/fusion)

The collection of frontend utilities used by Vaadin Flow and Fusion.

| Package | Status |
Expand Down
2 changes: 1 addition & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"postinstall": "npm run bootstrap",
"publish": "lerna publish",
"test": "lerna run test",
"test:coverage": "lerna run test:coverage",
"typecheck": "lerna run typecheck"
},
"repository": {
Expand Down
3 changes: 2 additions & 1 deletion frontend/packages/common-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"build": "tsc --isolatedModules",
"lint": "eslint --fix src/**/*.ts",
"test": "web-test-runner \"test/**/*.test.ts\" --config ../../web-test-runner.config.js",
"test:watch": "yarn run test -- --watch",
"test:coverage": "npm run test -- --coverage",
"test:watch": "npm run test -- --watch",
"typecheck": "tsc --noEmit"
},
"exports": {
Expand Down
3 changes: 2 additions & 1 deletion frontend/packages/form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"build": "tsc --isolatedModules",
"lint": "eslint --fix src/**/*.ts",
"test": "web-test-runner \"test/**/*.test.ts\" --config ../../web-test-runner.config.js",
"test:watch": "yarn run test -- --watch",
"test:coverage": "npm run test -- --coverage",
"test:watch": "npm run test -- --watch",
"typecheck": "tsc --noEmit"
},
"exports": {
Expand Down
3 changes: 2 additions & 1 deletion frontend/packages/fusion-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"build": "tsc --isolatedModules",
"lint": "eslint --fix src/**/*.ts",
"test": "web-test-runner \"test/**/*.test.ts\" --config ../../web-test-runner.config.js",
"test:watch": "yarn run test -- --watch",
"test:coverage": "npm run test -- --coverage",
"test:watch": "npm run test -- --watch",
"typecheck": "tsc --noEmit"
},
"exports": {
Expand Down
11 changes: 11 additions & 0 deletions frontend/web-test-runner.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default {
browserStartTimeout: 60000, // default 30000
testsStartTimeout: 60000, // default 10000
testsFinishTimeout: 60000, // default 20000
preserveSymlinks: true,
plugins: [
esbuildPlugin({ ts: true, target: 'auto' }),
{
Expand All @@ -42,4 +43,14 @@ export default {
},
}),
],
coverageConfig: {
report: true,
reportDir: '.coverage',
threshold: {
statements: 70,
branches: 70,
functions: 70,
lines: 70,
},
},
};

0 comments on commit b009a6b

Please sign in to comment.