microsoft / mu_devops

Project Mu Developer Operations
https://microsoft.github.io/mu/
Other
27 stars 25 forks source link

Add Rust Support [Rebase & FF] #226

Closed makubacki closed 1 year ago

makubacki commented 1 year ago

This pull request adds Rust support to mu_devops with patterns that extend to Rust adoption in additional Project Mu repos.

The changes can be grouped into three high-level parts:

  1. Sync Rust environment files to repos
  2. Add pipeline support to build and test Rust code
  3. Update the build container to incorporate Rust support

These changes extend existing Rust efforts in Project Mu and improve user experience outside the CI environment.


Commit/Change Overview


.azurepipelines: Add YAML to cache Cargo tools

These files are added so dedicated pipelines can download the latest release from each tools GitHub repository and push the binaries to the pipeline artifacts.

Project Mu pipelines dependent on Rust tools can access the tools directly from the Project Mu pipeline artifacts which is faster than building and more reliable than depending on infrastructure outside the pipelines.


.sync/Files.yml: Move dev container section

Moves the section higher in the file to maintain alphabetic ordering of sections.


.sync: Sync common Rust files

Syncs the following files to repos that support Rust builds.


Jobs/PrGate.yml: Give the linux container a reliable name

Passes the --name parameter as a container creation option in pipelines so steps that may need to operate on the container instance have a fixed name to refer to the container by.

The name is: mu_devops_build_container


Steps: Add Rust templates

Adds two new step templates.

  1. RustSetupSteps.yml - Prepare Cargo for Rust builds including build during the edk build process and perform other actions available during pre-firmware build.
  2. RustCargoSteps.yml.yml - Steps to run common Cargo commands on the workspace. Cargo should be installed and the workspace source cloned before running these steps.

.sync/azure_pipelines/MuDevOpsWrapper.yml: Add rust support

Allows repos that extend the YAML template to pass a new parameter rust_build. By default, the option is false. If true, then the repo will be set up to build for Rust and Cargo commands will be run at the workspace level to build and test code.


Dockerfile: Add Rust support

Updates the build container image to be able to build Rust code (including Rust UEFI code).

The following additional applications are installed to assist with setting up Rust dependencies:

curl, jq, and unzip

The CARGO_HOME and RUSTUP_HOME environment variables are set in the image and the cargo directory is added to the system path.

The version of Rust specified in Version.njk is installed alongside support for other tools used in Project Mu Rust builds such as cargo-make and cargo-tarpaulin. The latest release binaries are pulled directly from their GitHub releases to minimze container size impact.

The resulting container images can be used for local development and within pipelines.


Notes


File sync tested in the following PRs:

makubacki commented 1 year ago

acpica.org appears to be broken now which is breaking the container build. Will put up a separate PR to get iasl from our external mu-iasl feed first and then rebase this PR on that.

makubacki commented 1 year ago

acpica.org appears to be broken now which is breaking the container build. Will put up a separate PR to get iasl from our external mu-iasl feed first and then rebase this PR on that.

PR with the change to move away from acpica.org: https://github.com/microsoft/mu_devops/pull/227

makubacki commented 1 year ago

acpica.org appears to be broken now which is breaking the container build.

PR with the change to move away from acpica.org: #227

Rebase done