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
49 changes: 49 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build & Test

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
GOLANG_VERSION: "1.23.3"

jobs:
build-and-test:
name: Go
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694 # v4.0.0

- name: Setup Golang
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version: ${{ env.GOLANG_VERSION }}

- name: Download all Go modules
run: |
go mod download

- name: Check for tidiness of go.mod and go.sum
run: |
go mod tidy
git diff --exit-code -- .

- name: Check for tidiness of example code
run: |
cd example
go mod tidy
git diff --exit-code -- .

- name: Run golangci-lint
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
with:
version: v1.63.4
args: --verbose

- name: Run all unit tests
run: go test -v -race ./...
18 changes: 18 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Pre-commit

on:
pull_request:
branches:
- main

permissions:
contents: read

jobs:
preCommitValidation:
name: Pre Commit Validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694 # v4.0.0

- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.1.0
20 changes: 20 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Create release from new tag

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694 # v4.0.0

- name: Create GitHub release from tag
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1
with:
generate_release_notes: true
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-added-large-files
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ A simple example of lock-free single producer, single consumer:
go run example/spsc/main.go
```

## Contributing

Feel free to fork or clone this repository, explore the code, and contribute by submitting pull requests. Contributions, whether they’re bug fixes, improvements, or new features, are always welcome!

## License

Distributed under the GPLv3 License. See `LICENSE.md` file for more information.
8 changes: 4 additions & 4 deletions ringbuffer_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ func BenchmarkRingBuffer(b *testing.B) {
r := NewRingBuffer[int](uint64(b.N))
b.ResetTimer()
for i := 0; i < b.N; i++ {
r.PushBack(i)
r.PopFront()
_ = r.PushBack(i)
_, _ = r.PopFront()
}
}

Expand All @@ -24,7 +24,7 @@ func BenchmarkRingBufferSingleProducerSingleConsumer(b *testing.B) {
defer wg.Done()

for i := 0; i < b.N; i++ {
r.PushBack(i)
_ = r.PushBack(i)
}
}()

Expand All @@ -33,7 +33,7 @@ func BenchmarkRingBufferSingleProducerSingleConsumer(b *testing.B) {
defer wg.Done()

for i := 0; i < b.N; i++ {
r.PopFront()
_, _ = r.PopFront()
}
}()

Expand Down
Loading