From 0d64c9a51097810deb1f6c4bdf8a766671f0911e Mon Sep 17 00:00:00 2001 From: Ian Shim <100327837+ian-shim@users.noreply.github.com> Date: Sat, 14 Sep 2024 05:55:05 +0900 Subject: [PATCH] [ci] Generate unit test coverage on PR (#759) --- .github/actions/test-coverage/action.yml | 2 +- .github/pull_request_template.md | 1 + .github/workflows/unit-tests.yml | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/actions/test-coverage/action.yml b/.github/actions/test-coverage/action.yml index 1c70f8797..cbd115e7b 100644 --- a/.github/actions/test-coverage/action.yml +++ b/.github/actions/test-coverage/action.yml @@ -37,7 +37,7 @@ runs: go-version: ${{inputs.go-version}} - name: Download coverage artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: coverage path: . diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 53a5c8bea..043f61acb 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -6,6 +6,7 @@ - [ ] I've made sure the lint is passing in this PR. - [ ] I've made sure the tests are passing. Note that there might be a few flaky tests, in that case, please comment that they are not relevant. +- [ ] I've checked the new test coverage and the coverage percentage didn't drop. - Testing Strategy - [ ] Unit tests - [ ] Integration tests diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index dadf54752..6baa73770 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -46,6 +46,13 @@ jobs: name: coverage path: coverage.out + - name: Extract coverage + shell: bash + run: | + COVERAGE=$(go tool cover -func="coverage.out" | tail -1 | grep -Eo '[0-9]+\.[0-9]') + echo "coverage: $COVERAGE% of statements" + + coverage-report: name: Coverage Report needs: unit-tests