# Reusable workflow: Rust testing with cargo test # Usage: uses: wectrl-net/ci-templates/.gitea/workflows/test-rust.yaml@main name: Test Rust (cargo) on: workflow_call: inputs: rust-toolchain: description: "Rust toolchain" required: false type: string default: "stable" working-directory: description: "Directory containing the Rust project" required: false type: string default: "." cargo-test-args: description: "Additional cargo test arguments" required: false type: string default: "--all-features" jobs: test: name: cargo test runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install Rust toolchain uses: dtolnay/rust-toolchain@master with: toolchain: ${{ inputs.rust-toolchain }} - name: Cache cargo uses: actions/cache@v4 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ ${{ inputs.working-directory }}/target/ key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ runner.os }}-cargo-test- - name: Run tests run: cargo test ${{ inputs.cargo-test-args }} working-directory: ${{ inputs.working-directory }}