ci: make go compatibility check parallel

Change-Id: I40162548305dcd181cfb702f72830d2c0a887cf4
This commit is contained in:
Egon Elbre 2022-10-20 09:08:20 -04:00 committed by Storj Robot
parent 2ed18a0ed6
commit bcbf30a333
3 changed files with 96 additions and 18 deletions

View File

@ -129,15 +129,7 @@ pipeline {
steps {
// verify most of the commands, we cannot check everything since some of them
// have a C dependency and we don't have cross-compilation in storj/ci image
sh 'GOOS=linux GOARCH=386 go vet ./cmd/uplink ./cmd/satellite ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=linux GOARCH=amd64 go vet ./cmd/uplink ./cmd/satellite ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=linux GOARCH=arm go vet ./cmd/uplink ./cmd/satellite ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=linux GOARCH=arm64 go vet ./cmd/uplink ./cmd/satellite ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=windows GOARCH=386 go vet ./cmd/uplink ./cmd/satellite ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=windows GOARCH=amd64 go vet ./cmd/uplink ./cmd/satellite ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=windows GOARCH=arm64 go vet ./cmd/uplink ./cmd/satellite ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=darwin GOARCH=amd64 go vet ./cmd/uplink ./cmd/satellite ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=darwin GOARCH=arm64 go vet ./cmd/uplink ./cmd/satellite ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'go run ./scripts/go-version-compatibility -parallel 4'
}
}

View File

@ -151,15 +151,7 @@ pipeline {
steps {
// verify most of the commands, we cannot check everything since some of them
// have a C dependency and we don't have cross-compilation in storj/ci image
sh 'GOOS=linux GOARCH=386 go vet ./cmd/uplink ./cmd/satellite ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=linux GOARCH=amd64 go vet ./cmd/uplink ./cmd/satellite ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=linux GOARCH=arm go vet ./cmd/uplink ./cmd/satellite ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=linux GOARCH=arm64 go vet ./cmd/uplink ./cmd/satellite ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=windows GOARCH=386 go vet ./cmd/uplink ./cmd/satellite ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=windows GOARCH=amd64 go vet ./cmd/uplink ./cmd/satellite ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=windows GOARCH=arm64 go vet ./cmd/uplink ./cmd/satellite ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=darwin GOARCH=amd64 go vet ./cmd/uplink ./cmd/satellite ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=darwin GOARCH=arm64 go vet ./cmd/uplink ./cmd/satellite ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'go run ./scripts/go-version-compatibility -parallel 4'
}
}
stage('Tests') {

View File

@ -0,0 +1,94 @@
// Copyright (C) 2022 Storj Labs, Inc.
// See LICENSE for copying information.
package main
import (
"context"
"flag"
"fmt"
"os"
"os/exec"
"runtime"
"strings"
"storj.io/common/sync2"
)
func main() {
parallel := flag.Int("parallel", runtime.GOMAXPROCS(0), "number of compiles to run in parallel")
flag.Parse()
ctx := context.Background()
type testcase struct {
compiler string
os string
arch string
}
test := func(compiler, os, arch string) testcase {
return testcase{
compiler: compiler,
os: os,
arch: arch,
}
}
tests := []testcase{
test("go", "linux", "amd64"),
test("go", "linux", "386"),
test("go", "linux", "arm64"),
test("go", "linux", "arm"),
test("go", "windows", "amd64"),
test("go", "windows", "386"),
test("go", "windows", "arm64"),
test("go", "darwin", "amd64"),
test("go", "darwin", "arm64"),
}
type result struct {
title string
out string
err error
}
results := make([]result, len(tests))
lim := sync2.NewLimiter(*parallel)
for i, test := range tests {
i, test := i, test
lim.Go(ctx, func() {
cmd := exec.Command(test.compiler, "vet",
"storj.io/storj/cmd/uplink",
"storj.io/storj/cmd/satellite",
"storj.io/storj/cmd/storagenode-updater",
"storj.io/storj/cmd/storj-sim",
)
cmd.Env = append(os.Environ(),
"GOOS="+test.os,
"GOARCH="+test.arch,
)
data, err := cmd.CombinedOutput()
results[i] = result{
title: test.compiler + "/" + test.os + "/" + test.arch,
out: strings.TrimSpace(string(data)),
err: err,
}
})
}
lim.Wait()
exit := 0
for _, r := range results {
if r.err == nil {
fmt.Println("#", r.title, "SUCCESS")
} else {
fmt.Println("#", r.title, "FAILED", r.err)
fmt.Println(r.out)
fmt.Println()
exit = 1
}
}
os.Exit(exit)
}