Skip to content

Commit

Permalink
Enable Minimum code coverage check (#8)
Browse files Browse the repository at this point in the history
* use PR base ref branch

* remove cache to simplify workflow

* remove data folder use real coverage

* rename to use base and compare branches

* improve descriptions

* check if minimum-coverage-ratio is no exist

* use zero minimum-coverage-ratio

* add log messages and tests for code coverage min Ration

* fix minimum ratio feature enable condition

* use toFixed(2) for diff

* add log messages

* comment tests to check coverage

* refactor tests running

* use another command for master

* set workflow failed

* uncomment tests
  • Loading branch information
vitaliimelnychuk authored Dec 31, 2020
1 parent c51e59d commit 819cabe
Show file tree
Hide file tree
Showing 14 changed files with 199 additions and 708 deletions.
31 changes: 5 additions & 26 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
name: Code Coverage

on:
push:
branches:
- master
pull_request:
on: [pull_request]

jobs:
base_branch_cov:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
#TODO: uncommend after merge to master
# with:
# ref: master
with:
ref: ${{ github.base_ref }}
- name: Use Node.js 12.13.1
uses: actions/setup-node@v1
with:
node-version: 12.13.1
- name: Cache node modules
uses: actions/cache@v1
with:
path: node_modules
key: node_modules-v1-${{ hashFiles('yarn.lock') }}
# loading an older version is fine here, since it will get an npm install
restore-keys: |
node_modules-

- name: Install dependencies
run: yarn
Expand All @@ -48,14 +35,6 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: 12.13.1
- name: Cache node modules
uses: actions/cache@v1
with:
path: node_modules
key: node_modules-v1-${{ hashFiles('yarn.lock') }}
# loading an older version is fine here, since it will get an npm install
restore-keys: |
node_modules-

- name: Download math result for job 2
uses: actions/download-artifact@v2
Expand All @@ -66,7 +45,7 @@ jobs:
run: yarn

- name: Run test coverage
run: yarn coverage-lcov
run: yarn coverage

# Testing beta of code coverage checks
# This part can be removed or optimized once barecheck code coverage will be out of beta
Expand All @@ -76,5 +55,5 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
lcov-file: './coverage/lcov.info'
head-lcov-file: './lcov.info'
base-lcov-file: './lcov.info'
minimum-coverage-ratio: 0
8 changes: 8 additions & 0 deletions .nycrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"check-coverage": false,
"extension": [".js"],
"include": ["src/**/*.js"],
"exclude": ["coverage/**", "node_modules/**", "**/*.test.js"],
"reporter": ["html", "text", "text-summary", "lcov"],
"all": true
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"javascript.validate.enable": false
}
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ inputs:
description: Your GitHub secret token
required: true
lcov-file:
description: 'Path where code coverage artifacts located'
description: 'Compare code coverage report'
required: true
default: './coverage/lcov.info'
head-lcov-file:
description: 'Code coverage head branch report to compare with'
base-lcov-file:
description: 'Base code coverage report to generate percentage diff'
required: true
default: ''
minimum-coverage-ratio:
Expand Down
Loading

0 comments on commit 819cabe

Please sign in to comment.