Skip to content

Commit

Permalink
Stop build if coverage is lower than main (#5300)
Browse files Browse the repository at this point in the history
  • Loading branch information
youngbupark authored Mar 17, 2023
1 parent e4df6c3 commit e501872
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ jobs:
COLOR=green
fi
DIFF_RATE=$(echo "$UT_COVERAGE-$MAIN_COVERAGE" | bc -l)
echo "diff_coverage=$DIFF_RATE" >> $GITHUB_ENV
echo "coverage_img=https://img.shields.io/badge/coverage-$UT_COVERAGE%25-$COLOR" >> $GITHUB_ENV
# copy coverage to cache
cp ./dist/ut_coverage.txt ./dist/cache/
Expand Down Expand Up @@ -147,8 +150,14 @@ jobs:
* Your PR branch coverage: ${{ env.ut_coverage }} %
* main branch coverage: ${{ env.main_coverage }} %
* diff coverage: ${{ env.diff_coverage }} %
> The coverage result does not include the functional test coverage.
- name: Stop build if PR branch coverage is lower than main branch.
if: (env.main_coverage > env.ut_coverage) && matrix.target_arch == 'amd64' && matrix.target_os == 'linux' && github.event.pull_request
run: |
echo "stop build to prevent from merging PR because coverage is down from ${{ env.main_coverage }} % to ${{ env.ut_coverage }} %."
exit 1
- name: Save coverage (only main push)
uses: actions/cache/save@v3
if: matrix.target_arch == 'amd64' && matrix.target_os == 'linux' && github.ref == 'refs/heads/main'
Expand Down

0 comments on commit e501872

Please sign in to comment.