diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..838bc63 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +name: CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build-and-test: + runs-on: ubuntu-latest + strategy: + matrix: + go: ['1.25'] # TODO: Test different versions + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go }} # Use the version from the matrix + cache: true + + - name: Verify dependencies + run: | + go mod download + go mod tidy + git diff --exit-code + + - name: Build + run: go build -v ./... + + - name: Vet + run: go vet ./... + + - name: Run unit tests + run: go test -v ./... + + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@2025.1.1 + + - name: Run staticcheck + run: $(go env GOPATH)/bin/staticcheck ./... + + - name: Run tests with coverage + run: | + go test ./... -race -coverprofile=coverage.out -covermode=atomic + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + files: coverage.out + flags: unittests + fail_ci_if_error: true diff --git a/README.md b/README.md index 925b5b6..60539d7 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +[![Go Reference](https://pkg.go.dev/badge/github.com/arunksaha/gdsu.svg)](https://pkg.go.dev/github.com/arunksaha/gdsu) +[![Go Report Card](https://goreportcard.com/badge/github.com/arunksaha/gdsu)](https://goreportcard.com/report/github.com/arunksaha/gdsu) +![Build](https://github.com/arunksaha/gdsu/actions/workflows/ci.yml/badge.svg) + + + # gdsu — Generic Disjoint Set Union (Union-Find) `gdsu` is a modern, type-safe, composable Disjoint Set Union (DSU) / Union-Find Go library.