From d630ac4b68883ff06525ef16782121a687260fb9 Mon Sep 17 00:00:00 2001 From: Leonard Gram Date: Thu, 21 Nov 2019 09:41:32 +0100 Subject: [PATCH] CI: Build all platforms for Enterprise (#20389) * CI: Build all platforms for Enterprise * CI: publishes new enterprise builds to grafana.com --- scripts/build/build-all.sh | 16 +++++------ scripts/build/release_publisher/main.go | 7 ++--- scripts/build/release_publisher/publisher.go | 27 +++++++++++++------ .../build/release_publisher/publisher_test.go | 22 ++++++++++----- 4 files changed, 44 insertions(+), 28 deletions(-) diff --git a/scripts/build/build-all.sh b/scripts/build/build-all.sh index 63aa9878ea3..e8b2dc9089d 100755 --- a/scripts/build/build-all.sh +++ b/scripts/build/build-all.sh @@ -47,15 +47,13 @@ fi echo "Build arguments: $OPT" echo "current dir: $(pwd)" -# build only amd64 for enterprise -if echo "$EXTRA_OPTS" | grep -vq enterprise ; then - go run build.go -goarch armv6 -cc ${CCARMV6} ${OPT} build - go run build.go -goarch armv7 -cc ${CCARMV7} ${OPT} build - go run build.go -goarch arm64 -cc ${CCARM64} ${OPT} build - go run build.go -goarch armv7 -libc musl -cc ${CCARMV7_MUSL} ${OPT} build - go run build.go -goarch arm64 -libc musl -cc ${CCARM64_MUSL} ${OPT} build - go run build.go -goos darwin -cc ${CCOSX64} ${OPT} build -fi +go run build.go -goarch armv6 -cc ${CCARMV6} ${OPT} build +go run build.go -goarch armv7 -cc ${CCARMV7} ${OPT} build +go run build.go -goarch arm64 -cc ${CCARM64} ${OPT} build +go run build.go -goarch armv7 -libc musl -cc ${CCARMV7_MUSL} ${OPT} build +go run build.go -goarch arm64 -libc musl -cc ${CCARM64_MUSL} ${OPT} build +go run build.go -goos darwin -cc ${CCOSX64} ${OPT} build + go run build.go -goos windows -cc ${CCWIN64} ${OPT} build diff --git a/scripts/build/release_publisher/main.go b/scripts/build/release_publisher/main.go index 52bd02be53d..eba3907f3a3 100644 --- a/scripts/build/release_publisher/main.go +++ b/scripts/build/release_publisher/main.go @@ -46,11 +46,8 @@ func main() { baseURL = createBaseURL(archiveProviderRoot, "enterprise", product, nightly) var err error buildArtifacts, err = filterBuildArtifacts([]artifactFilter{ - {os: "deb", arch: "amd64"}, - {os: "rhel", arch: "amd64"}, - {os: "linux", arch: "amd64"}, - {os: "win", arch: "amd64"}, - }) + {os: "win-installer", arch: "amd64"}, + }, Remove) if err != nil { log.Fatalf("Could not filter to the selected build artifacts, err=%v", err) diff --git a/scripts/build/release_publisher/publisher.go b/scripts/build/release_publisher/publisher.go index da4d36e49d5..c4925c4272c 100644 --- a/scripts/build/release_publisher/publisher.go +++ b/scripts/build/release_publisher/publisher.go @@ -186,21 +186,32 @@ type artifactFilter struct { arch string } -func filterBuildArtifacts(filters []artifactFilter) ([]buildArtifact, error) { - var artifacts []buildArtifact - for _, f := range filters { - matched := false +type filterType string - for _, a := range completeBuildArtifactConfigurations { +const ( + Add filterType = "add" + Remove filterType = "remove" +) + +func filterBuildArtifacts(filters []artifactFilter, ft filterType) ([]buildArtifact, error) { + var artifacts []buildArtifact + + for _, a := range completeBuildArtifactConfigurations { + matched := false + var match buildArtifact + + for _, f := range filters { if f.os == a.os && f.arch == a.arch { - artifacts = append(artifacts, a) + match = a matched = true break } } - if !matched { - return nil, fmt.Errorf("No buildArtifact for os=%v, arch=%v", f.os, f.arch) + if matched && ft == Add { + artifacts = append(artifacts, match) + } else if !matched && ft == Remove { + artifacts = append(artifacts, match) } } return artifacts, nil diff --git a/scripts/build/release_publisher/publisher_test.go b/scripts/build/release_publisher/publisher_test.go index 7406eef74b6..47ad46ce228 100644 --- a/scripts/build/release_publisher/publisher_test.go +++ b/scripts/build/release_publisher/publisher_test.go @@ -153,18 +153,28 @@ func TestFilterBuildArtifacts(t *testing.T) { {os: "rhel", arch: "amd64"}, {os: "linux", arch: "amd64"}, {os: "win", arch: "amd64"}, - }) + }, Add) if len(buildArtifacts) != 4 { t.Errorf("Expected 4 build artifacts after filtering, but was %v", len(buildArtifacts)) } - _, err := filterBuildArtifacts([]artifactFilter{ - {os: "foobar", arch: "amd64"}, - }) + buildArtifacts, err := filterBuildArtifacts([]artifactFilter{ + {os: "win-installer", arch: "amd64"}, + }, Remove) - if err == nil { - t.Errorf("Expected an error as a we tried to filter on a nonexiststant os.") + if err != nil { + t.Errorf("Expected all artifacts except win-msi, not error=%v", err) + } + + if len(buildArtifacts) != len(completeBuildArtifactConfigurations)-1 { + t.Errorf("Expected %v artifacts but was %v", completeBuildArtifactConfigurations, buildArtifacts) + } + + for _, ba := range buildArtifacts { + if ba.arch == "amd64" && ba.os == "win-installer" { + t.Errorf("win-installer/amd64 should be gone due to filtering") + } } }