datahaven/.github/workflows/task-rust-tests.yml
undercover-cactus a9d0f7157a
feat: storage hub client (#149)
Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-09-10 08:15:27 +02:00

113 lines
3.4 KiB
YAML

# Rust Tests: CI for Rust components (DataHaven runtime and node Rust tests)
#
# Overview:
# 1. Prepare: This job handles the setup phase where the cargo nextest archive is created
# and uploaded to the workflow for use in the subsequent jobs
# 2. All Rust Tests: Executes the full suite of Rust tests across two partitions to
# to reduce total execution time.
name: DataHaven Operator Rust Tests
on:
workflow_dispatch:
workflow_call:
jobs:
prepare:
name: Prepare artifacts for Rust tests
runs-on:
group: DH-runners
env:
RUSTC_WRAPPER: "sccache"
CARGO_INCREMENTAL: "0"
CARGO_TERM_COLOR: always
SCCACHE_GHA_ENABLED: "true"
defaults:
run:
working-directory: ./operator
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- uses: ./.github/workflows/actions/setup-env
with:
cache-key: "TEST"
install-deps: false
- name: Set build flags
run: echo "RUSTFLAGS=${{ env.RUSTFLAGS }} -C linker=clang -C link-arg=-fuse-ld=mold" >> $GITHUB_ENV
# Cleanup-runner skipped on self-hosted runners (bare-metal manages disk space externally)
- name: Install nextest
run: |
if ! command -v cargo-nextest &> /dev/null; then
echo "Installing cargo-nextest version 0.9.100"
cargo install cargo-nextest --version 0.9.100 --locked
else
echo "cargo-nextest is already installed: $(cargo-nextest --version)"
fi
- name: Build and archive tests
run: cargo nextest archive --archive-file nextest-archive.tar.zst
- name: Upload archive to workflow
uses: actions/upload-artifact@v4
with:
name: nextest-archive
path: ./operator/nextest-archive.tar.zst
all-rust-tests:
name: Run all Operator Rust tests (/w partitioning)
needs: [prepare]
runs-on:
group: DH-runners
strategy:
fail-fast: false
matrix:
partition: [1, 2]
defaults:
run:
working-directory: ./operator
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install nextest
run: |
if ! command -v cargo-nextest &> /dev/null; then
echo "Installing cargo-nextest version 0.9.100"
cargo install cargo-nextest --version 0.9.100 --locked
else
echo "cargo-nextest is already installed: $(cargo-nextest --version)"
fi
- name: Download archive
uses: actions/download-artifact@v4
with:
name: nextest-archive
- name: Run Tests for All Projects!
run: |
~/.cargo/bin/cargo-nextest nextest run \
--archive-file ../nextest-archive.tar.zst \
--partition count:${{ matrix.partition }}/2
tests-result-checker:
name: Check tests were successful
needs: [all-rust-tests]
runs-on:
group: DH-runners
steps:
- name: Cleanup test artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: nextest-archive
- name: Validate test results
run: |
echo "matrix result: ${{ needs.all-rust-tests.result }}"
if [ "${{ needs.all-rust-tests.result }}" != "success" ]; then
echo "Rust tests failed or were cancelled"
exit 1
else
echo "Rust tests passed"
fi