1
0
Fork 0
mirror of https://github.com/clechasseur/rs-cargo.git synced 2025-12-15 06:58:58 +01:00
📦 GitHub Action for Rust cargo command
renovate[bot] ce47ba38c8
chore(deps): update dependency prettier to ^3.7.4 (#343)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-08 22:35:08 -05:00
.github chore(deps): update actions/setup-node action to v6.1.0 (#345) 2025-12-08 22:34:49 -05:00
.matchers Add clippy test (#30) 2023-08-14 03:05:48 -04:00
__tests__ fix: proper support of toolchain with cargo-hack (#204) 2025-01-10 00:39:15 -05:00
dist chore: update dist 2025-11-18 20:57:25 -05:00
rust_tests Add more rustfmt test (#33) 2023-08-14 23:38:51 -04:00
src fix: proper support of toolchain with cargo-hack (#204) 2025-01-10 00:39:15 -05:00
.editorconfig Start work on 2.0 2023-08-04 14:49:47 -04:00
.gitignore fix: update dependencies, fix moderate security vulnerability (#192) 2024-11-17 22:12:39 -05:00
.npmrc chore: Configure Renovate (#107) 2024-04-07 22:58:00 -04:00
.nvmrc feat!: move to v4.0.0, Node.js 24.x (#304) 2025-08-30 23:52:08 -04:00
.oxlintrc.json chore: replace eslint with oxlint 2025-07-25 01:08:02 -04:00
action.yml feat!: move to v4.0.0, Node.js 24.x (#304) 2025-08-30 23:52:08 -04:00
Cargo.lock Add clippy test (#30) 2023-08-14 03:05:48 -04:00
Cargo.toml Add more rustfmt test (#33) 2023-08-14 23:38:51 -04:00
CODE_OF_CONDUCT.md chore: add more docs 2025-07-25 01:15:04 -04:00
CONTRIBUTING.md chore: add more docs 2025-07-25 01:15:04 -04:00
DEVELOPMENT.md feat!: move to v4.0.0, Node.js 24.x (#304) 2025-08-30 23:52:08 -04:00
jest.config.json Add formatting and linting tools 2020-03-25 08:40:28 +03:00
LICENSE chore: add more docs 2025-07-25 01:15:04 -04:00
package-lock.json chore(deps): update dependency prettier to ^3.7.4 (#343) 2025-12-08 22:35:08 -05:00
package.json chore(deps): update dependency prettier to ^3.7.4 (#343) 2025-12-08 22:35:08 -05:00
README.md chore: add more docs 2025-07-25 01:15:04 -04:00
renovate.json chore(renovate): point to shared Renovate config 2024-04-14 07:22:35 -04:00
SECURITY.md chore: update SECURITY.md 2025-08-31 00:19:36 -04:00
tsconfig.json feat!: move to v4.0.0, Node.js 24.x (#304) 2025-08-30 23:52:08 -04:00

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@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?

  1. Transparent cross or cargo-hack installation and execution with tool input
  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
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

MIT license

Contributing

See CONTRIBUTING.

Development

See DEVELOPMENT.