Skip to content

Commit 7616cd7

Browse files
authored
Merge branch 'master' into develop
2 parents 7085b65 + 3903a0a commit 7616cd7

File tree

6 files changed

+3473
-185
lines changed

6 files changed

+3473
-185
lines changed

.github/workflows/generator.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Generate Protobuf Documentation
2+
3+
# Define a manual trigger with input for version
4+
on:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
# Step 1: Checkout the repository code
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
# Step 1.1: Check Version Number
19+
- name: Check Version Number
20+
run: |
21+
pwd
22+
PROTO_VERSION=$(grep -oP '(?<=version\s)[0-9]+\.[0-9]+' ./idl/grpc/service.proto)
23+
THRIFT_VERSION=$(grep -oP '(?<=version\s)[0-9]+\.[0-9]+' ./idl/thrift/soccer_service.thrift)
24+
if [ "$PROTO_VERSION" != "$THRIFT_VERSION" ]; then
25+
echo "Version mismatch: Protobuf version is $PROTO_VERSION, Thrift version is $THRIFT_VERSION"
26+
exit 1
27+
fi
28+
29+
# Step 2: Install dependencies for protoc
30+
- name: Install protoc dependencies
31+
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler wget
32+
33+
# Step 3: Download precompiled protoc-gen-doc binary
34+
- name: Download protoc-gen-doc binary
35+
run: |
36+
# Download the appropriate precompiled binary for Linux
37+
wget https://github.com/pseudomuto/protoc-gen-doc/releases/download/v1.5.1/protoc-gen-doc_1.5.1_linux_amd64.tar.gz -O protoc-gen-doc.tar.gz
38+
39+
# Extract the binary from the tarball
40+
tar -xvf protoc-gen-doc.tar.gz
41+
42+
# Ensure it's an executable binary
43+
file protoc-gen-doc
44+
45+
# Make it executable
46+
chmod +x protoc-gen-doc
47+
48+
# Move the binary to /usr/local/bin
49+
sudo mv protoc-gen-doc /usr/local/bin/
50+
51+
# Step 4: Generate Markdown from the Protobuf file
52+
- name: Generate Protobuf Documentation
53+
run: |
54+
# Generate markdown from .proto file
55+
protoc --doc_out=./idl --doc_opt=markdown,readme.md ./idl/grpc/service.proto
56+
57+
# Step 5: Extract version from the first line of the .proto file
58+
- name: Extract version from .proto file
59+
id: extract_version
60+
run: |
61+
VERSION=$(grep -oP '(?<=version\s)[0-9]+\.[0-9]+' ./idl/grpc/service.proto)
62+
echo "VERSION=$VERSION" >> $GITHUB_ENV
63+
64+
# Step 6: Insert version into the generated Markdown file
65+
- name: Insert version into markdown
66+
run: |
67+
sed -i '3a\\n## Version: '"${{ env.VERSION }}"'\n' ./idl/readme.md
68+
69+
# Step 7: Replace &gt; and &lt; in Mermaid diagrams with > and <
70+
- name: Fix Mermaid symbols in readme.md
71+
run: |
72+
sed -i 's/&gt;/>/g' ./idl/readme.md
73+
sed -i 's/&lt;/</g' ./idl/readme.md
74+
75+
# Step 8: Configure Git and commit the updated readme.md
76+
- name: Configure Git
77+
run: |
78+
git config --global user.name "GitHub Action"
79+
git config --global user.email "[email protected]"
80+
81+
# Step 10: Stage and Commit Changes
82+
- name: Stage and Commit Changes
83+
run: |
84+
ls ./idl
85+
git status
86+
git add ./idl/readme.md # Ensure the correct file is added
87+
git diff --quiet || git commit -m "Update protobuf documentation with version and fixed Mermaid symbols" || echo "No changes to commit"
88+
89+
# Step 11: Push the changes
90+
- name: Push Changes
91+
env:
92+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93+
run: git push
94+
95+
# Step 12: Clone the website repository and push the updated protobuf.md
96+
- name: Push to Website Repo
97+
env:
98+
WEBSITE_TOKEN: ${{ secrets.WEBSITE_TOKEN }} # Add your Personal Access Token (PAT) as a secret
99+
run: |
100+
# Clone the website repository
101+
git clone https://[email protected]/CLSFramework/CLSFramework.github.io.git website
102+
103+
# Copy the generated readme.md and rename it to protobuf.md
104+
mv ./idl/readme.md ./website/docs/3-idl/protobuf.md
105+
106+
# Commit and push changes to the website repo only if there are changes
107+
cd website
108+
git config --global user.name "GitHub Action"
109+
git config --global user.email "[email protected]"
110+
111+
# Check if there are any changes
112+
if git diff --quiet; then
113+
echo "No changes detected, skipping commit and push."
114+
else
115+
git add ./docs/3-idl/protobuf.md
116+
git commit -m "Update protobuf documentation with version and fixed Mermaid symbols"
117+
git push
118+
fi

.gitignore

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,15 @@ grpc/python-v1/src/__pycache__/
3737
.idea/
3838
cmake-build-debug-event-trace/
3939
__pycache__/
40-
grpc/python-v1/src/__pycache__/
40+
grpc/python-v1/src/__pycache__/
41+
42+
src/grpc-generated/service.grpc.pb.cc
43+
src/grpc-generated/service.grpc.pb.h
44+
src/grpc-generated/service.pb.cc
45+
src/grpc-generated/service.pb.h
46+
src/thrift-generated/Game_server.skeleton.cpp
47+
src/thrift-generated/Game.cpp
48+
src/thrift-generated/Game.h
49+
src/thrift-generated/soccer_service_types.cpp
50+
src/thrift-generated/soccer_service_types.h
51+
idl/test.md

idl/generate-local-md.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
3+
# sudo apt-get update && sudo apt-get install -y protobuf-compiler wget
4+
5+
# # Download the appropriate precompiled binary for Linux
6+
# wget https://github.com/pseudomuto/protoc-gen-doc/releases/download/v1.5.1/protoc-gen-doc_1.5.1_linux_amd64.tar.gz -O protoc-gen-doc.tar.gz
7+
8+
# # Extract the binary from the tarball
9+
# tar -xvf protoc-gen-doc.tar.gz
10+
11+
# # Ensure it's an executable binary
12+
# file protoc-gen-doc
13+
14+
# # Make it executable
15+
# chmod +x protoc-gen-doc
16+
17+
# # Move the binary to /usr/local/bin
18+
# sudo mv protoc-gen-doc /usr/local/bin/
19+
20+
protoc --doc_out=./ --doc_opt=markdown,test.md ./grpc/service.proto
21+
22+
VERSION=$(grep -oP '(?<=version\s)[0-9]+\.[0-9]+' ./grpc/service.proto)
23+
echo "VERSION=$VERSION"
24+
25+
sed -i '3a\\n## Version: '"$VERSION"'\n' ./test.md
26+
27+
sed -i 's/&gt;/>/g' ./test.md
28+
sed -i 's/&lt;/</g' ./test.md

0 commit comments

Comments
 (0)