Skip to content

Latest commit

 

History

History
113 lines (86 loc) · 3.9 KB

README.md

File metadata and controls

113 lines (86 loc) · 3.9 KB

rs-cargo Action

MIT licensed CI

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

This GitHub Action has been forked from actions-rs/cargo. The original project published under the name rust-cargo. See LICENSE for copyright attribution details.

Table of Contents

Example workflow

on: [push]

name: CI

jobs:
  build_and_test:
    name: Rust project
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions-rust-lang/setup-rust-toolchain@v1
      - uses: clechasseur/rs-cargo@v2
        with:
          command: build
          args: --release --all-features

Use cases

Note that this Action is not usually required and you can just use a run step instead:

jobs:
  build_and_test:
    name: Rust project
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions-rust-lang/setup-rust-toolchain@v1
      - run: cargo build --release --all-features

Why would you want to use this Action instead?

  1. Transparent cross installation and execution with use-cross: true input enabled
  2. Warnings and errors issued by cargo will be displayed in GitHub UI

Inputs

Name Required Description Type Default
command Cargo command to run, ex. check or build string
toolchain Rust toolchain name to use string
args Arguments for the cargo command string
use-cross Use cross instead of cargo bool false
working-directory Directory where to perform cargo command string

Toolchain

By default this Action will call whatever cargo binary is available in the current virtual environment.

You can use actions-rust-lang/setup-rust-toolchain to install a specific Rust toolchain with cargo included.

Cross-compilation

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

All consequent calls of this Action in the same job with use-cross: true input enabled 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@v4
      - uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          targets: armv7-unknown-linux-gnueabihf
      - uses: clechasseur/rs-cargo@v2
        with:
          use-cross: true
          command: build
          args: --target armv7-unknown-linux-gnueabihf

License

MIT license