-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmagefile.go
More file actions
109 lines (80 loc) · 2.82 KB
/
magefile.go
File metadata and controls
109 lines (80 loc) · 2.82 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//go:build mage
package main
import (
"fmt"
"path"
"github.com/mcandre/buttery"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
"github.com/mcandre/mx"
)
// Default references the default build task.
var Default = Build
// Audit runs security checks.
func Audit() error { return Govulncheck() }
// Build compiles Go projects.
func Build() error { return sh.RunV("go", "build", "./...") }
// Clean removes artifacts.
func Clean() error { mg.Deps(CleanPackages); return CleanArtifacts() }
// CleanArtifacts removes artifacts.
func CleanArtifacts() error { return sh.RunV("tuco", "-clean") }
// CleanPackages removes OS package artifacts.
func CleanPackages() error { return sh.RunV("rockhopper", "-c") }
// Deadcode runs deadcode.
func Deadcode() error { return sh.RunV("deadcode", "./...") }
// Errcheck runs errcheck.
func Errcheck() error { return sh.RunV("errcheck", "-blank") }
// GoGenerate populates generated Go source code.
func GoGenerate() error { return sh.RunV("go", "generate", "./...") }
// GoImports runs goimports.
func GoImports() error { return mx.GoImports("-w") }
// GoVet runs default go vet analyzers.
func GoVet() error { return mx.GoVet() }
// Govulncheck runs govulncheck.
func Govulncheck() error { return sh.RunV("govulncheck", "-scan", "package", "./...") }
// Install builds and installs Go applications.
func Install() error { mg.Deps(GoGenerate); return mx.Install() }
// Lint runs the lint suite.
func Lint() error {
mg.Deps(Deadcode)
mg.Deps(GoImports)
mg.Deps(GoVet)
mg.Deps(Errcheck)
mg.Deps(Nakedret)
mg.Deps(Shadow)
mg.Deps(Staticcheck)
return nil
}
// Nakedret runs nakedret.
func Nakedret() error { return mx.Nakedret("-l", "0") }
// Package generates OS packages.
func Package() error { return sh.RunV("rockhopper", "-r", fmt.Sprintf("version=%s", buttery.Version)) }
// Shadow runs go vet with shadow checks enabled.
func Shadow() error { return mx.GoVetShadow() }
// Staticcheck runs staticcheck.
func Staticcheck() error { return sh.RunV("staticcheck", "./...") }
// Test executes a test suite.
func Test() error { return mx.UnitTest() }
// Tuco builds crossplatform binaries and tarballs.
func Tuco() error { return sh.RunV("tuco") }
// Uninstall deletes installed Go applications.
func Uninstall() error { return mx.Uninstall("buttery") }
// Bucket stores OS packages
const Bucket = "s3://buttery"
// Artifacts contains precompiled binaries
var Artifacts = path.Join(".rockhopper", "artifacts")
// Banner identifies the application version.
var Banner = fmt.Sprintf("buttery-%s", buttery.Version)
// Dest stores OS packages for this application version.
var Dest = fmt.Sprintf("%s/%s/", Bucket, Banner)
// Upload sends packages to CloudFlare R2.
func Upload() error {
return mx.RunVSilent("aws",
"--cli-connect-timeout", "1",
"s3",
"cp",
"--recursive",
Artifacts,
Dest,
)
}