Skip to content

Commit bf64c12

Browse files
authored
Add GitHub CI (#29)
This needn’t preclude using Evergreen for CI later.
1 parent 46bae63 commit bf64c12

File tree

5 files changed

+79
-6
lines changed

5 files changed

+79
-6
lines changed

.github/workflows/all.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
on:
2+
push:
3+
branches:
4+
- '*'
5+
tags-ignore:
6+
- '*'
7+
pull_request:
8+
9+
jobs:
10+
basics:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os:
15+
- runsOn: macos-latest
16+
mongodb_distro: mongodb-macos-arm64
17+
18+
- runsOn: ubuntu-latest
19+
mongodb_distro: mongodb-linux-x86_64-ubuntu1804
20+
21+
go_version:
22+
23+
# This is hard-coded by design in order to catch inadvertent changes
24+
# to the minimum-required Go version to build migration-verifier.
25+
- 1.19
26+
- stable
27+
28+
runs-on: ${{matrix.os.runsOn}}
29+
30+
steps:
31+
- name: Check out repository
32+
uses: actions/checkout@v4
33+
34+
- name: Fetch Go ${{ matrix.go_version }}
35+
uses: actions/setup-go@v5
36+
with:
37+
go-version: ${{ matrix.go_version }}
38+
39+
- name: Build
40+
run: go build main/migration_verifier.go
41+
42+
- name: Test
43+
run: go test -v ./...
44+
env:
45+
MONGODB_DISTRO: ${{matrix.os.mongodb_distro}}

.github/workflows/lint.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
on:
2+
push:
3+
branches:
4+
- '*'
5+
tags-ignore:
6+
- '*'
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
# Optional: allow read access to pull request. Use with `only-new-issues` option.
12+
# pull-requests: read
13+
14+
jobs:
15+
golangci:
16+
name: lint
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-go@v5
21+
with:
22+
go-version: stable
23+
- name: golangci-lint
24+
uses: golangci/golangci-lint-action@v6
25+
with:
26+
version: v1.60

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/10gen/migration-verifier
22

3-
go 1.18
3+
go 1.19
44

55
require (
66
github.com/deckarep/golang-set/v2 v2.3.0

internal/verifier/pprof.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ func (verifier *Verifier) MaybeStartPeriodicHeapProfileCollection(ctx context.Co
3232
func collectHeapUsage() {
3333
heapFileName := fmt.Sprintf("heap-%s.out", time.Now().UTC().Format("20060102T150405Z"))
3434
heapFile, err := os.Create(heapFileName)
35-
defer heapFile.Close()
3635

3736
if err != nil {
3837
panic(err)
3938
}
4039

40+
defer heapFile.Close()
41+
4142
err = pprof.Lookup("heap").WriteTo(heapFile, 0)
4243
if err != nil {
4344
panic(err)

main/migration_verifier.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,11 @@ func handleArgs(ctx context.Context, cCtx *cli.Context) (*verifier.Verifier, err
212212
v.SetNumWorkers(cCtx.Int(numWorkers))
213213
v.SetGenerationPauseDelayMillis(time.Duration(cCtx.Int64(generationPauseDelay)))
214214
v.SetWorkerSleepDelayMillis(time.Duration(cCtx.Int64(workerSleepDelay)))
215-
v.SetPprofInterval(cCtx.String(pprofInterval))
215+
216+
err = v.SetPprofInterval(cCtx.String(pprofInterval))
217+
if err != nil {
218+
return nil, err
219+
}
216220

217221
partitionSizeMB := cCtx.Uint64(partitionSizeMB)
218222
if partitionSizeMB != 0 {
@@ -226,9 +230,6 @@ func handleArgs(ctx context.Context, cCtx *cli.Context) (*verifier.Verifier, err
226230
v.SetStartClean(cCtx.Bool(startClean))
227231
logPath := cCtx.String(logPath)
228232
v.SetLogger(logPath)
229-
if err != nil {
230-
return nil, err
231-
}
232233
if cCtx.Bool(verifyAll) {
233234
if len(cCtx.StringSlice(srcNamespace)) > 0 || len(cCtx.StringSlice(dstNamespace)) > 0 {
234235
return nil, errors.Errorf("Setting both verifyAll and explicit namespaces is not supported")

0 commit comments

Comments
 (0)