Skip to content

Commit ccd370e

Browse files
committed
add magefiles
1 parent 6e47fcf commit ccd370e

File tree

4 files changed

+72
-4
lines changed

4 files changed

+72
-4
lines changed

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,27 @@
88

99
This project contains the definitions of [Protocol Buffers] used by Authzed.
1010

11-
[Buf] is used to distribute these definitions and generate source code from them.
11+
We use [Buf] to distribute these definitions and generate source code from them. The definitions are published in [Buf Registry Authzed API repository].
1212

13-
You can find more info on [HTTP API usage] in the [Authzed Docs].
13+
You can find more info on [HTTP API usage] and the [versioning and deprecation policy] in the [Authzed Docs].
1414

15-
See [CONTRIBUTING.md] for instructions on how to contribute and perform common tasks like building the project and running tests.
15+
You can also use our [Postman collection] to explore the API.
16+
17+
See [CONTRIBUTING.md] for instructions on how to contribute.
1618

1719
[Protocol Buffers]: https://developers.google.com/protocol-buffers/
1820
[Buf]: https://github.com/bufbuild/buf
1921
[HTTP API usage]: https://authzed.com/docs/spicedb/getting-started/client-libraries#http-clients
2022
[Authzed Docs]: https://authzed.com/docs
23+
[versioning and deprecation policy]: https://authzed.com/blog/buf
24+
[Postman collection]: (https://www.postman.com/authzed/spicedb/collection/m26cqyc)
2125
[Buf Registry Authzed API repository]: https://buf.build/authzed/api/docs/main
22-
[CONTRIBUTING.md]: https://github.com/authzed/api/blob/main/CONTRIBUTING.md
26+
[CONTRIBUTING.md]: https://github.com/authzed/api/blob/main/CONTRIBUTING.md
27+
28+
## Development
29+
30+
You can run `mage` to see the available commands for development. We assume you have a Mac computer.
31+
32+
## Warnings ⚠️
33+
34+
- The `version` field found in various buf YAML configuration is actually schema of the YAML of the file and is not related to the version of the definitions.

magefiles/dev.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os/exec"
6+
7+
"github.com/magefile/mage/mg"
8+
)
9+
10+
type Dev mg.Namespace
11+
12+
// InstallDependencies installs development tools required for the project.
13+
func (Dev) InstallDependencies() error {
14+
commands := [][]string{
15+
{"brew", "install", "pre-commit"},
16+
{"brew", "install", "bufbuild/buf/buf"},
17+
{"pre-commit", "install"},
18+
}
19+
20+
for _, cmd := range commands {
21+
fmt.Printf("Running: %s\n", cmd)
22+
c := exec.Command(cmd[0], cmd[1:]...)
23+
if err := c.Run(); err != nil {
24+
return fmt.Errorf("failed to run %v: %w", cmd, err)
25+
}
26+
}
27+
28+
return nil
29+
}
30+
31+
// BufGenerate builds the image and then produces results according to `buf.gen.yaml`.
32+
func (Dev) BufGenerate() error {
33+
fmt.Println("Running buf generate...")
34+
c := exec.Command("buf", "generate")
35+
if err := c.Run(); err != nil {
36+
return fmt.Errorf("failed to run buf generate: %w", err)
37+
}
38+
return nil
39+
}
40+
41+
// BufBuild compiles protobuf files into an internal image format, verifying that the definitions are syntactically and semantically correct (e.g., resolving types, imports, etc.).
42+
func (Dev) BufBuild() error {
43+
fmt.Println("Running buf build...")
44+
c := exec.Command("buf", "build")
45+
if err := c.Run(); err != nil {
46+
return fmt.Errorf("failed to run buf build: %w", err)
47+
}
48+
return nil
49+
}

magefiles/go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/authzed/api/magefiles
2+
3+
go 1.24.0
4+
5+
require github.com/magefile/mage v1.15.0

magefiles/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=
2+
github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=

0 commit comments

Comments
 (0)