From a3242dc9e15e0e1b6704991c365d6aa27fc58510 Mon Sep 17 00:00:00 2001 From: Jakob Naucke Date: Wed, 17 Sep 2025 12:18:04 +0200 Subject: [PATCH 1/3] cargo: Set MSRV for individual crates #22 set an MSRV for the workspace, but this doesn't have any effect before setting them for the crates. Set them there. Unblocks #29. Signed-off-by: Jakob Naucke --- compute-pcrs/Cargo.toml | 1 + crds/Cargo.toml | 1 + manifest-gen/Cargo.toml | 1 + operator/Cargo.toml | 1 + rv-store/Cargo.toml | 1 + 5 files changed, 5 insertions(+) diff --git a/compute-pcrs/Cargo.toml b/compute-pcrs/Cargo.toml index 1cd7802e..0bdd9217 100644 --- a/compute-pcrs/Cargo.toml +++ b/compute-pcrs/Cargo.toml @@ -2,6 +2,7 @@ name = "compute-pcrs" version = "0.1.0" edition.workspace = true +rust-version.workspace = true description = "A cocl-operator optimized compute-pcrs interface" [dependencies] diff --git a/crds/Cargo.toml b/crds/Cargo.toml index 75053ba4..f04c19a4 100644 --- a/crds/Cargo.toml +++ b/crds/Cargo.toml @@ -2,6 +2,7 @@ name = "crds" version = "0.1.0" edition.workspace = true +rust-version.workspace = true [dependencies] k8s-openapi.workspace = true diff --git a/manifest-gen/Cargo.toml b/manifest-gen/Cargo.toml index 1e365c8d..c379bf1e 100644 --- a/manifest-gen/Cargo.toml +++ b/manifest-gen/Cargo.toml @@ -2,6 +2,7 @@ name = "manifest-gen" version = "0.1.0" edition.workspace = true +rust-version.workspace = true [dependencies] anyhow.workspace = true diff --git a/operator/Cargo.toml b/operator/Cargo.toml index 35e58e63..b0a4a87a 100644 --- a/operator/Cargo.toml +++ b/operator/Cargo.toml @@ -2,6 +2,7 @@ name = "operator" version = "0.1.0" edition.workspace = true +rust-version.workspace = true [dependencies] anyhow.workspace = true diff --git a/rv-store/Cargo.toml b/rv-store/Cargo.toml index 702d4cd8..543e0892 100644 --- a/rv-store/Cargo.toml +++ b/rv-store/Cargo.toml @@ -3,6 +3,7 @@ name = "rv-store" version = "0.1.0" description = "Reference values store definition for operator and compute-pcrs" edition.workspace = true +rust-version.workspace = true [dependencies] chrono.workspace = true From 4865c19f5be0a1f5664227b7992a4bd44b2bf115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Ravier?= Date: Tue, 16 Sep 2025 17:34:07 +0200 Subject: [PATCH 2/3] github/workflows: Use split workflow instead of matrix --- .github/workflows/cocl_basic_ci.yaml | 80 ------------------ .github/workflows/rust.yml | 122 +++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 80 deletions(-) delete mode 100644 .github/workflows/cocl_basic_ci.yaml create mode 100644 .github/workflows/rust.yml diff --git a/.github/workflows/cocl_basic_ci.yaml b/.github/workflows/cocl_basic_ci.yaml deleted file mode 100644 index 4a0e4033..00000000 --- a/.github/workflows/cocl_basic_ci.yaml +++ /dev/null @@ -1,80 +0,0 @@ -name: Basic CI test for Rust - -on: - pull_request: - branches: - - main - paths: - - 'operator/**' - - 'crds/**' - - 'manifest-gen/**' - - '.github/workflows/cocl_basic_ci.yaml' - - 'Cargo.toml' - - 'Cargo.lock' - push: - branches: - - main - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -env: - CARGO_TERM_COLOR: always - # Pinned toolchain for linting - ACTIONS_LINTS_TOOLCHAIN: 1.89.0 - -jobs: - lint: - name: Lint with pinned toolchain - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v5 - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: ${{ env.ACTIONS_LINTS_TOOLCHAIN }} - components: rustfmt, clippy - - name: Cache dependencies - uses: Swatinem/rust-cache@v2 - - name: Run lint checks - run: make lint - - build_and_test: - name: ${{ matrix.rust }} / ${{ matrix.profile }} - runs-on: ubuntu-latest - needs: lint - strategy: - fail-fast: false - matrix: - rust: - - stable - - beta - profile: - - dev - - release - target: - - x86_64-unknown-linux-gnu - steps: - - name: Checkout code - uses: actions/checkout@v5 - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: ${{ matrix.rust }} - targets: ${{ matrix.target }} - - - name: Cache dependencies - uses: Swatinem/rust-cache@v2 - - - name: Run cargo test - continue-on-error: ${{ matrix.rust == 'beta' }} - run: | - if [ "${{ matrix.profile }}" == "release" ]; then - make test-release - else - make test - fi diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 00000000..3466abba --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,122 @@ +# SPDX-FileCopyrightText: Yalan Zhang +# SPDX-FileCopyrightText: Timothée Ravier +# +# SPDX-License-Identifier: CC0-1.0 + +# Inspired by https://github.com/coreos/repo-templates + +name: "Rust" +on: + pull_request: + branches: + - "main" +permissions: + contents: "read" + +# Don't waste job slots on superseded code +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + # Pinned toolchain for linting + ACTIONS_LINTS_TOOLCHAIN: 1.85.0 + +jobs: + tests-stable: + name: "Tests, stable toolchain" + runs-on: "ubuntu-24.04" + container: "ghcr.io/confidential-clusters/buildroot:latest" + steps: + - name: "Check out repository" + uses: actions/checkout@v5 + - name: "Install toolchain" + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: stable + - name: "Cache build artifacts" + uses: Swatinem/rust-cache@v2 + - name: "cargo build" + run: cargo build --all-targets + - name: "cargo test" + run: cargo test --all-targets + tests-release-stable: + name: "Tests (release), stable toolchain" + runs-on: "ubuntu-24.04" + container: "ghcr.io/confidential-clusters/buildroot:latest" + steps: + - name: "Check out repository" + uses: actions/checkout@v5 + - name: "Install toolchain" + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: stable + - name: "Cache build artifacts" + uses: Swatinem/rust-cache@v2 + - name: "cargo build (release)" + run: cargo build --all-targets --release + - name: "cargo test (release)" + run: cargo test --all-targets --release + tests-release-msrv: + name: "Tests (release), minimum supported toolchain" + runs-on: "ubuntu-24.04" + container: "ghcr.io/confidential-clusters/buildroot:latest" + steps: + - name: "Check out repository" + uses: actions/checkout@v5 + - name: "Detect crate MSRV" + run: | + msrv=$(cargo metadata --format-version 1 --no-deps | \ + jq -r '.packages[0].rust_version') + echo "Crate MSRV: $msrv" + echo "MSRV=$msrv" >> $GITHUB_ENV + - name: "Install toolchain" + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: ${{ env.MSRV }} + - name: "Cache build artifacts" + uses: Swatinem/rust-cache@v2 + - name: "cargo build (release)" + run: cargo build --all-targets --release + - name: "cargo test (release)" + run: cargo test --all-targets --release + linting: + name: "Lints, pinned toolchain" + runs-on: "ubuntu-24.04" + container: "ghcr.io/confidential-clusters/buildroot:latest" + steps: + - name: "Check out repository" + uses: actions/checkout@v5 + - name: "Install toolchain" + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: ${{ env.ACTIONS_LINTS_TOOLCHAIN }} + components: rustfmt, clippy + - name: "Cache build artifacts" + uses: Swatinem/rust-cache@v2 + - name: "cargo fmt (check)" + run: cargo fmt -- --check -l + - name: "cargo clippy (warnings)" + run: cargo clippy --all-targets -- -D warnings + tests-other-channels: + name: "Tests, unstable toolchain" + runs-on: "ubuntu-24.04" + container: "ghcr.io/confidential-clusters/buildroot:latest" + continue-on-error: true + strategy: + matrix: + channel: [beta, nightly] + steps: + - name: "Check out repository" + uses: actions/checkout@v5 + - name: "Install toolchain" + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: ${{ matrix.channel }} + - name: "Cache build artifacts" + uses: Swatinem/rust-cache@v2 + - name: "cargo build" + run: cargo build --all-targets + - name: "cargo test" + run: cargo test --all-targets From fcaadfa28db7193952b7eca790b19bb57654fbe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Ravier?= Date: Thu, 18 Sep 2025 15:57:13 +0200 Subject: [PATCH 3/3] Use 1.85.0 as MSRV --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 04db47e6..0f5c66e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ resolver = "3" [workspace.package] edition = "2024" -rust-version = "1.88" +rust-version = "1.85" [workspace.dependencies] anyhow = "1.0.99"