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
|
//go:build mage
// +build mage
package main
import (
"context"
"path/filepath"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
"github.com/xlgmokha/x/pkg/x"
)
// Default target to run when none is specified
// If not set, running mage will list available targets
var Default = Servers
// Run the Authzd Service
func Authzd() error {
env := map[string]string{
"BIND_ADDR": ":8080",
}
return sh.RunWithV(env, "go", "run", "./cmd/authzd/main.go")
}
// Generate gRPC from protocal buffers
func Protos() error {
for _, file := range x.Must(filepath.Glob("./protos/*.proto")) {
if err := sh.RunV(
"protoc",
"--proto_path=./protos",
"--go_out=.",
"--twirp_out=.",
file,
); err != nil {
return err
}
}
return nil
}
// Run All the servers
func Servers(ctx context.Context) {
mg.CtxDeps(ctx, Authzd)
}
// Run the end to end tests
func Test(ctx context.Context) error {
mg.CtxDeps(ctx, func() error {
return sh.RunV("go", "clean", "-testcache")
})
return sh.RunV("go", "test", "-shuffle=on", "-v", "./...")
}
|