ci: cross-compile storagenode-updater

Change-Id: I1db757b64e61f185ba710bf669f2e62441b9ab71
This commit is contained in:
Egon Elbre 2021-11-01 11:57:59 +02:00 committed by Stefan Benten
parent 136899eeea
commit 431f55d53b
3 changed files with 21 additions and 27 deletions

View File

@ -151,15 +151,15 @@ 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/uplinkng'
sh 'GOOS=linux GOARCH=amd64 go vet ./cmd/uplink ./cmd/satellite ./cmd/uplinkng'
sh 'GOOS=linux GOARCH=arm go vet ./cmd/uplink ./cmd/satellite ./cmd/uplinkng'
sh 'GOOS=linux GOARCH=arm64 go vet ./cmd/uplink ./cmd/satellite ./cmd/uplinkng'
sh 'GOOS=windows GOARCH=386 go vet ./cmd/uplink ./cmd/satellite ./cmd/uplinkng'
sh 'GOOS=windows GOARCH=amd64 go vet ./cmd/uplink ./cmd/satellite ./cmd/uplinkng'
sh 'GOOS=windows GOARCH=arm64 go vet ./cmd/uplink ./cmd/satellite ./cmd/uplinkng'
sh 'GOOS=darwin GOARCH=amd64 go vet ./cmd/uplink ./cmd/satellite ./cmd/uplinkng'
sh 'GOOS=darwin GOARCH=arm64 go vet ./cmd/uplink ./cmd/satellite ./cmd/uplinkng'
sh 'GOOS=linux GOARCH=386 go vet ./cmd/uplink ./cmd/satellite ./cmd/uplinkng ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=linux GOARCH=amd64 go vet ./cmd/uplink ./cmd/satellite ./cmd/uplinkng ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=linux GOARCH=arm go vet ./cmd/uplink ./cmd/satellite ./cmd/uplinkng ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=linux GOARCH=arm64 go vet ./cmd/uplink ./cmd/satellite ./cmd/uplinkng ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=windows GOARCH=386 go vet ./cmd/uplink ./cmd/satellite ./cmd/uplinkng ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=windows GOARCH=amd64 go vet ./cmd/uplink ./cmd/satellite ./cmd/uplinkng ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=windows GOARCH=arm64 go vet ./cmd/uplink ./cmd/satellite ./cmd/uplinkng ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=darwin GOARCH=amd64 go vet ./cmd/uplink ./cmd/satellite ./cmd/uplinkng ./cmd/storagenode-updater ./cmd/storj-sim'
sh 'GOOS=darwin GOARCH=arm64 go vet ./cmd/uplink ./cmd/satellite ./cmd/uplinkng ./cmd/storagenode-updater ./cmd/storj-sim'
}
}
stage('Tests') {

View File

@ -41,11 +41,6 @@ func loopFunc(ctx context.Context) error {
}
func updateSelf(ctx context.Context, binaryLocation string, ver version.Process) error {
suggestedVersion, err := ver.Suggested.SemVer()
if err != nil {
return errs.Wrap(err)
}
currentVersion, err := binaryVersion(binaryLocation)
if err != nil {
return errs.Wrap(err)
@ -57,18 +52,18 @@ func updateSelf(ctx context.Context, binaryLocation string, ver version.Process)
)
// should update
shouldUpdate, reason, err := version.ShouldUpdateVersion(currentVersion, nodeID, ver)
newVersion, reason, err := version.ShouldUpdateVersion(currentVersion, nodeID, ver)
if err != nil {
return errs.Wrap(err)
}
if !shouldUpdate {
if newVersion.IsZero() {
zap.L().Info(reason, zap.String("Service", updaterServiceName))
return nil
}
newVersionPath := prependExtension(binaryLocation, ver.Suggested.Version)
newVersionPath := prependExtension(binaryLocation, newVersion.Version)
if err = downloadBinary(ctx, parseDownloadURL(ver.Suggested.URL), newVersionPath); err != nil {
if err = downloadBinary(ctx, parseDownloadURL(newVersion.URL), newVersionPath); err != nil {
return errs.Wrap(err)
}
@ -77,11 +72,13 @@ func updateSelf(ctx context.Context, binaryLocation string, ver version.Process)
return errs.Combine(errs.Wrap(err), os.Remove(newVersionPath))
}
if suggestedVersion.Compare(downloadedVersion) != 0 {
err := errs.New("invalid version downloaded: wants %s got %s",
suggestedVersion.String(),
downloadedVersion.String(),
)
newSemVer, err := newVersion.SemVer()
if err != nil {
return errs.Combine(err, os.Remove(newVersionPath))
}
if newSemVer.Compare(downloadedVersion) != 0 {
err := errs.New("invalid version downloaded: wants %s got %s", newVersion.Version, downloadedVersion)
return errs.Combine(err, os.Remove(newVersionPath))
}

View File

@ -51,10 +51,7 @@ func update(ctx context.Context, serviceName, binaryLocation string, ver version
}
if newSemVer.Compare(downloadedVersion) != 0 {
err := errs.New("invalid version downloaded: wants %s got %s",
newVersion.Version,
downloadedVersion.String(),
)
err := errs.New("invalid version downloaded: wants %s got %s", newVersion.Version, downloadedVersion)
return errs.Combine(err, os.Remove(newVersionPath))
}