Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
play-circle

GitHub Action

rust-cargo

v1.0.0

rust-cargo

play-circle

rust-cargo

Run cargo command

Installation

Copy and paste the following snippet into your .yml file.

              

- name: rust-cargo

uses: actions-rs/cargo@v1.0.0

Learn more about this action in actions-rs/cargo

Choose a version

Rust cargo Action

MIT licensed Gitter

This GitHub Action runs specified cargo command on a Rust language project.

Example workflow

on: [push]

name: CI

jobs:
  build_and_test:
    name: Rust project
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - uses: actions-rs/cargo@v1
        with:
          command: build
          arguments: --release --all-features

Inputs

  • command (required) - Cargo command to run (ex. check or build)
  • toolchain - Rust toolchain to use (without the + sign, ex. nightly);
    Override or system toolchain will be used if omitted.
  • args - Arguments for the cargo command
  • use-cross - Use cross instead of cargo (default: false)

Virtual environments

Note that cargo is not available by default for all virtual environments; for example, as for 2019-09-15, macOS env is missing it.

You can use actions-rs/toolchain to install the Rust toolchain with cargo included.

Cross

In order to make cross-compilation an easy process, this Action can install cross tool on demand if use-cross input is enabled; cross executable will be invoked then instead of cargo automatically.

All consequent calls of this Action in the same job will use the same cross installed.

on: [push]

name: ARMv7 build

jobs:
  linux_arm7:
    name: Linux ARMv7
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          target: armv7-unknown-linux-gnueabihf
          override: true
      - uses: actions-rs/cargo@v1
        with:
          use-cross: true
          command: build
          args: --target armv7-unknown-linux-gnueabihf