-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
magefile.go
59 lines (49 loc) · 1.31 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
// +build mage
package main
import (
"fmt"
// mg contains helpful utility functions, like Deps
"github.com/magefile/mage/mg"
// sh contains helpers for running shell-like commands
"github.com/magefile/mage/sh"
)
// set up environment variables
var env = map[string]string{
"MAGEFILE_VERBOSE": "1",
"GO111MODULE": "on",
}
// Default target to run when none is specified
// If not set, running mage will list available targets
var Default = Test
// Dep target fetches project dependencies
func Dep() error {
fmt.Println("Installing Deps...")
return sh.RunWith(env, "go", "mod", "tidy")
}
// Vet target makes vetting
func Vet() error {
fmt.Println("Vetting...")
return sh.RunWith(env, "go", "vet", "./...")
}
// Fmt target makes formatting
func Fmt() error {
fmt.Println("Formatting...")
return sh.RunWith(env, "go", "fmt", "./...")
}
// Clean up
func Clean() error {
fmt.Println("Cleaning...")
return sh.RunWith(env, "go", "clean")
}
// Test target executes project tests
func Test() error {
mg.SerialDeps(Clean, Fmt, Vet, Dep)
fmt.Println("Testing...")
return sh.RunWith(env, "go", "test", "-v", "-cover", "./...")
}
// Generates test data
func Generate() error {
mg.SerialDeps(Clean, Fmt, Vet, Dep)
fmt.Println("generating test data...")
return sh.RunWith(env, "go", "test", "-v", "-update", "./...")
}