Rust (With Cargo)

Example Rust (With Cargo) Pipeline

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:

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:

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