cargo command
|
|
||
|---|---|---|
| .github | ||
| .matchers | ||
| __tests__ | ||
| dist | ||
| rust_tests | ||
| src | ||
| .editorconfig | ||
| .gitignore | ||
| .npmrc | ||
| .nvmrc | ||
| .oxlintrc.json | ||
| action.yml | ||
| Cargo.lock | ||
| Cargo.toml | ||
| CODE_OF_CONDUCT.md | ||
| CONTRIBUTING.md | ||
| DEVELOPMENT.md | ||
| jest.config.json | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| renovate.json | ||
| SECURITY.md | ||
| tsconfig.json | ||
rs-cargo Action
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions-rust-lang/setup-rust-toolchain@9399c7bb15d4c7d47b27263d024f0a4978346ba4 # v1.11.0
- uses: clechasseur/rs-cargo@319e211e9459c5e531afb6d157296765b441572e # v3.0.3
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions-rust-lang/setup-rust-toolchain@9399c7bb15d4c7d47b27263d024f0a4978346ba4 # v1.11.0
- run: cargo build --release --all-features
Why would you want to use this Action instead?
- Transparent
crossorcargo-hackinstallation and execution withtoolinput - Warnings and errors issued by
cargowill 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 | ||
working-directory |
Directory where to perform cargo command | string | ||
tool |
Tool to use instead of cargo (cross or cargo-hack) |
string | ||
cache-key |
Cache key when using a non-cargo tool |
string | rs-cargo |
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 by setting tool input to cross; the cross executable will be invoked then instead of cargo automatically.
All consequent calls of this action in the same job with tool: cross will use the same cross binary.
on: [push]
name: ARMv7 build
jobs:
linux_arm7:
name: Linux ARMv7
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions-rust-lang/setup-rust-toolchain@9399c7bb15d4c7d47b27263d024f0a4978346ba4 # v1.11.0
with:
targets: armv7-unknown-linux-gnueabihf
- uses: clechasseur/rs-cargo@319e211e9459c5e531afb6d157296765b441572e # v3.0.3
with:
command: build
args: --target armv7-unknown-linux-gnueabihf
tool: cross
License
Contributing
See CONTRIBUTING.
Development
See DEVELOPMENT.