Compile and test a Rust application
Using Codefresh pipelines
Codefresh can work with any Rust application very easily as both rustc
and cargo
are already offered in Dockerhub.
The example Rust project
You can see the example project at https://github.com/codefresh-contrib/rust-sample-app. The repository contains a Rust starter project with a dummy unit test.
cargo build
compiles the code.cargo test
runs unit testscargo clean
removes artifacts and binaries.
Create a CI pipeline for Rust applications
Creating a CI/CD pipeline for Rust is very easy, because Codefresh can run any Rust image that you wish. Rust docker images already contain the cargo
package manager.
Here is the full pipeline that compiles the application after checking out the code.
codefresh.yml
This pipeline clones the source code, compiles the code and runs unit tests. In all cases we use the public Docker image of Rust that also contains cargo
.
We also pass the CARGO_HOME
environment variable to place the Cargo cache on the shared Codefresh volume. See the Caching documentation for more details.
Related articles
Codefresh YAML for pipeline definitions
Steps in pipelines
Creating pipelines
How Codefresh pipelines work