rs-cargo/README.md

78 lines
2.6 KiB
Markdown
Raw Normal View History

2019-09-12 23:48:44 +03:00
# Rust `cargo` Action
2019-09-15 11:45:45 +03:00
![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)
2019-09-14 20:42:21 +03:00
[![Gitter](https://badges.gitter.im/actions-rs/community.svg)](https://gitter.im/actions-rs/community)
2019-09-12 23:48:44 +03:00
This GitHub Action runs specified [`cargo`](https://github.com/rust-lang/cargo)
command on a Rust language project.
## Example workflow
```yaml
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
2019-09-18 12:55:16 +03:00
args: --release --all-features
2019-09-12 23:48:44 +03:00
```
2019-09-16 10:37:57 +03:00
See [additional recipes here](https://github.com/actions-rs/meta).
2019-09-12 23:48:44 +03:00
## Inputs
2019-09-29 00:34:53 +03:00
| 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`](https://github.com/rust-embedded/cross) instead of `cargo` | bool | false |
2019-09-13 00:21:16 +03:00
2019-09-15 11:45:45 +03:00
## Virtual environments
2019-09-15 12:22:59 +03:00
Note that `cargo` is not available by default for some [virtual environments](https://help.github.com/en/articles/software-in-virtual-environments-for-github-actions);
2019-09-15 11:45:45 +03:00
for example, as for 2019-09-15, `macOS` env is missing it.
You can use [`actions-rs/toolchain`](https://github.com/actions-rs/toolchain)
to install the Rust toolchain with `cargo` included.
## Cross
2019-09-13 00:21:16 +03:00
2019-09-15 11:45:45 +03:00
In order to make cross-compilation an easy process,
this Action can install [cross](https://github.com/rust-embedded/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.
```yaml
on: [push]
2019-09-13 00:21:16 +03:00
2019-09-15 11:45:45 +03:00
name: ARMv7 build
2019-09-13 00:21:16 +03:00
2019-09-15 11:45:45 +03:00
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
```