Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ jobs:
version: v2.1.0
args: false # Will be run as part of `make check`

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install protobuf compiler
run: sudo apt-get install -y protobuf-compiler

- name: Setup schema generator
run: make setup-schema-generator

- name: Check
run: make check

Expand Down
38 changes: 37 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,40 @@ gen-schema:
fi
@.venv/bin/python3 tools/gen_lua_proto_schema $(OUTPUT) $(PROTO)

# Generate the base types schema from empty.proto
.PHONY: gen-types
gen-types:
@if [ ! -f .venv/bin/python3 ]; then \
echo "Python virtual environment not found. Run 'make setup-schema-generator' first."; \
exit 1; \
fi
@echo "Generating src/protobuf/types.lua from empty.proto..."
@.venv/bin/python3 tools/gen_lua_proto_schema src/protobuf/types.lua empty.proto
@echo "Generated src/protobuf/types.lua"

# Check that types.lua matches what would be generated (for CI)
.PHONY: check-types
check-types:
@if [ ! -f .venv/bin/python3 ]; then \
echo "Python virtual environment not found. Run 'make setup-schema-generator' first."; \
exit 1; \
fi
@echo "Checking src/protobuf/types.lua is up to date..."
@mkdir -p build
@.venv/bin/python3 tools/gen_lua_proto_schema build/types.lua.tmp empty.proto
@if diff -q src/protobuf/types.lua build/types.lua.tmp >/dev/null 2>&1; then \
echo "src/protobuf/types.lua is up to date"; \
rm -f build/types.lua.tmp; \
else \
echo "ERROR: src/protobuf/types.lua is out of date!"; \
echo "Run 'make gen-types' to regenerate it."; \
echo ""; \
echo "Diff:"; \
diff src/protobuf/types.lua build/types.lua.tmp || true; \
rm -f build/types.lua.tmp; \
exit 1; \
fi

# Format Lua code with stylua
.PHONY: format
format:
Expand Down Expand Up @@ -162,7 +196,7 @@ lint:
fi

.PHONY: check
check: format-check lint
check: format-check lint check-types
@echo "Code quality checks complete."

# Clean generated files
Expand All @@ -186,6 +220,8 @@ help:
@echo "Schema Generation:"
@echo " make setup-schema-generator - Setup Python venv for schema generator"
@echo " make gen-schema PROTO=<file> OUTPUT=<file> - Generate Lua schema from proto file(s)"
@echo " make gen-types - Regenerate src/protobuf/types.lua"
@echo " make check-types - Verify types.lua matches empty.proto"
@echo ""
@echo "Code Quality:"
@echo " make format - Format all code (Lua)"
Expand Down
2 changes: 2 additions & 0 deletions empty.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
syntax = "proto3";
package empty;
Loading
Loading