Skip to main content

Rust (With Cargo)

Example YAML configuration for a project building a Rust binary with Cargo.

Scenario

User is looking to create a pipeline that builds an artifact on any event or branch pushed to source control.

Steps

The following pipeline concepts are being used in the pipeline below:

tip

Pipeline must be stored in base of repository as .vela.yml or .vela.yaml

It is recommended to pin image: versions for production pipelines

version: "1"

steps:
- name: fetch
image: rust:latest
pull: always
commands:
- cargo fetch --verbose --all

- name: test
image: rust:latest
pull: always
environment:
CGO_ENABLED: '0'
GOOS: linux
commands:
- cargo test --verbose --all

- name: build
image: rust:latest
pull: always
environment:
CGO_ENABLED: '0'
GOOS: linux
commands:
- cargo build --verbose --all

Stages

The following pipeline concepts are being used in the pipeline below:

tip

Pipeline must be stored in base of repository as .vela.yml or .vela.yaml

It is recommended to pin image: versions for production pipelines

version: "1"

stages:
fetch:
steps:
- name: fetch
image: rust:latest
pull: always
commands:
- cargo fetch --verbose --all

test:
needs: [ fetch ]
steps:
- name: test
image: rust:latest
pull: always
commands:
- cargo test --verbose --all

build:
needs: [ fetch ]
steps:
- name: build
image: rust:latest
pull: always
commands:
- cargo build --verbose --all