Skip to content

Commit 5418b6e

Browse files
authored
Merge pull request #1282 from sirupsen/dbd-ci-no-cross
reduce the list of cross build target
2 parents accc7da + 25e89b7 commit 5418b6e

File tree

2 files changed

+49
-3
lines changed

2 files changed

+49
-3
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
timeout-minutes: 10
1616
strategy:
1717
matrix:
18-
platform: [ubuntu-latest, windows-latest]
18+
platform: [ubuntu-latest]
1919
runs-on: ${{ matrix.platform }}
2020
steps:
2121
- uses: actions/checkout@v2

ci/magefile.go

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build mage
1+
//go:build mage
22

33
package main
44

@@ -7,13 +7,34 @@ import (
77
"fmt"
88
"os"
99
"path"
10+
"sort"
1011

1112
"github.com/magefile/mage/mg"
1213
"github.com/magefile/mage/sh"
1314
)
1415

16+
func intersect(a, b []string) []string {
17+
sort.Strings(a)
18+
sort.Strings(b)
19+
20+
res := make([]string, 0, func() int {
21+
if len(a) < len(b) {
22+
return len(a)
23+
}
24+
return len(b)
25+
}())
26+
27+
for _, v := range a {
28+
idx := sort.SearchStrings(b, v)
29+
if idx < len(b) && b[idx] == v {
30+
res = append(res, v)
31+
}
32+
}
33+
return res
34+
}
35+
1536
// getBuildMatrix returns the build matrix from the current version of the go compiler
16-
func getBuildMatrix() (map[string][]string, error) {
37+
func getFullBuildMatrix() (map[string][]string, error) {
1738
jsonData, err := sh.Output("go", "tool", "dist", "list", "-json")
1839
if err != nil {
1940
return nil, err
@@ -38,6 +59,31 @@ func getBuildMatrix() (map[string][]string, error) {
3859
return matrix, nil
3960
}
4061

62+
func getBuildMatrix() (map[string][]string, error) {
63+
minimalMatrix := map[string][]string{
64+
"linux": []string{"amd64"},
65+
"darwin": []string{"amd64", "arm64"},
66+
"freebsd": []string{"amd64"},
67+
"js": []string{"wasm"},
68+
"solaris": []string{"amd64"},
69+
"windows": []string{"amd64", "arm64"},
70+
}
71+
72+
fullMatrix, err := getFullBuildMatrix()
73+
if err != nil {
74+
return nil, err
75+
}
76+
77+
for os, arches := range minimalMatrix {
78+
if fullV, ok := fullMatrix[os]; !ok {
79+
delete(minimalMatrix, os)
80+
} else {
81+
minimalMatrix[os] = intersect(arches, fullV)
82+
}
83+
}
84+
return minimalMatrix, nil
85+
}
86+
4187
func CrossBuild() error {
4288
matrix, err := getBuildMatrix()
4389
if err != nil {

0 commit comments

Comments
 (0)