mirror of https://github.com/sirupsen/logrus.git
Merge pull request #1282 from sirupsen/dbd-ci-no-cross
reduce the list of cross build target
This commit is contained in:
commit
5418b6e7a4
|
@ -15,7 +15,7 @@ jobs:
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
platform: [ubuntu-latest, windows-latest]
|
platform: [ubuntu-latest]
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// +build mage
|
//go:build mage
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
@ -7,13 +7,34 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/magefile/mage/mg"
|
"github.com/magefile/mage/mg"
|
||||||
"github.com/magefile/mage/sh"
|
"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
|
// 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")
|
jsonData, err := sh.Output("go", "tool", "dist", "list", "-json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -38,6 +59,31 @@ func getBuildMatrix() (map[string][]string, error) {
|
||||||
return matrix, nil
|
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 {
|
func CrossBuild() error {
|
||||||
matrix, err := getBuildMatrix()
|
matrix, err := getBuildMatrix()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue