Compare commits

...
9 Commits
Author SHA1 Message Date
beejay e21d7f2394 Merge pull request 'add README documentation for Fog Model and Protocol Buffer schemas' (#1) from docs/readme into main
Reviewed-on: #1
2026-11-11 17:18:23 +09:00
actions[bot] 2caed6fd6f Update generated Protobufs 2026-11-11 08:15:05 +00:00
beejay 8d493c6579 update CI workflow to install specific protoc version and enhance generated Protobufs handling
Build protos / Build Protobufs (pull_request) Successful in 20s
2026-11-11 17:14:43 +09:00
beejay ce2c54acf2 update CI workflow to install specific protoc version and enhance generated Protobufs handling 2026-11-11 17:11:48 +09:00
beejay 35d0739b63 add CLEANUP action to DeploymentAction enum in deployment.proto
Build protos / Build Protobufs (pull_request) Successful in 37s
2026-11-11 17:05:37 +09:00
beejay d6c399fded update build configuration to trigger on changes to Protobuf files 2026-11-11 17:04:45 +09:00
beejay c3339ab49a update CI configuration to commit and push generated Protobufs 2026-11-11 17:03:26 +09:00
beejay 85a6397d1d automate protobuf generation and update git configuration for CI
Build protos / Build Protobufs (pull_request) Failing after 38s
2026-11-11 16:29:50 +09:00
beejay 47e0e79550 add README documentation for Fog Model and Protocol Buffer schemas
Build protos / Build Protobufs (pull_request) Successful in 5m42s
2026-11-11 16:21:55 +09:00
4 changed files with 112 additions and 15 deletions

No files matched your search

+34 -13
View File
@@ -1,16 +1,12 @@
name: Build protos
on:
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
- edited
push:
tags:
- 'v*.*.*'
paths:
- '*.proto'
- '**/*.proto'
permissions:
contents: write
jobs:
build:
@@ -21,6 +17,7 @@ jobs:
uses: actions/checkout@v7
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.head.sha || github.sha }}
- name: Set up Go
uses: actions/setup-go@v7
@@ -29,13 +26,37 @@ jobs:
- name: Install protoc
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
curl --fail --location --silent --show-error \
--output "$RUNNER_TEMP/protoc.zip" \
https://github.com/protocolbuffers/protobuf/releases/download/v36.2/protoc-36.2-linux-x86_64.zip
unzip -q "$RUNNER_TEMP/protoc.zip" -d "$RUNNER_TEMP/protoc"
echo "$RUNNER_TEMP/protoc/bin" >> "$GITHUB_PATH"
- name: Install protoc-gen-go
run: |
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.12
- name: Generate Protobufs
run: |
make proto
- name: Commit and push changes
env:
HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}
HEAD_REF: ${{ github.event.pull_request.head.ref }}
REPOSITORY: ${{ github.repository }}
run: |
git add -- '*.pb.go'
if git diff --cached --quiet; then
exit 0
fi
if [ "$HEAD_REPOSITORY" != "$REPOSITORY" ]; then
echo "::error::Generated protobufs are out of date. Run make proto and commit the changes."
exit 1
fi
git config user.name "actions[bot]"
git config user.email "noreply@beejay.kim"
git commit -m "Update generated Protobufs"
git push origin "HEAD:refs/heads/$HEAD_REF"
+71
View File
@@ -0,0 +1,71 @@
# Fog Model
This module contains the Protocol Buffer schemas and generated Go types used to
represent Fog deployment data and control messages.
## Schemas
- `deployment.proto` defines `DeploymentAction` (`STOP` or `START`),
`GlobalEnvironment`, `ConfigFile`, and `Deployment`.
- `c2o/operation.proto` defines request `Message` values and `RequestType`
(`PING` or `DEPLOYMENT`).
The generated Go packages are `beejay.kim/fog/model` and
`beejay.kim/fog/model/c2o`, respectively. The generated `.pb.go` files are
checked in; edit the `.proto` files rather than editing generated code.
## Using the Go types
Import the generated package and use the standard Protocol Buffers Go API:
```go
package main
import (
"fmt"
model "beejay.kim/fog/model"
"google.golang.org/protobuf/proto"
)
func main() {
deployment := &model.Deployment{
Id: "example",
Action: model.DeploymentAction_START,
Env: &model.GlobalEnvironment{
Version: "1",
Variables: map[string]string{"REGION": "west"},
},
}
data, err := proto.Marshal(deployment)
if err != nil {
panic(err)
}
var decoded model.Deployment
if err := proto.Unmarshal(data, &decoded); err != nil {
panic(err)
}
fmt.Println(decoded.GetId())
}
```
The module requires Go 1.27 and `google.golang.org/protobuf`.
## Regenerating Go code
Install `protoc` 36.2 using the [official installation
instructions](https://protobuf.dev/installation/), and ensure it and the Go
generator are on `PATH`:
```sh
protoc --version
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.12
make proto
```
`make proto` regenerates the Go files from both schemas. Commit the updated
`.pb.go` files together with any schema changes. The workflow pushes generated
files to same-repository pull request branches; for pull requests from forks,
it reports an error if generated files are out of date.
+6 -2
View File
@@ -26,6 +26,7 @@ type DeploymentAction int32
const (
DeploymentAction_STOP DeploymentAction = 0
DeploymentAction_START DeploymentAction = 1
DeploymentAction_CLEANUP DeploymentAction = 2
)
// Enum value maps for DeploymentAction.
@@ -33,10 +34,12 @@ var (
DeploymentAction_name = map[int32]string{
0: "STOP",
1: "START",
2: "CLEANUP",
}
DeploymentAction_value = map[string]int32{
"STOP": 0,
"START": 1,
"CLEANUP": 2,
}
)
@@ -278,10 +281,11 @@ const file_deployment_proto_rawDesc = "" +
"\x06action\x18\x03 \x01(\x0e2\x17.proto.DeploymentActionR\x06action\x12\x10\n" +
"\x03hcl\x18\x04 \x01(\fR\x03hcl\x124\n" +
"\fconfig_files\x18\n" +
" \x03(\v2\x11.proto.ConfigFileR\vconfigFiles*'\n" +
" \x03(\v2\x11.proto.ConfigFileR\vconfigFiles*4\n" +
"\x10DeploymentAction\x12\b\n" +
"\x04STOP\x10\x00\x12\t\n" +
"\x05START\x10\x01B\x16Z\x14beejay.kim/fog/modelb\x06proto3"
"\x05START\x10\x01\x12\v\n" +
"\aCLEANUP\x10\x02B\x16Z\x14beejay.kim/fog/modelb\x06proto3"
var (
file_deployment_proto_rawDescOnce sync.Once
+1
View File
@@ -6,6 +6,7 @@ option go_package = "beejay.kim/fog/model";
enum DeploymentAction {
STOP = 0;
START = 1;
CLEANUP = 2;
}
message GlobalEnvironment {