-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmagefile.go
90 lines (67 loc) · 2.3 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//go:build mage
// +build mage
package main
import (
"fmt"
"os"
"os/exec"
"github.com/magefile/mage/mg"
"github.com/mcandre/buttery"
"github.com/mcandre/mage-extras"
)
// artifactsPath describes where artifacts are produced.
var artifactsPath = "bin"
// Default references the default build task.
var Default = Test
// Audit runs a security audit.
func Audit() error { return mageextras.SnykTest() }
// Test executes the integration test suite.
func Test() error {
mg.Deps(Install)
cmd := exec.Command("buttery", "-help")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}
// GoVet runs go vet with shadow checks enabled.
func GoVet() error { return mageextras.GoVetShadow() }
// GoLint runs golint.
func GoLint() error { return mageextras.GoLint() }
// Gofmt runs gofmt.
func GoFmt() error { return mageextras.GoFmt("-s", "-w") }
// GoImports runs goimports.
func GoImports() error { return mageextras.GoImports("-w") }
// Errcheck runs errcheck.
func Errcheck() error { return mageextras.Errcheck("-blank") }
// Nakedret runs nakedret.
func Nakedret() error { return mageextras.Nakedret("-l", "0") }
// Staticcheck runs staticcheck.
func Staticcheck() error { return mageextras.Staticcheck() }
// Yamllint runs yamllint.
func Yamllint() error { return mageextras.Yamllint("-s", ".yamllint", ".") }
// Lint runs the lint suite.
func Lint() error {
mg.Deps(GoVet)
mg.Deps(GoLint)
mg.Deps(GoFmt)
mg.Deps(GoImports)
mg.Deps(Errcheck)
mg.Deps(Nakedret)
mg.Deps(Staticcheck)
mg.Deps(Yamllint)
return nil
}
// portBasename labels the artifact basename.
var portBasename = fmt.Sprintf("buttery-%s", buttery.Version)
// repoNamespace identifies the Go namespace for this project.
var repoNamespace = "github.com/mcandre/buttery"
// Factorio cross-compiles Go binaries for a multitude of platforms.
func Factorio() error { return mageextras.Factorio(portBasename) }
// Port builds and compresses artifacts.
func Port() error { mg.Deps(Factorio); return mageextras.Archive(portBasename, artifactsPath) }
// Install builds and installs Go applications.
func Install() error { return mageextras.Install() }
// Uninstall deletes installed Go applications.
func Uninstall() error { return mageextras.Uninstall("buttery") }
// Clean deletes artifacts.
func Clean() error { return os.RemoveAll(artifactsPath) }