Skip to content

Commit c784f3a

Browse files
authored
Compute coverage for v2 (#13)
1 parent 34d86c6 commit c784f3a

3 files changed

Lines changed: 60 additions & 50 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 58 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,20 @@ on:
99
jobs:
1010
test:
1111
name: Test
12-
runs-on: "ubuntu-latest"
13-
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
include:
17+
- module: v1
18+
path: .
19+
- module: v2
20+
path: v2
21+
22+
defaults:
23+
run:
24+
working-directory: ${{ matrix.path }}
25+
1426
steps:
1527
- name: Checkout code
1628
uses: actions/checkout@v4
@@ -26,7 +38,7 @@ jobs:
2638
path: |
2739
~/.cache/go-build
2840
~/go/pkg/mod
29-
key: ubuntu-latest-go-1.24-${{ hashFiles('**/go.sum') }}
41+
key: ubuntu-latest-go-1.24-${{ hashFiles(format('{0}/go.sum', matrix.path)) }}
3042
restore-keys: |
3143
ubuntu-latest-go-1.24-
3244
@@ -55,6 +67,19 @@ jobs:
5567
benchmark:
5668
name: Benchmark
5769
runs-on: ubuntu-latest
70+
71+
strategy:
72+
matrix:
73+
include:
74+
- module: v1
75+
path: .
76+
- module: v2
77+
path: v2
78+
79+
defaults:
80+
run:
81+
working-directory: ${{ matrix.path }}
82+
5883
steps:
5984
- name: Checkout code
6085
uses: actions/checkout@v4
@@ -70,7 +95,7 @@ jobs:
7095
path: |
7196
~/.cache/go-build
7297
~/go/pkg/mod
73-
key: ubunsu-latest-go-1.24-${{ hashFiles('**/go.sum') }}
98+
key: ubuntu-latest-go-1.24-${{ hashFiles(format('{0}/go.sum', matrix.path)) }}
7499
restore-keys: |
75100
ubunsu-latest-go-1.24-
76101
@@ -83,6 +108,19 @@ jobs:
83108
coverage:
84109
name: Coverage Check
85110
runs-on: ubuntu-latest
111+
112+
strategy:
113+
matrix:
114+
include:
115+
- module: v1
116+
path: .
117+
- module: v2
118+
path: v2
119+
120+
defaults:
121+
run:
122+
working-directory: ${{ matrix.path }}
123+
86124
steps:
87125
- name: Checkout code
88126
uses: actions/checkout@v4
@@ -98,7 +136,7 @@ jobs:
98136
path: |
99137
~/.cache/go-build
100138
~/go/pkg/mod
101-
key: ubuntu-latest-go-1.24-${{ hashFiles('**/go.sum') }}
139+
key: ubuntu-latest-go-1.24-${{ hashFiles(format('{0}/go.sum', matrix.path)) }}
102140
restore-keys: |
103141
ubuntu-latest-go-1.24-
104142
@@ -138,6 +176,7 @@ jobs:
138176
- name: Update coverage badge
139177
uses: ncruces/go-coverage-report@main
140178
with:
179+
output-dir: ${{matrix.module}}
141180
coverage-file: coverage.out
142181
report: true
143182
chart: true
@@ -149,7 +188,7 @@ jobs:
149188
if: github.event_name == 'pull_request'
150189
run: |
151190
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print substr($3, 1, length($3)-1)}')
152-
echo "## 📊 Coverage Report" > coverage_comment.md
191+
echo "## 📊 ${{matrix.module}} Coverage Report" > coverage_comment.md
153192
echo "" >> coverage_comment.md
154193
echo "**Total Coverage: $COVERAGE%**" >> coverage_comment.md
155194
echo "" >> coverage_comment.md
@@ -167,6 +206,19 @@ jobs:
167206
lint:
168207
name: Lint
169208
runs-on: ubuntu-latest
209+
210+
strategy:
211+
matrix:
212+
include:
213+
- module: v1
214+
path: .
215+
- module: v2
216+
path: v2
217+
218+
defaults:
219+
run:
220+
working-directory: ${{ matrix.path }}
221+
170222
steps:
171223
- name: Checkout code
172224
uses: actions/checkout@v4
@@ -181,45 +233,3 @@ jobs:
181233
with:
182234
version: latest
183235
args: --timeout=5m
184-
185-
security:
186-
name: Security Scan
187-
runs-on: ubuntu-latest
188-
steps:
189-
- name: Checkout code
190-
uses: actions/checkout@v4
191-
192-
- name: Set up Go
193-
uses: actions/setup-go@v4
194-
with:
195-
go-version: '1.24'
196-
197-
- name: Run Gosec Security Scanner
198-
uses: securego/gosec@master
199-
with:
200-
args: '-no-fail -fmt sarif -out results.sarif ./...'
201-
202-
- name: Upload SARIF file
203-
uses: github/codeql-action/upload-sarif@v3
204-
with:
205-
sarif_file: results.sarif
206-
207-
notify:
208-
name: Notify
209-
runs-on: ubuntu-latest
210-
needs: [test, benchmark, coverage, lint, security]
211-
if: always()
212-
steps:
213-
- name: Notify success
214-
if: needs.test.result == 'success' && needs.coverage.result == 'success' && needs.lint.result == 'success'
215-
run: echo "✅ All checks passed!"
216-
217-
- name: Notify failure
218-
if: needs.test.result == 'failure' || needs.coverage.result == 'failure' || needs.lint.result == 'failure'
219-
run: |
220-
echo "❌ Some checks failed:"
221-
echo "Tests: ${{ needs.test.result }}"
222-
echo "Coverage: ${{ needs.coverage.result }}"
223-
echo "Lint: ${{ needs.lint.result }}"
224-
echo "Security: ${{ needs.security.result }}"
225-
exit 1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)
44
[![CI](https://github.com/floatdrop/debounce/actions/workflows/ci.yaml/badge.svg)](https://github.com/floatdrop/debounce/actions/workflows/ci.yaml)
55
[![Go Report Card](https://goreportcard.com/badge/github.com/floatdrop/debounce)](https://goreportcard.com/report/github.com/floatdrop/debounce)
6-
[![Go Coverage](https://github.com/floatdrop/debounce/wiki/coverage.svg)](https://raw.githack.com/wiki/floatdrop/debounce/coverage.html)
6+
[![Go Coverage](https://github.com/floatdrop/debounce/wiki/v2/coverage.svg)](https://raw.githack.com/wiki/floatdrop/debounce/v2/coverage.html)
77
[![Go Reference](https://pkg.go.dev/badge/github.com/floatdrop/debounce/v2.svg)](https://pkg.go.dev/github.com/floatdrop/debounce/v2)
88
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
99

v2/example_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func ExampleDebouncer_Func() {
2525
debouncer()
2626
debouncer()
2727
time.Sleep(time.Second)
28-
fmt.Println(counter)
28+
fmt.Println(atomic.LoadInt32(&counter))
2929
// Output: 1
3030
}
3131

0 commit comments

Comments
 (0)