Skip to content

Commit

Permalink
Add publish --dry_run to the cargo_test
Browse files Browse the repository at this point in the history
Add trivial README.md files for this to pass.

This will catch some but not all issues with the crates that would cause them to be rejected by crates.io

PiperOrigin-RevId: 702766719
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Dec 4, 2024
1 parent fbffeb5 commit 926f87d
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions rust/release_crates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This directory contains one directory per crate that we release.

Each directory contains a pkg_tar() which packages up the crate into a tar which
can be pushed to crates.io.
10 changes: 9 additions & 1 deletion rust/release_crates/cargo_test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash
# Runs tests that are defined in the protobuf crate using Cargo.
# Runs tests that are defined in the protobuf crate using Cargo. This also
# performs a publish dry-run, which catches some but not all issues that
# would prevent the crates from being published.
# This is not a hermetic task because Cargo will fetch the needed
# dependencies from crates.io

Expand Down Expand Up @@ -59,9 +61,15 @@ tar -xvf $EXAMPLE_TAR -C $EXAMPLE_ROOT
cd $CRATE_ROOT
# Run all tests except doctests
CARGO_HOME=$CARGO_HOME cargo test --lib --bins --tests
CARGO_HOME=$CARGO_HOME cargo publish --dry-run

cd $CODEGEN_ROOT
CARGO_HOME=$CARGO_HOME cargo test --lib --bins --tests
CARGO_HOME=$CARGO_HOME cargo publish --dry-run

cd $EXAMPLE_ROOT
CARGO_HOME=$CARGO_HOME cargo test
# TODO: Cannot enable this dry-run yet because it checks that the versions of
# its dependencies are published on crates.io, which they are definitely not
# in this case.
# CARGO_HOME=$CARGO_HOME cargo publish --dry-run
1 change: 1 addition & 0 deletions rust/release_crates/protobuf/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ genrule(
filegroup(
name = "srcs",
srcs = [
"README.md",
"build.rs",
":gen_cargo_toml",
],
Expand Down
1 change: 1 addition & 0 deletions rust/release_crates/protobuf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The runtime of the official Google Rust Protobuf implementation.
1 change: 1 addition & 0 deletions rust/release_crates/protobuf_codegen/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ genrule(
filegroup(
name = "srcs",
srcs = [
"README.md",
":gen_cargo_toml",
] + glob(["src/**/*"]),
visibility = ["//rust:__subpackages__"],
Expand Down
2 changes: 2 additions & 0 deletions rust/release_crates/protobuf_codegen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The build time dependency crate for generating code for the Google Rust Protobuf
implementation.
2 changes: 2 additions & 0 deletions rust/release_crates/protobuf_example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
An example that demonstrates how to use the `protobuf` and `protobuf_codegen`
crates together.

0 comments on commit 926f87d

Please sign in to comment.