From a4590d628a5ce5ade0e6721fe7f318ed051949d4 Mon Sep 17 00:00:00 2001 From: "max.rodionov" Date: Tue, 19 Nov 2019 22:39:27 +0300 Subject: [PATCH] chore: setup jest coverage + ci integration(codecov.io) --- .editorconfig | 3 +++ .github/workflows/nodejs.yml | 14 +++++++++++--- .gitignore | 3 ++- README.md | 4 +++- jest.config.js | 4 +++- package.json | 2 +- tsconfig.json | 2 +- 7 files changed, 24 insertions(+), 8 deletions(-) diff --git a/.editorconfig b/.editorconfig index 556af51a..38a47bc0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,5 +10,8 @@ trim_trailing_whitespace = true [package.json,*.yml] indent_size = 2 +[*.yml] +indent_size = 2 + max_line_length = 100 \ No newline at end of file diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index eaa88209..9a598570 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -13,11 +13,19 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Use Node.js ${{ matrix.node-version }} + + - name: use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} + + - name: npm install global packages + run: npm install -g codecov + - name: npm ci run: npm ci - - name: npm run pre-push(lint/build/e2e) - run: npm run pre-push \ No newline at end of file + - name: lint, test, build, then e2e + run: npm run pre-push + + - name: send coverage to codecov.io + run: codecov --token="${{ secrets.CODECOV_IO_TOKEN }}" --branch="${GITHUB_REF#refs/heads/}" diff --git a/.gitignore b/.gitignore index ab03d840..f9a83cf2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .vscode/ node_modules/ -dist/ \ No newline at end of file +dist/ +reports/ \ No newline at end of file diff --git a/README.md b/README.md index 7f9ba4b7..1b913128 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Actions Status](https://github.com/rodmax/react-playground/workflows/ci/badge.svg)](https://github.com/rodmax/react-playground/actions) [![Greenkeeper badge](https://badges.greenkeeper.io/rodmax/react-playground.svg)](https://greenkeeper.io/) +[![codecov](https://codecov.io/gh/rodmax/react-playground/branch/master/graph/badge.svg)](https://codecov.io/gh/rodmax/react-playground) The main purpose of this project is to study web applications development based on react stack @@ -14,7 +15,8 @@ The main purpose of this project is to study web applications development based - [x] Sass + PostCSS(autoprefixer and friends) - Quality: - [x] CI: base on [github actions](https://github.com/rodmax/react-playground/actions) - - [ ] CI: code coverage badge + - [ ] [CI: code coverage](https://codecov.io/gh/rodmax/react-playground) + - [ ] [CI: sonar cloud analyzer](https://sonarcloud.io/dashboard?id=rodmax_react-playground) - [x] E2E testing: testcafe - [x] unit & international testing: jest + testing-library - [ ] jest: code coverage diff --git a/jest.config.js b/jest.config.js index 0e8df3e5..674c4228 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,5 +1,5 @@ /** - * @type { jest.ProjectConfig } + * @type { jest.GlobalConfig } */ module.exports = { roots: ['src'], @@ -16,4 +16,6 @@ module.exports = { tsConfig: './src/tsconfig.json', }, }, + collectCoverageFrom: ['./src/app/**'], + coverageDirectory: './reports', } diff --git a/package.json b/package.json index 8608dadb..6e07c361 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "lint:all": "run-p -ln eslint stylelint", "prettier:fix": "prettier --check --write './*.js'", "jest:watch": "jest --watch", - "jest": "jest", + "jest": "jest --coverage", "testcafe:prod": "E2E_MODE=prod testcafe --app 'npm run app:serve'", "testcafe:live": "E2E_MODE=dev testcafe chrome --live", "pre-commit": "run-p -ln lint:all", diff --git a/tsconfig.json b/tsconfig.json index 1f95b4b1..18c1d6af 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -41,7 +41,7 @@ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ - "types": [], /* Type declaration files to be included in compilation. */ + // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just type checking. */ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */