-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1208 from sirupsen/magefile
migrate ci target from bash scripts to magefile
- Loading branch information
Showing
6 changed files
with
93 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// +build ignore | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/magefile/mage/mage" | ||
"os" | ||
) | ||
|
||
func main() { os.Exit(mage.Main()) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// +build mage | ||
|
||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
"path" | ||
|
||
"github.com/magefile/mage/mg" | ||
"github.com/magefile/mage/sh" | ||
) | ||
|
||
// getBuildMatrix returns the build matrix from the current version of the go compiler | ||
func getBuildMatrix() (map[string][]string, error) { | ||
jsonData, err := sh.Output("go", "tool", "dist", "list", "-json") | ||
if err != nil { | ||
return nil, err | ||
} | ||
var data []struct { | ||
Goos string | ||
Goarch string | ||
} | ||
if err := json.Unmarshal([]byte(jsonData), &data); err != nil { | ||
return nil, err | ||
} | ||
|
||
matrix := map[string][]string{} | ||
for _, v := range data { | ||
if val, ok := matrix[v.Goos]; ok { | ||
matrix[v.Goos] = append(val, v.Goarch) | ||
} else { | ||
matrix[v.Goos] = []string{v.Goarch} | ||
} | ||
} | ||
|
||
return matrix, nil | ||
} | ||
|
||
func CrossBuild() error { | ||
matrix, err := getBuildMatrix() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for os, arches := range matrix { | ||
for _, arch := range arches { | ||
env := map[string]string{ | ||
"GOOS": os, | ||
"GOARCH": arch, | ||
} | ||
if mg.Verbose() { | ||
fmt.Printf("Building for GOOS=%s GOARCH=%s\n", os, arch) | ||
} | ||
if err := sh.RunWith(env, "go", "build", "./..."); err != nil { | ||
return err | ||
} | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func Lint() error { | ||
gopath := os.Getenv("GOPATH") | ||
if gopath == "" { | ||
return fmt.Errorf("cannot retrieve GOPATH") | ||
} | ||
|
||
return sh.Run(path.Join(gopath, "bin", "golangci-lint"), "run", "./...") | ||
} | ||
|
||
// Run the test suite | ||
func Test() error { | ||
return sh.RunWith(map[string]string{"GORACE": "halt_on_error=1"}, | ||
"go", "test", "-race", "-v", "./...") | ||
} |
This file was deleted.
Oops, something went wrong.