-
Notifications
You must be signed in to change notification settings - Fork 0
/
magefile.go
62 lines (51 loc) · 1.33 KB
/
magefile.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//go:build mage
// +build mage
package main
import (
"github.com/dmvolod/mageutil/bintool"
"github.com/dmvolod/mageutil/shellcmd"
)
var (
linter = bintool.Must(bintool.New(
"golangci-lint{{.BinExt}}",
"1.52.2",
"https://github.com/golangci/golangci-lint/releases/download/v{{.Version}}/golangci-lint-{{.Version}}-{{.GOOS}}-{{.GOARCH}}{{.ArchiveExt}}",
))
mage = bintool.Must(bintool.New(
"mage{{.BinExt}}",
"1.14.0",
"https://github.com/magefile/mage/releases/download/v{{.Version}}/mage_{{.Version}}_{{.GOOS}}-{{.GOARCH}}{{.ArchiveExt}}",
bintool.WithGoBinFolder(),
bintool.WithOsSubstitution(mageOsRepl),
bintool.WithArchSubstitution(mageArchRepl),
))
mageOsRepl = map[string]string{
"darwin": "macOS",
"linux": "Linux",
"windows": "Windows",
}
mageArchRepl = map[string]string{
"amd64": "64bit",
"386": "32bit",
"arm": "ARM",
"arm64": "ARM64",
}
)
func Mage() error {
return mage.Ensure()
}
func Lint() error {
if err := linter.Ensure(); err != nil {
return err
}
return linter.Command("run --timeout 5m").Run()
}
func Test() error {
return shellcmd.Command("go test -race -coverprofile=coverage.out ./...").Run()
}
func Coverage() error {
return shellcmd.Command("go tool cover -html=coverage.out").Run()
}
func Generate() error {
return shellcmd.Command("go generate ./...").Run()
}