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

pb-rust: codegen via prost + prost-reflect #207

Merged
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
6 changes: 2 additions & 4 deletions .github/workflows/rust-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: |
cd gen/pb-rust
cargo build --verbose
make rust

test:
runs-on: ubuntu-latest
Expand All @@ -59,5 +58,4 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: |
cd gen/pb-rust
cargo test
make rust RUST_ACTION=test
5 changes: 1 addition & 4 deletions .github/workflows/rust-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ jobs:
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
defaults:
run:
working-directory: gen/pb-rust

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- run: cargo publish
- run: make rust RUST_ACTION=publish
env:
CARGO_REGISTRY_TOKEN: "${{ secrets.CARGO_REGISTRY_TOKEN }}"
17 changes: 8 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

PROTOC_IMAGE=protobuf-specs-build
JSONSCHEMA_IMAGE=jsonschema-specs-build
PROTOC_IMAGE = protobuf-specs-build
JSONSCHEMA_IMAGE = jsonschema-specs-build

RUST_ACTION ?= build

# generate all language protobuf code
all: go python typescript ruby rust jsonschema
Expand Down Expand Up @@ -58,17 +60,15 @@ jsonschema: docker-image-jsonschema
${JSONSCHEMA_IMAGE} \
-c "cd defs/gen/jsonschema && ./jsonschema.sh -I ../../protos -I /googleapis/ --jsonschema_out=schemas ../../protos/*.proto"

gen/pb-rust/schemas: jsonschema
cp -r gen/jsonschema/schemas gen/pb-rust

rust: docker-image gen/pb-rust/schemas
@echo "Generating rust protobuf files"
rust: docker-image
@echo "Running `cargo ${RUST_ACTION}`"
docker run \
--platform linux/amd64 \
-v ${PWD}:/defs \
-e "RUST_BACKTRACE=1" \
-e "CARGO_REGISTRY_TOKEN" \
--entrypoint bash ${PROTOC_IMAGE} \
-c "cd gen/pb-rust && cargo build"
-c "cd gen/pb-rust && cargo ${RUST_ACTION}"

# docker already does its own caching so we can attempt a build every time
.PHONY: docker-image
Expand All @@ -95,7 +95,6 @@ clean:
gen/pb-typescript/src/__generated__ \
gen/pb-python/sigstore_protobuf_specs/dev \
gen/pb-python/sigstore_protobuf_specs/io \
gen/pb-rust/schemas \
gen/pb-rust/target
docker rmi -f ${PROTOC_IMAGE}

Expand Down
Loading