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)