From 51f2599bddbc3079ee32a6fd5e1cec1acf88e7cb Mon Sep 17 00:00:00 2001 From: David Bariod Date: Sun, 12 Sep 2021 15:52:09 +0200 Subject: [PATCH 1/3] reduce the list of cross build target --- ci/magefile.go | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/ci/magefile.go b/ci/magefile.go index 9aa603939..789ccde8f 100644 --- a/ci/magefile.go +++ b/ci/magefile.go @@ -1,3 +1,4 @@ +//go:build mage // +build mage package main @@ -7,13 +8,34 @@ import ( "fmt" "os" "path" + "sort" "github.com/magefile/mage/mg" "github.com/magefile/mage/sh" ) +func intersect(a, b []string) []string { + sort.Strings(a) + sort.Strings(b) + + res := make([]string, 0, func() int { + if len(a) < len(b) { + return len(a) + } + return len(b) + }()) + + for _, v := range a { + idx := sort.SearchStrings(b, v) + if idx < len(b) && b[idx] == v { + res = append(res, v) + } + } + return res +} + // getBuildMatrix returns the build matrix from the current version of the go compiler -func getBuildMatrix() (map[string][]string, error) { +func getFullBuildMatrix() (map[string][]string, error) { jsonData, err := sh.Output("go", "tool", "dist", "list", "-json") if err != nil { return nil, err @@ -38,6 +60,31 @@ func getBuildMatrix() (map[string][]string, error) { return matrix, nil } +func getBuildMatrix() (map[string][]string, error) { + minimalMatrix := map[string][]string{ + "linux": []string{"amd64"}, + "darwin": []string{"amd64", "arm64"}, + "freebsd": []string{"amd64"}, + "js": []string{"wasm"}, + "solaris": []string{"amd64"}, + "windows": []string{"amd64", "arm64"}, + } + + fullMatrix, err := getFullBuildMatrix() + if err != nil { + return nil, err + } + + for os, arches := range minimalMatrix { + if fullV, ok := fullMatrix[os]; !ok { + delete(minimalMatrix, os) + } else { + minimalMatrix[os] = intersect(arches, fullV) + } + } + return minimalMatrix, nil +} + func CrossBuild() error { matrix, err := getBuildMatrix() if err != nil { From f25cd754cf33cc725126bb251edd01f180ad31b2 Mon Sep 17 00:00:00 2001 From: David Bariod Date: Sun, 12 Sep 2021 15:58:50 +0200 Subject: [PATCH 2/3] remove duplicated build constraints line --- ci/magefile.go | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/magefile.go b/ci/magefile.go index 789ccde8f..ceda305cd 100644 --- a/ci/magefile.go +++ b/ci/magefile.go @@ -1,5 +1,4 @@ //go:build mage -// +build mage package main From 25e89b7d23013b9cd8570fee4a6ed24a6dd883de Mon Sep 17 00:00:00 2001 From: David Bariod Date: Sun, 12 Sep 2021 15:59:08 +0200 Subject: [PATCH 3/3] do not run the linter on windows --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ed5818a0f..6dc83a5d4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,7 +15,7 @@ jobs: timeout-minutes: 10 strategy: matrix: - platform: [ubuntu-latest, windows-latest] + platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v2