diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..299b290 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -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 ./... diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml new file mode 100644 index 0000000..02c0ba9 --- /dev/null +++ b/.github/workflows/pre-commit.yaml @@ -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 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..cbfe9f6 --- /dev/null +++ b/.github/workflows/release.yaml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..044690f --- /dev/null +++ b/.pre-commit-config.yaml @@ -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 diff --git a/README.md b/README.md index 6dec4b4..63106ef 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/ringbuffer_bench_test.go b/ringbuffer_bench_test.go index 98c0412..624d33e 100644 --- a/ringbuffer_bench_test.go +++ b/ringbuffer_bench_test.go @@ -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() } } @@ -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) } }() @@ -33,7 +33,7 @@ func BenchmarkRingBufferSingleProducerSingleConsumer(b *testing.B) { defer wg.Done() for i := 0; i < b.N; i++ { - r.PopFront() + _, _ = r.PopFront() } }()