-
Notifications
You must be signed in to change notification settings - Fork 14
/
main.go
93 lines (78 loc) · 2.38 KB
/
main.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
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
package main
import (
"context"
"go.einride.tech/sage/sg"
"go.einride.tech/sage/sgtool"
"go.einride.tech/sage/tools/sgconvco"
"go.einride.tech/sage/tools/sggit"
"go.einride.tech/sage/tools/sggo"
"go.einride.tech/sage/tools/sggolangcilint"
"go.einride.tech/sage/tools/sggolines"
"go.einride.tech/sage/tools/sgmdformat"
"go.einride.tech/sage/tools/sgyamlfmt"
)
func main() {
sg.GenerateMakefiles(
sg.Makefile{
Path: sg.FromGitRoot("Makefile"),
DefaultTarget: All,
},
sg.Makefile{
Path: sg.FromGitRoot("proto/Makefile"),
DefaultTarget: Proto.All,
Namespace: Proto{},
},
)
}
func All(ctx context.Context) error {
sg.Deps(ctx, ConvcoCheck, FormatMarkdown, FormatYAML, GoGenerate, Proto.All)
sg.Deps(ctx, GoLint, GoTest)
sg.SerialDeps(ctx, GoModTidy, GitVerifyNoDiff)
return nil
}
func ConvcoCheck(ctx context.Context) error {
sg.Logger(ctx).Println("checking git commits...")
return sgconvco.Command(ctx, "check", "origin/master..HEAD").Run()
}
func FormatYAML(ctx context.Context) error {
sg.Logger(ctx).Println("formatting YAML files...")
return sgyamlfmt.Run(ctx)
}
func FormatMarkdown(ctx context.Context) error {
sg.Logger(ctx).Println("formatting Markdown files...")
return sgmdformat.Command(ctx).Run()
}
func GoLint(ctx context.Context) error {
sg.Logger(ctx).Println("linting Go files...")
return sggolangcilint.Run(ctx)
}
func GoLintFix(ctx context.Context) error {
sg.Logger(ctx).Println("fixing Go files...")
return sggolangcilint.Fix(ctx)
}
func GoLines(ctx context.Context) error {
sg.Logger(ctx).Println("wrapping Go lines...")
return sggolines.Run(ctx)
}
func GoModTidy(ctx context.Context) error {
sg.Logger(ctx).Println("tidying Go module files...")
return sg.Command(ctx, "go", "mod", "tidy", "-v").Run()
}
func GoTest(ctx context.Context) error {
sg.Logger(ctx).Println("running Go tests...")
return sggo.TestCommand(ctx).Run()
}
func GitVerifyNoDiff(ctx context.Context) error {
sg.Logger(ctx).Println("verifying that git has no diff...")
return sggit.VerifyNoDiff(ctx)
}
func Stringer(ctx context.Context) error {
sg.Logger(ctx).Println("building...")
_, err := sgtool.GoInstall(ctx, "golang.org/x/tools/cmd/stringer", "v0.11.0")
return err
}
func GoGenerate(ctx context.Context) error {
sg.Deps(ctx, Stringer)
sg.Logger(ctx).Println("generating Go code...")
return sg.Command(ctx, "go", "generate", "./...").Run()
}