-
Notifications
You must be signed in to change notification settings - Fork 10
/
magefile.go
56 lines (46 loc) · 1.22 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
//go:build mage
// +build mage
package main
import (
"github.com/magefile/mage/mg" // mg contains helpful utility functions, like Deps
"github.com/magefile/mage/sh"
)
var (
// Default target to run when none is specified
Default = Test
Aliases = map[string]interface{}{
"cover": Coverage,
"c": Coverage,
"t": Test,
"l": Lint,
"f": Formatter,
"b": Builder,
}
test = sh.RunCmd("go", "test", "-v")
)
// Lint run golint and golang-ci-lint
func Lint() error {
if err := sh.Run("golint", "-set_exit_status", "./..."); err != nil {
return err
}
return sh.Run("golangci-lint", "run", "-c", ".golangci.toml")
}
// Test run unit tests
func Test() error {
return test("-coverprofile=coverage.out", "./...")
}
// Coverage run unit tests and open coverage
func Coverage() error {
mg.Deps(Test)
return sh.Run("go", "tool", "cover", "-html=coverage.out")
}
// Clean remove cache files
func Clean() error { return sh.Run("mage", "-clean") }
func Formatter() error { return sh.Run("gofmt", "-w", "src", "main.go") }
func Builder() error {
return sh.RunWith(map[string]string{
"GOOS": "darwin",
"GOARCH": "amd64",
"CGO_ENABLED": "1",
}, "go", "build", "-o", "alfred-chromium-workflow", ".")
}