From 58e4c29e126f559aff948d6227d4a44dc72eaeac Mon Sep 17 00:00:00 2001 From: abhijit-nightfall <127822984+abhijit-nightfall@users.noreply.github.com> Date: Mon, 4 Dec 2023 13:15:57 +0530 Subject: [PATCH] [QA-184] unit test coverage report added (#21) * added octocov configuration * added GitHub workflow * increased coverage acceptable score to 89% --- .github/workflows/coverage.yml | 26 ++++++++++++++++++++++++++ .octocov.yml | 21 +++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 .github/workflows/coverage.yml create mode 100644 .octocov.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..e766eef --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,26 @@ +name: octocov +on: + push: + branches: + - master + pull_request: + +jobs: + coverage: + runs-on: ubuntu-latest + steps: + - name: Granting private modules access + run: | + git config --global url."https://${{ secrets.engbot_token }}:x-oauth-basic@github.com/watchtowerai".insteadOf "https://github.com/watchtowerai" + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 + with: + go-version-file: go.mod + - name: Run tests with coverage report output + # can skip packages with external dependencies (e.g. entity with live DB) with a command like + # ```go test $(go list ./... | grep -v entity) -coverprofile=coverage.out``` + run: go test $(go list ./... | grep -v /internal/services/entity | grep -v /internal/entities | grep -v /internal/handler | grep -v /internal/services/entity) -coverprofile=coverage.out + env: + GO_ENV: "test" + GOPRIVATE: "github.com/watchtowerai" + - uses: k1LoW/octocov-action@v0 diff --git a/.octocov.yml b/.octocov.yml new file mode 100644 index 0000000..a4ff60d --- /dev/null +++ b/.octocov.yml @@ -0,0 +1,21 @@ +coverage: + acceptable: current >= 89% +codeToTestRatio: + code: + - '**/*.go' + - '!**/*_test.go' + test: + - '**/*_test.go' +diff: + datastores: + - artifact://${GITHUB_REPOSITORY} +push: + if: is_default_branch +comment: + if: is_pull_request +summary: + if: true +report: + if: is_default_branch + datastores: + - artifact://${GITHUB_REPOSITORY}