Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 58 additions & 48 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,20 @@ on:
jobs:
test:
name: Test
runs-on: "ubuntu-latest"

runs-on: ubuntu-latest

strategy:
matrix:
include:
- module: v1
path: .
- module: v2
path: v2

defaults:
run:
working-directory: ${{ matrix.path }}

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -26,7 +38,7 @@ jobs:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ubuntu-latest-go-1.24-${{ hashFiles('**/go.sum') }}
key: ubuntu-latest-go-1.24-${{ hashFiles(format('{0}/go.sum', matrix.path)) }}
restore-keys: |
ubuntu-latest-go-1.24-

Expand Down Expand Up @@ -55,6 +67,19 @@ jobs:
benchmark:
name: Benchmark
runs-on: ubuntu-latest

strategy:
matrix:
include:
- module: v1
path: .
- module: v2
path: v2

defaults:
run:
working-directory: ${{ matrix.path }}

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -70,7 +95,7 @@ jobs:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ubunsu-latest-go-1.24-${{ hashFiles('**/go.sum') }}
key: ubuntu-latest-go-1.24-${{ hashFiles(format('{0}/go.sum', matrix.path)) }}
restore-keys: |
ubunsu-latest-go-1.24-

Expand All @@ -83,6 +108,19 @@ jobs:
coverage:
name: Coverage Check
runs-on: ubuntu-latest

strategy:
matrix:
include:
- module: v1
path: .
- module: v2
path: v2

defaults:
run:
working-directory: ${{ matrix.path }}

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -98,7 +136,7 @@ jobs:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ubuntu-latest-go-1.24-${{ hashFiles('**/go.sum') }}
key: ubuntu-latest-go-1.24-${{ hashFiles(format('{0}/go.sum', matrix.path)) }}
restore-keys: |
ubuntu-latest-go-1.24-

Expand Down Expand Up @@ -138,6 +176,7 @@ jobs:
- name: Update coverage badge
uses: ncruces/go-coverage-report@main
with:
output-dir: ${{matrix.module}}
coverage-file: coverage.out
report: true
chart: true
Expand All @@ -149,7 +188,7 @@ jobs:
if: github.event_name == 'pull_request'
run: |
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print substr($3, 1, length($3)-1)}')
echo "## 📊 Coverage Report" > coverage_comment.md
echo "## 📊 ${{matrix.module}} Coverage Report" > coverage_comment.md
echo "" >> coverage_comment.md
echo "**Total Coverage: $COVERAGE%**" >> coverage_comment.md
echo "" >> coverage_comment.md
Expand All @@ -167,6 +206,19 @@ jobs:
lint:
name: Lint
runs-on: ubuntu-latest

strategy:
matrix:
include:
- module: v1
path: .
- module: v2
path: v2

defaults:
run:
working-directory: ${{ matrix.path }}

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -181,45 +233,3 @@ jobs:
with:
version: latest
args: --timeout=5m

security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24'

- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: '-no-fail -fmt sarif -out results.sarif ./...'

- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif

notify:
name: Notify
runs-on: ubuntu-latest
needs: [test, benchmark, coverage, lint, security]
if: always()
steps:
- name: Notify success
if: needs.test.result == 'success' && needs.coverage.result == 'success' && needs.lint.result == 'success'
run: echo "✅ All checks passed!"

- name: Notify failure
if: needs.test.result == 'failure' || needs.coverage.result == 'failure' || needs.lint.result == 'failure'
run: |
echo "❌ Some checks failed:"
echo "Tests: ${{ needs.test.result }}"
echo "Coverage: ${{ needs.coverage.result }}"
echo "Lint: ${{ needs.lint.result }}"
echo "Security: ${{ needs.security.result }}"
exit 1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)
[![CI](https://github.com/floatdrop/debounce/actions/workflows/ci.yaml/badge.svg)](https://github.com/floatdrop/debounce/actions/workflows/ci.yaml)
[![Go Report Card](https://goreportcard.com/badge/github.com/floatdrop/debounce)](https://goreportcard.com/report/github.com/floatdrop/debounce)
[![Go Coverage](https://github.com/floatdrop/debounce/wiki/coverage.svg)](https://raw.githack.com/wiki/floatdrop/debounce/coverage.html)
[![Go Coverage](https://github.com/floatdrop/debounce/wiki/v2/coverage.svg)](https://raw.githack.com/wiki/floatdrop/debounce/v2/coverage.html)
[![Go Reference](https://pkg.go.dev/badge/github.com/floatdrop/debounce/v2.svg)](https://pkg.go.dev/github.com/floatdrop/debounce/v2)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Expand Down
2 changes: 1 addition & 1 deletion v2/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func ExampleDebouncer_Func() {
debouncer()
debouncer()
time.Sleep(time.Second)
fmt.Println(counter)
fmt.Println(atomic.LoadInt32(&counter))
// Output: 1
}

Expand Down
Loading