From 8215973f17dfa126a5a8f8846c7a81ac07fea1a3 Mon Sep 17 00:00:00 2001 From: Shashank Sharma Date: Fri, 14 Aug 2026 10:41:51 -0700 Subject: [PATCH] fuzztest-rust: Add GitHub Actions workflow for Cargo tests - Add .github/workflows/cargo_test.yml to run cargo test across the workspace in OSS. - Build Centipede static library and binary with Bazel to satisfy engine-ffi linking. - Configure Bazel cache restoration with fallback to centipede default cache. PiperOrigin-RevId: 964774535 --- .github/workflows/cargo_test.yml | 81 ++++++++++++++++++++++++++++++++ rust/Cargo.toml | 3 -- rust/src/options.rs | 2 +- 3 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/cargo_test.yml diff --git a/.github/workflows/cargo_test.yml b/.github/workflows/cargo_test.yml new file mode 100644 index 000000000..36524fcf5 --- /dev/null +++ b/.github/workflows/cargo_test.yml @@ -0,0 +1,81 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Cargo Test + +on: + push: + branches: + - main + pull_request: + schedule: + # Triggered nightly at 8:00 AM UTC to reset the Bazel & Cargo caches. + - cron: '0 8 * * *' + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +permissions: + contents: read + +jobs: + run_cargo_tests: + name: Run Cargo tests + runs-on: ubuntu-22.04 + timeout-minutes: 60 + permissions: + contents: read + steps: + - name: Disable core dumping and piping due to slowness + run: | + sudo sysctl -w kernel.core_pattern="" + + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Install system dependencies + run: | + sudo apt-get update && sudo apt-get install -yq \ + clang + + - name: Setup Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@1fbea72663f6d4c03efaab13560c8a24cfd2a7cc # v1.9.0 + with: + toolchain: nightly + + - name: Restore Bazel cache + uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: "~/.cache/bazel" + key: bazel-centipede-cache-cargo-test + restore-keys: bazel-centipede-cache-cargo-test- + + - name: Build Centipede static library and binary with Bazel + run: | + bazel build -c opt //centipede:centipede_engine_static //centipede:centipede + + - name: Run Cargo workspace tests + env: + FUZZTEST_LIB_PATH: ${{ github.workspace }}/bazel-bin/centipede + CENTIPEDE_BINARY_PATH: ${{ github.workspace }}/bazel-bin/centipede/centipede + run: | + cargo test --locked --workspace --no-fail-fast -- --test-threads=1 + + - name: Save Bazel cache based on main + if: github.ref == 'refs/heads/main' + uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: "~/.cache/bazel" + key: bazel-centipede-cache-cargo-test-${{ github.run_id }} diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 7c3cbaeb9..2a7116c21 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -44,9 +44,6 @@ googletest.workspace = true version = "1.0.103" features = ["diff"] -[dev-dependencies.googletest] -version = "0.14.2" - [profile.fuzztest] inherits = 'release' panic = 'abort' diff --git a/rust/src/options.rs b/rust/src/options.rs index 0879705b9..f7da7ee2e 100644 --- a/rust/src/options.rs +++ b/rust/src/options.rs @@ -269,7 +269,7 @@ impl CentipedeArgs { /// write to restricted output files, or trigger other harness-specific behavior that /// interferes with fuzzing. fn default_env_diff() -> Vec { - let mut env_diff = vec![ + let env_diff = vec![ "-TEST_DIAGNOSTICS_OUTPUT_DIR".to_string(), "-TEST_INFRASTRUCTURE_FAILURE_FILE".to_string(), "-TEST_LOGSPLITTER_OUTPUT_FILE".to_string(),