diff --git a/.github/workflows/trunk.yml b/.github/workflows/trunk.yml index edfb029c9..9622f3789 100644 --- a/.github/workflows/trunk.yml +++ b/.github/workflows/trunk.yml @@ -9,6 +9,11 @@ permissions: checks: write jobs: + install-jq: + runs-on: ubuntu-latest + steps: + - name: Install jq + run: sudo apt-get update && sudo apt-get install -y jq trunk-code-quality: name: Trunk Code Quality uses: hypermodeinc/.github/.github/workflows/trunk.yml@main diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index 7aaff7db2..ad58fe30c 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -15,7 +15,7 @@ plugins: # Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes) runtimes: enabled: - - go@1.23.5 + - go@1.24.5 - node@18.20.5 - python@3.10.8 diff --git a/CHANGELOG.md b/CHANGELOG.md index 05d36674b..999fb132e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ## [Unreleased] +- chore(deps): Upgrade to Go 1.24.5 and downstream indirect packages dependencies +- chore(test): Adapt the test.sh script to run on OS-X (as well as Linux) +- chore: skip protoc generation if protoc is missing or not correct version - chore(deps): Remove dependency on github.com/pkg/errors (#2184) - chore(deps): Migrate from OpenCensus to OpenTelemetry (#2169) diff --git a/go.mod b/go.mod index 6b6836d03..127ea1146 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/google/uuid v1.6.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/spf13/pflag v1.0.6 // indirect + github.com/spf13/pflag v1.0.7 // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/otel/metric v1.37.0 // indirect go.opentelemetry.io/otel/sdk v1.37.0 // indirect diff --git a/go.sum b/go.sum index 64d8f57db..72bb17638 100644 --- a/go.sum +++ b/go.sum @@ -35,8 +35,9 @@ github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWN github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= -github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/pflag v1.0.7 h1:vN6T9TfwStFPFM5XzjsvmzZkLuaLX+HS+0SeFLRgU6M= +github.com/spf13/pflag v1.0.7/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= diff --git a/pb/gen.sh b/pb/gen.sh index f09cb24ee..53ad1a23b 100755 --- a/pb/gen.sh +++ b/pb/gen.sh @@ -1,7 +1,24 @@ #!/bin/bash # Run this script from its directory, so that badgerpb4.proto is where it's expected to -# be. +# be. Only run this script if you've made changes to the API in badgerpb4.proto. + +# Check if protoc version matches expected version first +EXPECTED_PROTOC_VERSION="3.21.12" +ACTUAL_PROTOC_VERSION=$(protoc --version 2>/dev/null | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' || true) + +if [[ ${ACTUAL_PROTOC_VERSION} != "${EXPECTED_PROTOC_VERSION}" ]]; then + echo "Warning: protoc version mismatch" + echo "Expected: ${EXPECTED_PROTOC_VERSION}" + echo "Actual: ${ACTUAL_PROTOC_VERSION:-'not found'}" + echo "Skipping generation" + exit 0 +fi go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31.0 + +# Get the GOPATH and add the bin directory to PATH +GOPATH=$(go env GOPATH) +export PATH="${GOPATH}/bin:${PATH}" + protoc --go_out=. --go_opt=paths=source_relative badgerpb4.proto diff --git a/pb/protos_test.go b/pb/protos_test.go index 37357a50c..d3df839e0 100644 --- a/pb/protos_test.go +++ b/pb/protos_test.go @@ -15,10 +15,11 @@ import ( func Exec(argv ...string) error { cmd := exec.Command(argv[0], argv[1:]...) - if err := cmd.Start(); err != nil { - return err + output, err := cmd.CombinedOutput() + if len(output) > 0 { + print(string(output)) } - return cmd.Wait() + return err } func TestProtosRegenerate(t *testing.T) { diff --git a/stream_writer_test.go b/stream_writer_test.go index ef56068ab..7f0ab5083 100644 --- a/stream_writer_test.go +++ b/stream_writer_test.go @@ -743,7 +743,6 @@ func TestStreamWriterIncremental(t *testing.T) { t.Run("multiple incremental with older data first", func(t *testing.T) { runBadgerTest(t, nil, func(t *testing.T, db *DB) { buf := z.NewBuffer(10<<20, "test") - defer func() { require.NoError(t, buf.Release()) }() KVToBuffer(&pb.KV{ Key: []byte("a1"), Value: []byte("val1"), @@ -755,7 +754,6 @@ func TestStreamWriterIncremental(t *testing.T) { require.NoError(t, sw.Flush(), "sw.Flush() failed") buf = z.NewBuffer(10<<20, "test") - defer func() { require.NoError(t, buf.Release()) }() KVToBuffer(&pb.KV{ Key: []byte("a2"), Value: []byte("val2"), @@ -766,6 +764,9 @@ func TestStreamWriterIncremental(t *testing.T) { require.NoError(t, sw.Write(buf), "sw.Write() failed") require.NoError(t, sw.Flush(), "sw.Flush() failed") + // Single defer at the end to release the final buffer + defer func() { require.NoError(t, buf.Release()) }() + // This will move the maxTs to 10 (earlier, without the fix) require.NoError(t, db.Update(func(txn *Txn) error { return txn.Set([]byte("a1"), []byte("val3")) diff --git a/test.sh b/test.sh index 5f1e9b3fc..69822f196 100755 --- a/test.sh +++ b/test.sh @@ -41,7 +41,7 @@ manual() { rm -rf p set -e go test $tags $timeout $covermode $coverprofile -run='TestTruncateVlogNoClose$' -failfast --manual=true && write_coverage || return 1 - truncate --size=4096 p/000000.vlog + dd if=/dev/null of=p/000000.vlog bs=1 seek=4096 count=0 2>/dev/null go test $tags $timeout $covermode $coverprofile -run='TestTruncateVlogNoClose2$' -failfast --manual=true && write_coverage || return 1 go test $tags $timeout $covermode $coverprofile -run='TestTruncateVlogNoClose3$' -failfast --manual=true && write_coverage || return 1 rm -rf p @@ -78,9 +78,9 @@ stream() { pushd badger baseDir=$(mktemp -d -p .) ./badger benchmark write -s --dir=$baseDir/test | tee $baseDir/log.txt - ./badger benchmark read --dir=$baseDir/test --full-scan | tee --append $baseDir/log.txt - ./badger benchmark read --dir=$baseDir/test -d=30s | tee --append $baseDir/log.txt - ./badger stream --dir=$baseDir/test -o "$baseDir/test2" | tee --append $baseDir/log.txt + ./badger benchmark read --dir=$baseDir/test --full-scan | tee -a $baseDir/log.txt + ./badger benchmark read --dir=$baseDir/test -d=30s | tee -a $baseDir/log.txt + ./badger stream --dir=$baseDir/test -o "$baseDir/test2" | tee -a $baseDir/log.txt count=$(cat "$baseDir/log.txt" | grep "at program end: 0 B" | wc -l) rm -rf $baseDir if [ $count -ne 4 ]; then