-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmagefile.go
More file actions
100 lines (85 loc) · 2.41 KB
/
magefile.go
File metadata and controls
100 lines (85 loc) · 2.41 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
//go:build mage
package main
import (
"strings"
"github.com/magefile/mage/sh"
)
var Default = Build
var CapoPackage = "./cmd/capo"
var BuildprobePackage = "./cmd/buildprobe"
// Runs the capo module in a buildah namespace using 'buildah unshare'.
// Passes args to capo. Capo arguments must be passed as a single string:
// $ mage run '--containerfile=Containerfile --build-arg=KEY=value'
func Run(capoArgsStr string) error {
capoArgs := strings.Split(capoArgsStr, " ")
bArgs := []string{
"unshare",
"go",
"run",
CapoPackage,
}
bArgs = append(bArgs, capoArgs...)
return sh.RunV("buildah", bArgs...)
}
func RunProbe(probeArgsStr string) error {
probeArgs := strings.Split(probeArgsStr, " ")
bArgs := []string{
"unshare",
"go",
"run",
BuildprobePackage,
}
bArgs = append(bArgs, probeArgs...)
return sh.RunV("buildah", bArgs...)
}
// Runs 'go mod download' and then installs the capo binary.
func Build() error {
if err := sh.RunV("go", "mod", "download"); err != nil {
return err
}
return sh.RunV("go", "install", "./...")
}
// Runs unit tests.
func Test() error {
return sh.RunV("go", "test", "-tags=unit,exclude_graphdriver_btrfs", "./...")
}
// Runs unit tests with coverage profiling and writes the result to coverage.out.
func Coverage() error {
return sh.RunV("go", "test", "-coverprofile=coverage.out", "-covermode=atomic", "-tags=unit,exclude_graphdriver_btrfs", "./...")
}
// Runs the dlv debugger in a buildah namespace using 'buildah unshare'.
func Debug() error {
return sh.RunV("buildah", "unshare", "dlv", "debug", CapoPackage)
}
// Formats using 'go fmt .'
func Format() error {
return sh.Run("go", "fmt", "./...")
}
// Runs 'go mod tidy' to remove unneeded dependencies.
func Tidy() error {
return sh.Run("go", "mod", "tidy")
}
// Runs golangci-lint to perform static code analysis and linting.
// golangci-lint uses the config in .golangci.yaml
func Lint() error {
return sh.RunV("golangci-lint", "run")
}
// Builds all test images and runs the integration test.
func IntegrationTest() error {
return sh.RunV(
"buildah",
"unshare",
"go",
"test",
"-v",
"-tags=integration,exclude_graphdriver_btrfs",
"./pkg",
)
}
// Creates a new git tag with the specified version and pushes it to origin.
// Github CI automation then builds the binary and creates a release.
func Release(version string) error {
sh.RunV("git", "tag", version)
sh.RunV("git", "push", "origin", version)
return nil
}