-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmagefile.go
More file actions
95 lines (79 loc) · 2.2 KB
/
magefile.go
File metadata and controls
95 lines (79 loc) · 2.2 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
//go:build mage
package main
import (
"fmt"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
)
// Default target when "mage" is run without arguments
var Default = Build
// Build compiles the library and ensures it's valid
func Build() error {
mg.Deps(Fmt, Vet)
fmt.Println("📦 Building ruby-extension-go...")
return sh.Run("go", "build", "./...")
}
// Test runs all tests with coverage
func Test() error {
mg.Deps(Build)
fmt.Println("🧪 Running tests with coverage...")
return sh.Run("go", "test", "-v", "-cover", "./...")
}
// TestRace runs tests with race detector
func TestRace() error {
fmt.Println("🏃 Running tests with race detector...")
return sh.Run("go", "test", "-race", "./...")
}
// Fmt formats the code
func Fmt() error {
fmt.Println("✨ Formatting code...")
return sh.Run("go", "fmt", "./...")
}
// Vet runs go vet for static analysis
func Vet() error {
fmt.Println("🔍 Running static analysis...")
return sh.Run("go", "vet", "./...")
}
// Lint runs golangci-lint
func Lint() error {
fmt.Println("🎯 Running linter...")
if err := sh.Run("which", "golangci-lint"); err != nil {
fmt.Println("Installing golangci-lint...")
if err := sh.Run("go", "install", "github.com/golangci/golangci-lint/cmd/golangci-lint@latest"); err != nil {
return err
}
}
return sh.Run("golangci-lint", "run")
}
// Bench runs benchmarks
func Bench() error {
fmt.Println("⚡ Running benchmarks...")
return sh.Run("go", "test", "-bench=.", "./...")
}
// Deps downloads dependencies
func Deps() error {
fmt.Println("📥 Downloading dependencies...")
return sh.Run("go", "mod", "download")
}
// Tidy tidies go.mod
func Tidy() error {
fmt.Println("🧹 Tidying go.mod...")
return sh.Run("go", "mod", "tidy")
}
// CI runs all checks for continuous integration
func CI() error {
mg.SerialDeps(Deps, Fmt, Vet, Lint, Test, TestRace)
fmt.Println("✅ All CI checks passed!")
return nil
}
// Examples runs the example scripts
func Examples() error {
fmt.Println("🎭 Running examples...")
// Examples will be added later
return nil
}
// Clean removes build artifacts
func Clean() error {
fmt.Println("🧽 Cleaning build artifacts...")
return sh.Run("go", "clean", "-cache", "-testcache")
}