-
Notifications
You must be signed in to change notification settings - Fork 0
/
magefile.go
59 lines (47 loc) · 1.09 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
//go:build mage
package main
import (
"fmt"
"os"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
)
var Default = All
// Metabuild rebuild the mage binary
func Metabuild() error {
return sh.Run("go", "run", "mage.go", "-compile", "mage")
}
// Build the tt binary
func Build() error {
return sh.Run("go", "build", "./")
}
// Run the test suite
func Test() error {
return test(false)
}
// Run the test suite with coverage instrumentation
func Coverage() error {
return test(true)
}
func test(coverage bool) error {
if coverage {
return sh.Run("go", "test", "-count", "1", "-coverprofile", "cover.out", "./...")
} else {
return sh.RunV("go", "test", "-count", "1", "-v", "./...")
}
}
// Run golangci-lint v1.50.1 from its docker image on the repository
func Lint() error {
wd, err := os.Getwd()
if err != nil {
return fmt.Errorf("cannot get current directory: %w", err)
}
err = sh.Run(
"docker", "run", "-v", wd+":/tt", "-w", "/tt", "--rm", "golangci/golangci-lint:v1.50.1",
"golangci-lint", "run", "./...")
return err
}
func All() {
mg.Deps(Build, Test)
mg.Deps(Lint)
}