Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve generate-protobufs script #135

Merged
merged 2 commits into from
Oct 22, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
uses: ./.github/actions/set-sha

- uses: ./.github/actions/install-python-and-poetry
- uses: ./.github/actions/install-canvas

- name: Run the pre-commit hooks
uses: pre-commit/action@v3.0.0
Expand Down
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,11 @@ repos:
&& poetry install --no-ansi \
&& exec poetry run mypy --show-traceback $@
"

- repo: local
hooks:
- id: check-protobufs-definitions
name: Check Protobufs Definitions
entry: poetry run ./bin/generate-protobufs
language: system
pass_filenames: false
28 changes: 28 additions & 0 deletions bin/generate-protobufs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -e

# Default input and output paths, run from root
input_dir="protobufs/"
output_dir="./"

# Parse arguments for input and output paths
while getopts i:o: flag
do
case "${flag}" in
i) input_dir=${OPTARG};;
o) output_dir=${OPTARG};;
*) exit 1;;
esac
done

echo "Generating Python code from Protobufs in \"${input_dir}\" to \"${output_dir}\"..."

python \
-m grpc_tools.protoc \
-I="${input_dir}" \
--python_out="${output_dir}" \
--pyi_out="${output_dir}" \
--grpc_python_out="${output_dir}" \
"${input_dir}"canvas_generated/**/*.proto || exit 1

echo "Done!"
16 changes: 0 additions & 16 deletions protobufs/generate_protobufs.sh

This file was deleted.

Loading