Skip to content

Commit db4ea2b

Browse files
acozzettecopybara-github
authored andcommitted
Add Windows test run exercising the Cargo build
PiperOrigin-RevId: 793698154
1 parent 69e5c0a commit db4ea2b

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

.github/workflows/test_rust.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,23 @@ jobs:
5858
${{ matrix.bazel_cmd }} --crosstool_top=//toolchain:clang_suite --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 --@rules_rust//rust/settings:experimental_use_cc_common_link=True
5959
${{ matrix.targets }} ${{ matrix.config.flags }}
6060
61+
windows:
62+
strategy:
63+
fail-fast: false # Don't cancel all jobs if one fails.
64+
name: Windows Cargo
65+
runs-on: windows-2022
66+
steps:
67+
- name: Checkout pending changes
68+
uses: protocolbuffers/protobuf-ci/checkout@v4
69+
with:
70+
ref: ${{ inputs.safe-checkout }}
71+
- name: Install Rust
72+
shell: bash
73+
run: rustup default nightly-2025-08-07
74+
- name: Run tests
75+
uses: protocolbuffers/protobuf-ci/bazel@v4
76+
with:
77+
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
78+
bazel: run //rust/release_crates:cargo_test
79+
bazel-cache: windows-cargo
80+
version: 8.0.1

rust/release_crates/cargo_test.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# --- begin runfiles.bash initialization ---
99
# Copy-pasted from Bazel's Bash runfiles library (tools/bash/runfiles/runfiles.bash).
10-
set -euo pipefail
10+
set -euxo pipefail
1111
if [[ ! -d "${RUNFILES_DIR:-/dev/null}" && ! -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
1212
if [[ -f "$0.runfiles_manifest" ]]; then
1313
export RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
@@ -40,7 +40,13 @@ mkdir $WORKSPACE_ROOT
4040
WORKSPACE_TAR=$(rlocation com_google_protobuf/rust/release_crates/workspace.tar)
4141

4242
echo "Expanding Cargo workspace tar"
43-
tar -xvf $WORKSPACE_TAR -C $WORKSPACE_ROOT
43+
44+
# The tar binary on Windows does not know how to handle file paths that start
45+
# with C:\ or similar, so we go a little out of our way here to avoid passing
46+
# any paths as arguments to tar.
47+
pushd $WORKSPACE_ROOT
48+
tar -xv < $WORKSPACE_TAR
49+
popd
4450

4551
# Put the Bazel-built protoc at the beginning of $PATH
4652
PATH=$(dirname $(rlocation com_google_protobuf/protoc)):$PATH

0 commit comments

Comments
 (0)