From 3a87f943fab41f04b22404235896830a3caf6667 Mon Sep 17 00:00:00 2001 From: Arun Saha Date: Tue, 25 Nov 2025 20:51:54 -0800 Subject: [PATCH 1/5] Added badges in README; added ci.yml --- .github/workflows/ci.yml | 48 ++++++++++++++++++++++++++++++++++++++++ README.md | 6 +++++ 2 files changed, 54 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c97fc5c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,48 @@ +name: CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.25" + + - name: Verify dependencies + run: go mod tidy && git diff --exit-code + + - name: Build + run: go build ./... + + - name: Vet + run: go vet ./... + + - name: Run tests + run: go test -v ./... + + - name: Run staticcheck + uses: dominikh/staticcheck-action@v1 + with: + version: "2024.1.1" + + - 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 \ No newline at end of file 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. From c5a75b1833885b38603ef633519f0840470d865f Mon Sep 17 00:00:00 2001 From: Arun Saha Date: Tue, 25 Nov 2025 20:56:44 -0800 Subject: [PATCH 2/5] ci.yml dominikh/staticcheck-action upgraded to v1.4.0 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c97fc5c..79eacc2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: run: go test -v ./... - name: Run staticcheck - uses: dominikh/staticcheck-action@v1 + uses: dominikh/staticcheck-action@v1.4.0 with: version: "2024.1.1" From b54e41622f05a26a0c71225a0516aa9363f927ec Mon Sep 17 00:00:00 2001 From: Arun Saha Date: Tue, 25 Nov 2025 21:08:35 -0800 Subject: [PATCH 3/5] tweak ci.yml --- .github/workflows/ci.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79eacc2..29f4a98 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,9 @@ on: jobs: build-and-test: runs-on: ubuntu-latest + strategy: + matrix: + go: ['1.25'] # TODO: Test different versions steps: - name: Checkout code @@ -17,18 +20,22 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "1.25" + go-version: ${{ matrix.go }} # Use the version from the matrix + cache: true - name: Verify dependencies - run: go mod tidy && git diff --exit-code + run: | + go mod download + go mod tidy + git diff --exit-code - name: Build - run: go build ./... + run: go build -v ./... - name: Vet run: go vet ./... - - name: Run tests + - name: Run unit tests run: go test -v ./... - name: Run staticcheck From a76e672262448e2983a9bc549331b38a80615615 Mon Sep 17 00:00:00 2001 From: Arun Saha Date: Tue, 25 Nov 2025 21:22:30 -0800 Subject: [PATCH 4/5] more ci.yml tweaks --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 29f4a98..0058499 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,10 @@ jobs: uses: dominikh/staticcheck-action@v1.4.0 with: version: "2024.1.1" + env: + # staticcheck 2024.1.1 is built with an older toolchain; force a + # supported Go version to avoid build failures on Go 1.25. + GOTOOLCHAIN: go1.22.9 - name: Run tests with coverage run: | @@ -52,4 +56,4 @@ jobs: with: files: coverage.out flags: unittests - fail_ci_if_error: true \ No newline at end of file + fail_ci_if_error: true From 375320e2278d4667d8ebab4b2db8a3fa8fd1af55 Mon Sep 17 00:00:00 2001 From: Arun Saha Date: Tue, 25 Nov 2025 21:29:53 -0800 Subject: [PATCH 5/5] further tweak ci.yml to install staticcheck --- .github/workflows/ci.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0058499..838bc63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,14 +38,11 @@ jobs: - 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 - uses: dominikh/staticcheck-action@v1.4.0 - with: - version: "2024.1.1" - env: - # staticcheck 2024.1.1 is built with an older toolchain; force a - # supported Go version to avoid build failures on Go 1.25. - GOTOOLCHAIN: go1.22.9 + run: $(go env GOPATH)/bin/staticcheck ./... - name: Run tests with coverage run: |