From 6ac5113c21380deb17af3ffa5c0fa23a6d6a432f Mon Sep 17 00:00:00 2001 From: rldyourmnd Date: Tue, 4 Aug 2026 15:50:19 +0500 Subject: [PATCH] feat: extend rust-ci.yml with MSRV, OS matrix, fmt/clippy jobs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5 new optional inputs (test_matrix_os, fmt_command, clippy_command, msrv_toolchain, msrv_command). All default empty — existing callers unaffected. Enables migration of repos with separate fmt/clippy/MSRV jobs. --- .github/workflows/rust-ci.yml | 141 +++++++++++++++++++++++++++++++++- CHANGELOG.md | 8 ++ 2 files changed, 146 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.yml index 9d47033..3b11f3c 100644 --- a/.github/workflows/rust-ci.yml +++ b/.github/workflows/rust-ci.yml @@ -1,7 +1,11 @@ name: rust-ci -# Reusable Rust CI for BOTH tiers: pinned Rust toolchain (with -# built-in cargo cache), and caller-provided build/test commands passed via env. +# Reusable Rust CI for BOTH tiers: pinned Rust toolchain (with built-in cargo +# cache), caller-provided build/test commands, optional MSRV (minimum supported +# Rust version) check, optional OS matrix for tests, and optional dedicated +# rustfmt/clippy lint jobs. +# +# All new inputs default to empty/false so existing callers are unaffected. on: workflow_call: @@ -27,6 +31,26 @@ on: description: 'Test/verify command (bash).' type: string default: 'cargo test --locked' + test_matrix_os: + description: 'JSON array of OS labels for the test job matrix. Empty string = single runner (no matrix).' + type: string + default: '' + fmt_command: + description: 'rustfmt check command (bash). Empty to skip the fmt job entirely.' + type: string + default: '' + clippy_command: + description: 'clippy lint command (bash). Empty to skip the clippy job entirely.' + type: string + default: '' + msrv_toolchain: + description: 'Minimum Supported Rust Version toolchain. Empty to skip the MSRV job.' + type: string + default: '' + msrv_command: + description: 'MSRV check command (bash). Defaults to cargo check --locked.' + type: string + default: 'cargo check --locked --all-targets' timeout_minutes: type: number default: 30 @@ -65,10 +89,121 @@ jobs: BUILD_COMMAND: ${{ inputs.build_command }} run: bash -c "$BUILD_COMMAND" - - name: Run tests + - name: Run tests (single OS) + if: ${{ inputs.test_matrix_os == '' }} env: TEST_COMMAND: ${{ inputs.test_command }} RUST_TOOLCHAIN: ${{ inputs.toolchain }} run: | bash -c "$TEST_COMMAND" echo "Rust ${RUST_TOOLCHAIN} build + tests passed." >> "$GITHUB_STEP_SUMMARY" + + test-matrix: + name: test (${{ matrix.os }}) + if: ${{ inputs.test_matrix_os != '' }} + runs-on: ${{ matrix.os }} + timeout-minutes: ${{ inputs.timeout_minutes }} + permissions: + contents: read + strategy: + fail-fast: false + matrix: + os: ${{ fromJSON(inputs.test_matrix_os) }} + defaults: + run: + working-directory: ${{ inputs.working_directory }} + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Set up Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 + with: + toolchain: ${{ inputs.toolchain }} + + - name: Run tests + env: + TEST_COMMAND: ${{ inputs.test_command }} + run: bash -c "$TEST_COMMAND" + + fmt: + name: rustfmt + if: ${{ inputs.fmt_command != '' }} + runs-on: ${{ inputs.runner }} + timeout-minutes: 15 + permissions: + contents: read + defaults: + run: + working-directory: ${{ inputs.working_directory }} + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Set up Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 + with: + toolchain: ${{ inputs.toolchain }} + components: rustfmt + + - name: Check formatting + env: + FMT_COMMAND: ${{ inputs.fmt_command }} + run: bash -c "$FMT_COMMAND" + + clippy: + name: clippy + if: ${{ inputs.clippy_command != '' }} + runs-on: ${{ inputs.runner }} + timeout-minutes: 20 + permissions: + contents: read + defaults: + run: + working-directory: ${{ inputs.working_directory }} + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Set up Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 + with: + toolchain: ${{ inputs.toolchain }} + components: clippy + + - name: Run clippy + env: + CLIPPY_COMMAND: ${{ inputs.clippy_command }} + run: bash -c "$CLIPPY_COMMAND" + + msrv: + name: msrv (${{ inputs.msrv_toolchain }}) + if: ${{ inputs.msrv_toolchain != '' }} + runs-on: ${{ inputs.runner }} + timeout-minutes: 20 + permissions: + contents: read + defaults: + run: + working-directory: ${{ inputs.working_directory }} + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Set up MSRV toolchain + uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 + with: + toolchain: ${{ inputs.msrv_toolchain }} + + - name: MSRV check + env: + MSRV_COMMAND: ${{ inputs.msrv_command }} + run: bash -c "$MSRV_COMMAND" diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e3876c..dde1a9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ ## [Unreleased] +### Changed + +- **`rust-ci.yml` gained 5 new inputs for full Rust CI coverage.** + `test_matrix_os` (JSON array for OS matrix testing), `fmt_command` (dedicated + rustfmt job), `clippy_command` (dedicated clippy lint job), `msrv_toolchain` + + `msrv_command` (minimum supported Rust version check). All default to + empty — existing callers are unaffected. + ### Added - **`clusterfuzzlite.yml` — ClusterFuzzLite PR (code-change) and batch fuzzing.**