Merge pull request #349 from forta-network/forta-1339-js-bot-health-c… #243
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Unit-Test | |
on: | |
push: | |
paths: | |
- cli/** | |
- sdk/** | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "14" | |
- name: Install Dependencies | |
run: npm install | |
- name: Run the tests | |
run: npm run js:coverage | |
- name: Code coverage | |
id: coverage | |
run: | | |
echo "total=$(sed -n 47p coverage/lcov-report/index.html | awk -F '>' '{print $2}' | awk -F '%' '{print $1}')" >> $GITHUB_OUTPUT | |
- name: Checkout master branch | |
uses: actions/checkout@v2 | |
with: | |
ref: master | |
path: master | |
- name: Master branch code coverage | |
id: master-coverage | |
run: | | |
npm install | |
npm run js:coverage | |
echo "total=$(sed -n 47p coverage/lcov-report/index.html | awk -F '>' '{print $2}' | awk -F '%' '{print $1}')" >> $GITHUB_OUTPUT | |
working-directory: ./master | |
- name: Coverage threshold check | |
run: | | |
COVERAGE=${{ steps.coverage.outputs.total }} | |
MASTER_COVERAGE=${{ steps.master-coverage.outputs.total }} | |
COVERAGE_THRESHOLD=${{ vars.COVERAGE_THRESHOLD }} | |
if (( $(echo "$MASTER_COVERAGE - $COVERAGE > $COVERAGE_THRESHOLD" | bc -l) )) ; then | |
echo "coverage fell by more than $COVERAGE_THRESHOLD%" | |
exit 1 | |
fi |