Skip to content

Commit d03178d

Browse files
authored
Upgrade bitn to v0.4.2 and enhance schema generation and Int64 handling (#7)
1 parent f878098 commit d03178d

7 files changed

Lines changed: 717 additions & 346 deletions

File tree

.github/workflows/build.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ jobs:
3737
version: v2.1.0
3838
args: false # Will be run as part of `make check`
3939

40+
- name: Setup Python
41+
uses: actions/setup-python@v5
42+
with:
43+
python-version: '3.12'
44+
45+
- name: Install protobuf compiler
46+
run: sudo apt-get install -y protobuf-compiler
47+
48+
- name: Setup schema generator
49+
run: make setup-schema-generator
50+
4051
- name: Check
4152
run: make check
4253

Makefile

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,40 @@ gen-schema:
124124
fi
125125
@.venv/bin/python3 tools/gen_lua_proto_schema $(OUTPUT) $(PROTO)
126126

127+
# Generate the base types schema from empty.proto
128+
.PHONY: gen-types
129+
gen-types:
130+
@if [ ! -f .venv/bin/python3 ]; then \
131+
echo "Python virtual environment not found. Run 'make setup-schema-generator' first."; \
132+
exit 1; \
133+
fi
134+
@echo "Generating src/protobuf/types.lua from empty.proto..."
135+
@.venv/bin/python3 tools/gen_lua_proto_schema src/protobuf/types.lua empty.proto
136+
@echo "Generated src/protobuf/types.lua"
137+
138+
# Check that types.lua matches what would be generated (for CI)
139+
.PHONY: check-types
140+
check-types:
141+
@if [ ! -f .venv/bin/python3 ]; then \
142+
echo "Python virtual environment not found. Run 'make setup-schema-generator' first."; \
143+
exit 1; \
144+
fi
145+
@echo "Checking src/protobuf/types.lua is up to date..."
146+
@mkdir -p build
147+
@.venv/bin/python3 tools/gen_lua_proto_schema build/types.lua.tmp empty.proto
148+
@if diff -q src/protobuf/types.lua build/types.lua.tmp >/dev/null 2>&1; then \
149+
echo "src/protobuf/types.lua is up to date"; \
150+
rm -f build/types.lua.tmp; \
151+
else \
152+
echo "ERROR: src/protobuf/types.lua is out of date!"; \
153+
echo "Run 'make gen-types' to regenerate it."; \
154+
echo ""; \
155+
echo "Diff:"; \
156+
diff src/protobuf/types.lua build/types.lua.tmp || true; \
157+
rm -f build/types.lua.tmp; \
158+
exit 1; \
159+
fi
160+
127161
# Format Lua code with stylua
128162
.PHONY: format
129163
format:
@@ -162,7 +196,7 @@ lint:
162196
fi
163197

164198
.PHONY: check
165-
check: format-check lint
199+
check: format-check lint check-types
166200
@echo "Code quality checks complete."
167201

168202
# Clean generated files
@@ -186,6 +220,8 @@ help:
186220
@echo "Schema Generation:"
187221
@echo " make setup-schema-generator - Setup Python venv for schema generator"
188222
@echo " make gen-schema PROTO=<file> OUTPUT=<file> - Generate Lua schema from proto file(s)"
223+
@echo " make gen-types - Regenerate src/protobuf/types.lua"
224+
@echo " make check-types - Verify types.lua matches empty.proto"
189225
@echo ""
190226
@echo "Code Quality:"
191227
@echo " make format - Format all code (Lua)"

empty.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
syntax = "proto3";
2+
package empty;

0 commit comments

Comments
 (0)