From 6d4296e18f3c344bb0dec195f6639be50f1a1f7d Mon Sep 17 00:00:00 2001 From: Vsevolod Strukchinsky Date: Fri, 20 Jun 2025 12:59:08 +0500 Subject: [PATCH 1/4] Add coverage badge --- .github/workflows/ci.yaml | 26 +++++++++++++++++++++++++- README.md | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ab7129e..c03fb10 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,5 +17,29 @@ jobs: - name: Build run: go build -v ./... - name: Test with the Go CLI - run: go test + run: | + go test -v ./... -covermode=count -coverprofile=coverage.out + go tool cover -func=coverage.out -o=coverage.out + - name: Go Coverage Badge # Pass the `coverage.out` output to this action + uses: tj-actions/coverage-badge-go@v2 + with: + filename: coverage.out + - name: Verify Changed files + uses: tj-actions/verify-changed-files@v16 + id: verify-changed-files + with: + files: README.md + - name: Commit changes + if: steps.verify-changed-files.outputs.files_changed == 'true' + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add README.md + git commit -m "chore: Updated coverage badge." + - name: Push changes + if: steps.verify-changed-files.outputs.files_changed == 'true' + uses: ad-m/github-push-action@master + with: + github_token: ${{ github.token }} + branch: ${{ github.head_ref }} \ No newline at end of file diff --git a/README.md b/README.md index 6375d10..203501d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # RingChan [![CI](https://github.com/floatdrop/ringchan/actions/workflows/ci.yaml/badge.svg)](https://github.com/floatdrop/ringchan/actions/workflows/ci.yaml) +![Coverage](https://img.shields.io/badge/Coverage-100.0-brightgreen) [![Go Report Card](https://goreportcard.com/badge/github.com/floatdrop/ringchan)](https://goreportcard.com/report/github.com/floatdrop/ringchan) [![Go Reference](https://pkg.go.dev/badge/github.com/floatdrop/ringchan.svg)](https://pkg.go.dev/github.com/floatdrop/ringchan) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) From 21c35a23bb1d3db9b7f86eb49e59296c50e8fcae Mon Sep 17 00:00:00 2001 From: Vsevolod Strukchinsky Date: Fri, 20 Jun 2025 13:14:37 +0500 Subject: [PATCH 2/4] Use push --- .github/workflows/ci.yaml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c03fb10..1a888f9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,17 +29,12 @@ jobs: id: verify-changed-files with: files: README.md - - name: Commit changes + - name: Commit and push changes if: steps.verify-changed-files.outputs.files_changed == 'true' run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" git add README.md git commit -m "chore: Updated coverage badge." - - name: Push changes - if: steps.verify-changed-files.outputs.files_changed == 'true' - uses: ad-m/github-push-action@master - with: - github_token: ${{ github.token }} - branch: ${{ github.head_ref }} + git push \ No newline at end of file From 44a72f0620fb670479451f7bcda634f8a3a5e911 Mon Sep 17 00:00:00 2001 From: Vsevolod Strukchinsky Date: Fri, 20 Jun 2025 13:15:12 +0500 Subject: [PATCH 3/4] Use ref --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1a888f9..dcc27ea 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,6 +8,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} - name: Setup Go uses: actions/setup-go@v5 with: From 0c6895392a140eccd48ea43119f676a2a47f9e4f Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Fri, 20 Jun 2025 08:15:40 +0000 Subject: [PATCH 4/4] chore: Updated coverage badge. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 203501d..cd8c58e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # RingChan [![CI](https://github.com/floatdrop/ringchan/actions/workflows/ci.yaml/badge.svg)](https://github.com/floatdrop/ringchan/actions/workflows/ci.yaml) -![Coverage](https://img.shields.io/badge/Coverage-100.0-brightgreen) +![Coverage](https://img.shields.io/badge/Coverage-90.9%25-brightgreen) [![Go Report Card](https://goreportcard.com/badge/github.com/floatdrop/ringchan)](https://goreportcard.com/report/github.com/floatdrop/ringchan) [![Go Reference](https://pkg.go.dev/badge/github.com/floatdrop/ringchan.svg)](https://pkg.go.dev/github.com/floatdrop/ringchan) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)