-
Notifications
You must be signed in to change notification settings - Fork 8
/
magefile.go
64 lines (53 loc) · 1.19 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
//go:build mage
// +build mage
package main
import (
"fmt"
"os"
"path/filepath"
"runtime"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
"github.com/uwu-tools/magex/xplat"
//mage:import install
"github.com/goodhosts/cli/mage/install"
//mage:import test
"github.com/goodhosts/cli/mage/test"
)
func init() {
cwd, _ := os.Getwd()
xplat.EnsureInPath(filepath.Join(cwd, "bin"))
}
// run everything for ci process (install deps, lint, coverage, build)
func Ci() error {
fmt.Println("Running Continuous Integration...")
mg.Deps(install.Dependencies)
mg.Deps(Lint, test.Coverage)
mg.Deps(test.Build)
return nil
}
// build goodhosts cli locally
func Build() error {
fmt.Println("Building goodhosts...")
out := "goodhosts"
if runtime.GOOS == "windows" {
out = "goodhosts.exe"
}
sh.RunV("go", "build", "-o", out, "main.go")
return nil
}
// run the linter
func Lint() error {
mg.Deps(install.Golangcilint)
fmt.Println("Running Linter...")
return sh.RunV("golangci-lint", "run")
}
// delete files and paths made by mage
func Clean() error {
for _, path := range []string{"coverage.txt", "dist", "bin"} {
if err := sh.Rm(path); err != nil {
return err
}
}
return nil
}