summaryrefslogtreecommitdiff
path: root/magefile.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-05-02 16:05:53 -0600
committermo khan <mo@mokhan.ca>2025-05-02 16:05:53 -0600
commita3d5ee1225e2ce0b6cf3b90525a6876ca8f5ef8c (patch)
tree429faf79855a2614b4c18bb286f94f474caf7e5c /magefile.go
parent649b71d7fd2d6768460a37ed0d9e6ce7a1202a4f (diff)
refactor: connect logging to http requests
Diffstat (limited to 'magefile.go')
-rw-r--r--magefile.go68
1 files changed, 68 insertions, 0 deletions
diff --git a/magefile.go b/magefile.go
new file mode 100644
index 00000000..06dc0251
--- /dev/null
+++ b/magefile.go
@@ -0,0 +1,68 @@
+//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")
+}
+
+// Start NATS server
+func Nats() error {
+ return sh.RunV(
+ "nats-server",
+ "--addr=127.0.0.1",
+ "--port=4222",
+ "--http_port=8222",
+ "--pid=tmp/pids/nats.pid",
+ "--jetstream",
+ "--store_dir=tmp/nats/store",
+ )
+}
+
+// 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, Nats, 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", "./...")
+}