From 47e0e79550d806371eaa45a6c35a63af53f62369 Mon Sep 17 00:00:00 2001 From: Alek Kim Date: Wed, 11 Nov 2026 16:21:55 +0900 Subject: [PATCH 1/8] add README documentation for Fog Model and Protocol Buffer schemas --- README.md | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..ace2975 --- /dev/null +++ b/README.md @@ -0,0 +1,67 @@ +# 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` and the Go generator, and ensure both executables are on +`PATH`: + +```sh +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. \ No newline at end of file -- 2.54.1 From 85a6397d1dedef1e1f140bdbfba8d1271cc0c079 Mon Sep 17 00:00:00 2001 From: Alek Kim Date: Wed, 11 Nov 2026 16:29:50 +0900 Subject: [PATCH 2/8] automate protobuf generation and update git configuration for CI --- .github/workflows/build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 73754f7..6fdb7c9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,3 +39,10 @@ jobs: - name: Generate Protobufs run: | make proto + + - name: Add changes to git + run: | + git config --global user.name "actions[bot]" + git config --global user.email "noreply@beejay.kim" + git add . + git diff --cached --exit-code || (git commit -m "Update generated protobufs" && git push) -- 2.54.1 From c3339ab49a379add17eb31f4435523dbcf621a70 Mon Sep 17 00:00:00 2001 From: Alek Kim Date: Wed, 11 Nov 2026 17:03:26 +0900 Subject: [PATCH 3/8] update CI configuration to commit and push generated Protobufs --- .github/workflows/build.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6fdb7c9..93c936b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,6 +21,7 @@ jobs: uses: actions/checkout@v7 with: fetch-depth: 0 + ref: ${{ github.ref }} - name: Set up Go uses: actions/setup-go@v7 @@ -40,9 +41,10 @@ jobs: run: | make proto - - name: Add changes to git + - name: Commit and push changes run: | git config --global user.name "actions[bot]" git config --global user.email "noreply@beejay.kim" git add . - git diff --cached --exit-code || (git commit -m "Update generated protobufs" && git push) + git commit -m "Update generated Protobufs" || echo "No changes to commit" + git push origin ${{ github.ref }} || echo "No changes to push" -- 2.54.1 From d6c399fded5de2f16ec97ac2913f0a7392f76acd Mon Sep 17 00:00:00 2001 From: Alek Kim Date: Wed, 11 Nov 2026 17:04:45 +0900 Subject: [PATCH 4/8] update build configuration to trigger on changes to Protobuf files --- .github/workflows/build.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 93c936b..80ac9c6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: -- 2.54.1 From 35d0739b6349ae27f955f438e139100a16b7e75e Mon Sep 17 00:00:00 2001 From: Alek Kim Date: Wed, 11 Nov 2026 17:05:37 +0900 Subject: [PATCH 5/8] add CLEANUP action to DeploymentAction enum in deployment.proto --- deployment.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/deployment.proto b/deployment.proto index 5a478c3..60a5c9e 100644 --- a/deployment.proto +++ b/deployment.proto @@ -6,6 +6,7 @@ option go_package = "beejay.kim/fog/model"; enum DeploymentAction { STOP = 0; START = 1; + CLEANUP = 2; } message GlobalEnvironment { -- 2.54.1 From ce2c54acf260d3915dbf2433e520e264ad6a9bd9 Mon Sep 17 00:00:00 2001 From: Alek Kim Date: Wed, 11 Nov 2026 17:11:48 +0900 Subject: [PATCH 6/8] update CI workflow to install specific protoc version and enhance generated Protobufs handling --- .github/workflows/build.yml | 34 +++++++++++++++++++++++++--------- README.md | 10 +++++++--- deployment.proto | 1 - 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 80ac9c6..66bf87c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: uses: actions/checkout@v7 with: fetch-depth: 0 - ref: ${{ github.ref }} + 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 @@ -26,21 +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 config --global user.name "actions[bot]" - git config --global user.email "noreply@beejay.kim" - git add . - git commit -m "Update generated Protobufs" || echo "No changes to commit" - git push origin ${{ github.ref }} || echo "No changes to push" + 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" diff --git a/README.md b/README.md index ace2975..798f358 100644 --- a/README.md +++ b/README.md @@ -55,13 +55,17 @@ The module requires Go 1.27 and `google.golang.org/protobuf`. ## Regenerating Go code -Install `protoc` and the Go generator, and ensure both executables are on -`PATH`: +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. \ No newline at end of file +`.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. \ No newline at end of file diff --git a/deployment.proto b/deployment.proto index 60a5c9e..5a478c3 100644 --- a/deployment.proto +++ b/deployment.proto @@ -6,7 +6,6 @@ option go_package = "beejay.kim/fog/model"; enum DeploymentAction { STOP = 0; START = 1; - CLEANUP = 2; } message GlobalEnvironment { -- 2.54.1 From 8d493c65790cd298b52e0140d836ea8fb5f1d0d1 Mon Sep 17 00:00:00 2001 From: Alek Kim Date: Wed, 11 Nov 2026 17:14:43 +0900 Subject: [PATCH 7/8] update CI workflow to install specific protoc version and enhance generated Protobufs handling --- deployment.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/deployment.proto b/deployment.proto index 5a478c3..60a5c9e 100644 --- a/deployment.proto +++ b/deployment.proto @@ -6,6 +6,7 @@ option go_package = "beejay.kim/fog/model"; enum DeploymentAction { STOP = 0; START = 1; + CLEANUP = 2; } message GlobalEnvironment { -- 2.54.1 From 2caed6fd6f1f49c71666d07f9d9ddd3409403a75 Mon Sep 17 00:00:00 2001 From: "actions[bot]" Date: Wed, 11 Nov 2026 08:15:05 +0000 Subject: [PATCH 8/8] Update generated Protobufs --- deployment.pb.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/deployment.pb.go b/deployment.pb.go index 614b60f..f66e994 100644 --- a/deployment.pb.go +++ b/deployment.pb.go @@ -24,8 +24,9 @@ const ( type DeploymentAction int32 const ( - DeploymentAction_STOP DeploymentAction = 0 - DeploymentAction_START DeploymentAction = 1 + 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, + "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 -- 2.54.1