From 862a8f7c38caa91d484067bf68ef4a65750de8d3 Mon Sep 17 00:00:00 2001 From: Jesper Brynolf Date: Wed, 19 Nov 2025 21:51:09 +0100 Subject: [PATCH 1/2] Fix Docs.rs build problem. Building the Docs.rs documentation failed due to a version environmental variable not being set. This commit addresses the problem by defaulting to the minimum supported tpm2-tss version when building for the Docs.rs build. Signed-off-by: Jesper Brynolf --- tss-esapi/build.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tss-esapi/build.rs b/tss-esapi/build.rs index 6ca6e6942..39c3a0a18 100644 --- a/tss-esapi/build.rs +++ b/tss-esapi/build.rs @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 use semver::{Version, VersionReq}; +const TPM2_TSS_MINIMUM_VERSION: Version = Version::new(4, 1, 3); + fn main() { println!("cargo:rustc-check-cfg=cfg(hierarchy_is_esys_tr)"); println!("cargo:rustc-check-cfg=cfg(has_tss_base_rc_values_28_to_51)"); @@ -9,11 +11,17 @@ fn main() { println!("cargo:rustc-check-cfg=cfg(has_tpmu_sensitive_create)"); println!("cargo:rustc-check-cfg=cfg(has_esys_tr_get_tpm_handle)"); - let tss_version_string = std::env::var("DEP_TSS2_ESYS_VERSION") - .expect("Failed to parse ENV variable DEP_TSS2_ESYS_VERSION as string"); - - let tss_version = Version::parse(&tss_version_string) - .expect("Failed to parse the DEP_TSS2_ESYS_VERSION variable as a semver version"); + // If documentation for Docs.rs is being built then the version is set + // to the minimum supported tpm2-tss version. + let tss_version = if std::env::var("DOCS_RS").is_ok() { + TPM2_TSS_MINIMUM_VERSION + } else { + let tss_version_string = std::env::var("DEP_TSS2_ESYS_VERSION") + .expect("Failed to parse ENV variable DEP_TSS2_ESYS_VERSION as string"); + + Version::parse(&tss_version_string) + .expect("Failed to parse the DEP_TSS2_ESYS_VERSION variable as a semver version") + }; let supported_tss_version = VersionReq::parse("<5.0.0, >=2.3.3").expect("Failed to parse supported TSS version"); From 4f9242c6e5588182c82502e41a5f44c2455b4d70 Mon Sep 17 00:00:00 2001 From: Jesper Brynolf Date: Wed, 19 Nov 2025 21:55:26 +0100 Subject: [PATCH 2/2] Adds ci check for Docs.rs build. Adds CI check that attempts to replicate how the documentation is built for Docs.rs. Signed-off-by: Jesper Brynolf --- .github/workflows/ci.yml | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eab40346f..0c6a7facb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: name: Check spelling runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Check spelling uses: codespell-project/actions-codespell@v1 with: @@ -19,7 +19,7 @@ jobs: name: Check formatting runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Check formatting run: cargo fmt --all -- --check # Check that it builds with the Minimum Supported Rust Version @@ -27,7 +27,7 @@ jobs: name: Check minimum supported rust version (MSRV) runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Build the container run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tools - name: Run the container @@ -38,7 +38,7 @@ jobs: name: Ubuntu tests runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Build the container run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tools - name: Run the container @@ -50,7 +50,7 @@ jobs: name: Ubuntu tests on v4.x.y of tpm2-tss libraries found using pkg-config --target tpm2-tools runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Build the container run: docker build -t ubuntucontainer tss-esapi/tests/ --build-arg TPM2_TSS_VERSION=4.1.3 --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tools - name: Run the container @@ -60,7 +60,7 @@ jobs: name: Ubuntu tests on v4.x.y of tpm2-tss libraries found using a path runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Build the container run: docker build -t ubuntucontainer tss-esapi/tests/ --build-arg TPM2_TSS_VERSION=4.1.3 --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tss-install-dir - name: Run the container @@ -71,7 +71,7 @@ jobs: # We just build a container... GitHub doesn't like Fedora :( runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Build the container run: docker build -t fedoracontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-fedora - name: Run the tests @@ -82,7 +82,7 @@ jobs: # We just build a container... GitHub doesn't like Fedora :( runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Build the container run: docker build -t fedoracontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-fedora-rawhide - name: Run the tests @@ -92,7 +92,7 @@ jobs: name: Valgrind test run runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Build the container run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tools - name: Run the tests @@ -103,7 +103,7 @@ jobs: name: Check documentation runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Build the container run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tools - name: Check documentation @@ -114,10 +114,22 @@ jobs: name: Check Clippy lints runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Build the container run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tss - name: Check Clippy lints MSRV run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi --env RUST_TOOLCHAIN_VERSION=1.74.0 ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/lint-checks.sh - name: Check Clippy lints latest run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/lint-checks.sh + # Check that it is possible to build the documentation the same way as it is done in Docs.rs + docs-rs: + name: Check Docs.rs compatibility + runs-on: ubuntu-latest + env: + RUSTDOCFLAGS: -Dwarnings + steps: + - uses: actions/checkout@v5 + - uses: dtolnay/rust-toolchain@nightly + - uses: dtolnay/install@cargo-docs-rs + - run: cargo docs-rs -p tss-esapi + - run: cargo docs-rs -p tss-esapi-sys \ No newline at end of file