From ed70b1148945a48ae0133238d6e4f7264e9b974d Mon Sep 17 00:00:00 2001 From: Nagizaaz Shaik <176337212+shaikn6@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:55:32 -0400 Subject: [PATCH] build: add CI workflow and fix flaky compaction test No GitHub Actions workflow existed. Adds one running go build, go vet and go test -race with a coverage summary on push and PR. TestCompactionDuringConcurrentUse signalled its compaction goroutine to stop with close(stop) but never joined it, so the goroutine could call Compact() after s.Close() and fail intermittently with 'store is closed' (failed ~5 of 6 runs without -race). Join it with a WaitGroup before Close. Passes 6/6 without -race and under -race. --- .github/workflows/ci.yml | 28 ++++++++++++++++++++++++++++ internal/memory/durability_test.go | 4 ++++ 2 files changed, 32 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..993b1ef --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,28 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: "1.26.4" + cache: true + - run: go build ./... + - run: go vet ./... + - run: go test ./... -count=1 -race -coverprofile=coverage.out + - name: Coverage summary + run: go tool cover -func=coverage.out | tail -1 diff --git a/internal/memory/durability_test.go b/internal/memory/durability_test.go index 930ad04..413bee7 100644 --- a/internal/memory/durability_test.go +++ b/internal/memory/durability_test.go @@ -259,10 +259,13 @@ func TestCompactionDuringConcurrentUse(t *testing.T) { s := open(t, Options{JournalPath: path, CompactAfter: 20}) const workers, rounds = 8, 120 var wg sync.WaitGroup + var compactWG sync.WaitGroup var mu sync.Mutex kept := 0 stop := make(chan struct{}) + compactWG.Add(1) go func() { + defer compactWG.Done() for { select { case <-stop: @@ -314,6 +317,7 @@ func TestCompactionDuringConcurrentUse(t *testing.T) { } wg.Wait() close(stop) + compactWG.Wait() // join the compactor before Close so it cannot call Compact on a closed store st := s.Stats() if st.Memories != kept || st.Updates != workers*rounds || st.JournalErrors != 0 { t.Fatalf("stats = %+v, want %d memories and %d updates", st, kept, workers*rounds)