diff --git a/.github/workflows/all.yml b/.github/workflows/all.yml new file mode 100644 index 00000000..acc83985 --- /dev/null +++ b/.github/workflows/all.yml @@ -0,0 +1,45 @@ +on: + push: + branches: + - '*' + tags-ignore: + - '*' + pull_request: + +jobs: + basics: + strategy: + fail-fast: false + matrix: + os: + - runsOn: macos-latest + mongodb_distro: mongodb-macos-arm64 + + - runsOn: ubuntu-latest + mongodb_distro: mongodb-linux-x86_64-ubuntu1804 + + go_version: + + # This is hard-coded by design in order to catch inadvertent changes + # to the minimum-required Go version to build migration-verifier. + - 1.19 + - stable + + runs-on: ${{matrix.os.runsOn}} + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Fetch Go ${{ matrix.go_version }} + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go_version }} + + - name: Build + run: go build main/migration_verifier.go + + - name: Test + run: go test -v ./... + env: + MONGODB_DISTRO: ${{matrix.os.mongodb_distro}} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..2e178708 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,26 @@ +on: + push: + branches: + - '*' + tags-ignore: + - '*' + pull_request: + +permissions: + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + # pull-requests: read + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: stable + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.60 diff --git a/go.mod b/go.mod index 5f8c6bbe..9c2f62b0 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/10gen/migration-verifier -go 1.18 +go 1.19 require ( github.com/deckarep/golang-set/v2 v2.3.0 diff --git a/internal/verifier/pprof.go b/internal/verifier/pprof.go index 1ffc3371..01d737b1 100644 --- a/internal/verifier/pprof.go +++ b/internal/verifier/pprof.go @@ -32,12 +32,13 @@ func (verifier *Verifier) MaybeStartPeriodicHeapProfileCollection(ctx context.Co func collectHeapUsage() { heapFileName := fmt.Sprintf("heap-%s.out", time.Now().UTC().Format("20060102T150405Z")) heapFile, err := os.Create(heapFileName) - defer heapFile.Close() if err != nil { panic(err) } + defer heapFile.Close() + err = pprof.Lookup("heap").WriteTo(heapFile, 0) if err != nil { panic(err) diff --git a/main/migration_verifier.go b/main/migration_verifier.go index 4289eb5d..cb5a6320 100644 --- a/main/migration_verifier.go +++ b/main/migration_verifier.go @@ -212,7 +212,11 @@ func handleArgs(ctx context.Context, cCtx *cli.Context) (*verifier.Verifier, err v.SetNumWorkers(cCtx.Int(numWorkers)) v.SetGenerationPauseDelayMillis(time.Duration(cCtx.Int64(generationPauseDelay))) v.SetWorkerSleepDelayMillis(time.Duration(cCtx.Int64(workerSleepDelay))) - v.SetPprofInterval(cCtx.String(pprofInterval)) + + err = v.SetPprofInterval(cCtx.String(pprofInterval)) + if err != nil { + return nil, err + } partitionSizeMB := cCtx.Uint64(partitionSizeMB) if partitionSizeMB != 0 { @@ -226,9 +230,6 @@ func handleArgs(ctx context.Context, cCtx *cli.Context) (*verifier.Verifier, err v.SetStartClean(cCtx.Bool(startClean)) logPath := cCtx.String(logPath) v.SetLogger(logPath) - if err != nil { - return nil, err - } if cCtx.Bool(verifyAll) { if len(cCtx.StringSlice(srcNamespace)) > 0 || len(cCtx.StringSlice(dstNamespace)) > 0 { return nil, errors.Errorf("Setting both verifyAll and explicit namespaces is not supported")