Skip to content

feat(integration): enable CodeBuild and Nix for rust integration tests#5578

Merged
kaukabrizvi merged 33 commits intoaws:mainfrom
kaukabrizvi:main
Oct 31, 2025
Merged

feat(integration): enable CodeBuild and Nix for rust integration tests#5578
kaukabrizvi merged 33 commits intoaws:mainfrom
kaukabrizvi:main

Conversation

@kaukabrizvi
Copy link
Copy Markdown
Contributor

Goal:
Develop scaffolding for Rust integration testing within Nix-based tooling to support CI coverage across aws-lc, aws-lc-fips, OpenSSL 3.X, OpenSSL 1.1.1, and OpenSSL 1.0.2. This PR builds on the utilities for rust integration tests implemented in #5475

Why:
We would like to improve integration tests to make them easier to debug, performant, and possible to run locally so we are pursuing rust based integration tests. Previously, our CI lacked dedicated Nix-based Rust integration scaffolding. This PR modifies the nix dev shells to ensure the rust_integration function can run in a nix environment without unresolved symbol or link-time dependency errors. Currently the test stored in bindings/rust/standard/integration are run in this environment

Currently, the lack of libclang and cargo support in nix result in failures when generating s2n-tls rust bindings in a nix-based environment. This PR modifies the nix environment and rust_integration function to support the build such that it builds consistently in the local nix environment and in CI. Additionally, aws-lc builds provide a shared lib by default in nix, but static linking is required for internal libcrypto builds, so this modifies the build flags to ensure successful builds in Rust.

Current Rust tests only gated on a combined PQAlgorithms flag, masking differences between ML-KEM and ML-DSA support between aws-lc and aws-lc-fips.

How:

  • Added static AWS-LC/FIPS devShell variants to fix dynamic-link conflicts under S2N_INTERN_LIBCRYPTO=ON.
  • Introduced commonShellHook and tool inputs for consistent libclang discovery (for bindgen).
  • Refactored devshell architecture with mkBaseShell helper function to create two classes of development environments: standard shells (common_packages only) and rust-enabled shells (common_packages + Rust toolchain), accessible via nix develop .#rust_ commands.
  • Added buildspec_integ_rust.yml to run Rust integration tests across OpenSSL (1.0.2/1.1.1/3.0), AWS-LC, and AWS-LC-FIPS (2024) on x86_64 and aarch64.
  • Modified rust_integration script to use a minimal Rust toolchain for reproducible local/CI runs.
  • Split PQAlgorithms into separate MLKem and MLDsa capabilities.

Testing:
Ran codebuild batch build for the integ_rust buildspec to verify that Rust integration tests pass across all libcrypto variants via the new Nix+CodeBuild matrix.
Ran existing IntegV2 batch build which is unaffected.

Next Steps:
Future PRs will introduce the batch build to GH actions and expand Rust coverage to replace Integration V2 cases.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions bot added the s2n-core team label Oct 23, 2025
@kaukabrizvi kaukabrizvi marked this pull request as ready for review October 23, 2025 21:49
@kaukabrizvi kaukabrizvi requested a review from dougch as a code owner October 23, 2025 21:49
@kaukabrizvi kaukabrizvi requested a review from jmayclin October 24, 2025 18:20
Copy link
Copy Markdown
Contributor

@dougch dougch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great start; I have some requests and we should chat offline about a couple items.

nix/shell.sh Outdated
-DCMAKE_BUILD_TYPE=RelWithDebInfo

# Check if we're in a rust shell by looking for S2N_RUST_MODE environment variable
if [[ "$S2N_RUST_MODE" == "1" ]]; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's maybe chat offline about this?

It looks like there isn't actually any reused code in this functions. It's either entirely the if block of the else block, which seems like maybe it should just be a different function? Maybe that would also let us drop the S2N_CMAKE_OPTIONS?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chatted offline, will split this into rust_configure and rust_build functions since it makes the code more readable and will add documentation for the local dev. workflow.

kaukabrizvi and others added 21 commits October 31, 2025 19:34
…build (#5)

* use Nix clang/LLVM bintools + cmake/ninja; set CC/CXX and llvm-* in shellHook

* add static AWS-LC builds for Rust integration compatibility

* simplify logic to enable rust integration tests

* Add rust integ codebuild job

* Remove LLVM to test in codebuild

* identify clang path for bindgen

* specify cargo version in rust_integration

* use Nix Rust toolchain (no rustup) to fix CI cargo resolution

* run Rust generator from correct crate

* Specify s2n directory for codebuild access

* Subshell to avoid early exit in rust_integration

* Add postbuild phase

* add cargo debug statement

* Add debug statements to diagnose cargo rustup issues

* Force rust install to resolve rustup toolchain issues

* Get rid of unecessary build step in spec

* Simplify build logic and correct string matching in capability check

* Fix unbound var error in spec

* Add expected test failures for PQ MLDsa

* Simplify nix reqs

* Add s2n no headbuild var for testing

* Fix syntax err

* set no headbuild for all libcryptos

* Temporary fix to check integv2 compatibility

* Undo temporary branch naming change
Co-authored-by: James Mayclin <maycj@amazon.com>
@kaukabrizvi kaukabrizvi requested a review from jmayclin October 31, 2025 20:15
Copy link
Copy Markdown
Contributor

@dougch dougch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@kaukabrizvi kaukabrizvi added this pull request to the merge queue Oct 31, 2025
Merged via the queue into aws:main with commit 57f7c10 Oct 31, 2025
50 of 51 checks passed
@kaukabrizvi kaukabrizvi deleted the main branch October 31, 2025 22:37
@kaukabrizvi kaukabrizvi restored the main branch October 31, 2025 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants