From c825151639271466063637b3408a621eb36405bd Mon Sep 17 00:00:00 2001 From: Kamaleshwar Date: Sat, 5 Oct 2024 09:00:04 +0200 Subject: [PATCH 1/6] [-] Updated Github workflow for coverage --- .github/workflows/go.yml | 42 +++++++++++++++++++++++++--------------- README.md | 4 +++- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 2577f88..2ff05bc 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -4,24 +4,34 @@ name: Go on: - push: - branches: ["main"] - pull_request: - branches: ["main"] + push: + branches: ["main"] + pull_request: + branches: ["main"] jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: "1.23" + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.23" - - name: Build - run: go build -v ./... + - name: Build + run: go build -v ./... - - name: Test - run: go test -v ./... + - name: Test + run: go test -v ./... + + - name: Go coverage report + uses: ncruces/go-coverage-report@v0 + with: + report: true + chart: true + amend: true + if: | + github.event_name == 'push' + continue-on-error: true diff --git a/README.md b/README.md index 5fd9aba..4252c11 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@

pocache gopher

[![](https://github.com/naughtygopher/pocache/actions/workflows/go.yml/badge.svg?branch=main)](https://github.com/naughtygopher/pocache/actions) -[![](https://godoc.org/github.com/nathany/looper?status.svg)](http://godoc.org/github.com/naughtygopher/pocache) +[![Go Reference](https://pkg.go.dev/badge/github.com/naughtygopher/pocache.svg)](https://pkg.go.dev/github.com/naughtygopher/pocache) +[![Go Report Card](https://goreportcard.com/badge/github.com/naughtygopher/pocache)](https://goreportcard.com/report/github.com/naughtygopher/pocache) +[![Go Coverage](https://github.com/naughtygopher/REPO/wiki/coverage.svg)](https://raw.githack.com/wiki/naughtygopher/pocache/coverage.html) # Pocache From 1e2333c437b1d52500c86509b771c285d213c470 Mon Sep 17 00:00:00 2001 From: Kamaleshwar Date: Sat, 5 Oct 2024 09:01:48 +0200 Subject: [PATCH 2/6] checking workflow without if --- .github/workflows/go.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 2ff05bc..9b66f68 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -32,6 +32,7 @@ jobs: report: true chart: true amend: true - if: | - github.event_name == 'push' + # if: | + # github.base_ref == 'main' && + # github.event_name == 'push' continue-on-error: true From 2315be3692386738ff0df910153d369b98412d52 Mon Sep 17 00:00:00 2001 From: Kamaleshwar Date: Sat, 5 Oct 2024 09:02:57 +0200 Subject: [PATCH 3/6] disable amend wiki --- .github/workflows/go.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 9b66f68..24aa80f 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -31,7 +31,6 @@ jobs: with: report: true chart: true - amend: true # if: | # github.base_ref == 'main' && # github.event_name == 'push' From 317c2b91dd9a7a33dcb3c8fe42d49afa733ec9bc Mon Sep 17 00:00:00 2001 From: Kamaleshwar Date: Sat, 5 Oct 2024 09:16:43 +0200 Subject: [PATCH 4/6] coverall integration --- .github/workflows/go.yml | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 24aa80f..c0c70d9 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -26,12 +26,21 @@ jobs: - name: Test run: go test -v ./... - - name: Go coverage report - uses: ncruces/go-coverage-report@v0 + - name: Check out code + uses: actions/checkout@v2 + - name: Install dependencies + run: | + go mod download + - name: Run Unit tests + run: | + go test -race -covermode atomic -coverprofile=covprofile ./... + - name: Install goveralls + run: go install github.com/mattn/goveralls@latest + # - name: Send coverage + # env: + # COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # run: goveralls -coverprofile=covprofile -service=github + - name: Send coverage + uses: shogo82148/actions-goveralls@v1 with: - report: true - chart: true - # if: | - # github.base_ref == 'main' && - # github.event_name == 'push' - continue-on-error: true + path-to-profile: covprofile From 18a3dedb38a84820961f5f7838d3c426fa6e9214 Mon Sep 17 00:00:00 2001 From: Kamaleshwar Date: Sat, 5 Oct 2024 09:22:55 +0200 Subject: [PATCH 5/6] minor changes in workflow --- .github/workflows/go.yml | 15 +-------------- README.md | 2 +- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index c0c70d9..44bc671 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -23,23 +23,10 @@ jobs: - name: Build run: go build -v ./... - - name: Test - run: go test -v ./... - - - name: Check out code - uses: actions/checkout@v2 - - name: Install dependencies - run: | - go mod download - name: Run Unit tests run: | + go install github.com/mattn/goveralls@latest go test -race -covermode atomic -coverprofile=covprofile ./... - - name: Install goveralls - run: go install github.com/mattn/goveralls@latest - # - name: Send coverage - # env: - # COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # run: goveralls -coverprofile=covprofile -service=github - name: Send coverage uses: shogo82148/actions-goveralls@v1 with: diff --git a/README.md b/README.md index 4252c11..7c1cea6 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![](https://github.com/naughtygopher/pocache/actions/workflows/go.yml/badge.svg?branch=main)](https://github.com/naughtygopher/pocache/actions) [![Go Reference](https://pkg.go.dev/badge/github.com/naughtygopher/pocache.svg)](https://pkg.go.dev/github.com/naughtygopher/pocache) [![Go Report Card](https://goreportcard.com/badge/github.com/naughtygopher/pocache)](https://goreportcard.com/report/github.com/naughtygopher/pocache) -[![Go Coverage](https://github.com/naughtygopher/REPO/wiki/coverage.svg)](https://raw.githack.com/wiki/naughtygopher/pocache/coverage.html) +[![Coverage Status](https://coveralls.io/repos/github/naughtygopher/pocache/badge.svg?branch=main)](https://coveralls.io/github/naughtygopher/pocache?branch=main) # Pocache From 566b3aca9d57b319839cfb71c078df253ed31e8d Mon Sep 17 00:00:00 2001 From: Kamaleshwar Date: Sat, 5 Oct 2024 09:26:40 +0200 Subject: [PATCH 6/6] push coverage report only if merged --- .github/workflows/go.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 44bc671..df85e2a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -23,7 +23,7 @@ jobs: - name: Build run: go build -v ./... - - name: Run Unit tests + - name: Tests run: | go install github.com/mattn/goveralls@latest go test -race -covermode atomic -coverprofile=covprofile ./... @@ -31,3 +31,4 @@ jobs: uses: shogo82148/actions-goveralls@v1 with: path-to-profile: covprofile + if: github.event.pull_request.merged