From f2b97bf290c1921b943e96a23e94228aaa6dc580 Mon Sep 17 00:00:00 2001 From: Theofanis Petkos Date: Thu, 13 Jul 2023 15:47:29 +0100 Subject: [PATCH] Add test coverage check to CI.yaml (#13) * Add test coverage workflow Signed-off-by: thepetk * Update ci.yaml Signed-off-by: thepetk * Add separate check for code coverage Signed-off-by: thepetk * Move code report in ci file Signed-off-by: thepetk * Add .codecov.yaml Signed-off-by: thepetk * Update workflow Signed-off-by: thepetk * Bump up setup-go Signed-off-by:thepetk --------- Signed-off-by: thepetk --- .codecov.yaml | 36 ++++++++++++++++++++++++++++++++++++ .github/workflows/CI.yml | 18 +++++++++++++++++- Makefile | 2 +- 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 .codecov.yaml diff --git a/.codecov.yaml b/.codecov.yaml new file mode 100644 index 00000000..aa78ba62 --- /dev/null +++ b/.codecov.yaml @@ -0,0 +1,36 @@ +# See http://docs.codecov.io/docs/coverage-configuration +coverage: + precision: 2 # 2 = xx.xx%, 0 = xx% + round: down + # For example: 20...60 would result in any coverage less than 20% + # would have a red background. The color would gradually change to + # green approaching 60%. Any coverage over 60% would result in a + # solid green color. + range: "60...80" + + status: + # project will give us the diff in the total code coverage between a commit + # and its parent + project: yes + # Patch gives just the coverage of the patch + patch: yes + # changes tells us if there are unexpected code coverage changes in other files + # which were not changed by the diff + changes: yes + + # See http://docs.codecov.io/docs/ignoring-paths + ignore: + - "docs/*" + - ".github/*" + - "resources/*" + - "test/*" + - "Makefile" + +# See http://docs.codecov.io/docs/pull-request-comments-1 +comment: + layout: "diff, files" + behavior: "" + # default = posts once then update, posts new if delete + # once = post once then updates + # new = delete old, post new + # spammy = post new \ No newline at end of file diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 587d9ec7..2daed1ed 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -46,4 +46,20 @@ jobs: uses: github/codeql-action/upload-sarif@v2 with: # Path to SARIF file relative to the root of the repository - sarif_file: gosec.sarif \ No newline at end of file + sarif_file: gosec.sarif + + code-coverage-report: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3.5.3 + with: + persist-credentials: false + - name: Set up Go 1.x + uses: actions/setup-go@v3 + with: + go-version: 1.19 + - name: Run tests + run: make test + - name: Codecov + uses: codecov/codecov-action@v3.1.4 \ No newline at end of file diff --git a/Makefile b/Makefile index 41340709..3b02c6bb 100644 --- a/Makefile +++ b/Makefile @@ -16,4 +16,4 @@ buildWin: .PHONY: test test: - go test ./... \ No newline at end of file + go test -coverprofile cover.out -v ./... \ No newline at end of file