-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmagefile.go
More file actions
51 lines (43 loc) · 1.23 KB
/
magefile.go
File metadata and controls
51 lines (43 loc) · 1.23 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
//go:build mage
// +build mage
package main
import (
"fmt"
"os"
"os/exec"
"github.com/magefile/mage/sh"
)
// Build compiles the temporal-ts_net binary
func Build() error {
fmt.Println("Building temporal-ts_net...")
return sh.Run("go", "build", "-o", "./bin/temporal-ts_net", "./cmd/temporal-ts_net")
}
// Test runs all tests with race detection and randomized order
func Test() error {
fmt.Println("Running tests with race detector and shuffle...")
return sh.RunV("go", "test", "-race", "-shuffle=on", "./...")
}
// Fmt formats all Go source files
func Fmt() error {
fmt.Println("Formatting code...")
return sh.Run("go", "fmt", "./...")
}
// Clean removes build artifacts
func Clean() error {
fmt.Println("Cleaning build artifacts...")
return sh.Rm("./bin")
}
// Install builds and installs the binary to $GOPATH/bin
func Install() error {
fmt.Println("Installing temporal-ts_net...")
gopath := os.Getenv("GOPATH")
if gopath == "" {
cmd := exec.Command("go", "env", "GOPATH")
out, err := cmd.Output()
if err != nil {
return fmt.Errorf("failed to determine GOPATH: %w", err)
}
gopath = string(out[:len(out)-1]) // trim newline
}
return sh.Run("go", "build", "-o", gopath+"/bin/temporal-ts_net", "./cmd/temporal-ts_net")
}