1
0
Fork 0
mirror of https://github.com/clechasseur/rs-cargo.git synced 2025-12-17 07:18:58 +01:00
📦 GitHub Action for Rust cargo command
Find a file
Charles Lechasseur 319e211e94
fix: update to rs-actions-core 5.0.2, run npm update, get octokit fixes (#223)
* fix: update to `rs-actions-core` 5.0.2, run `npm update`, get octokit fixes

* chore: bump version to 3.0.3
2025-02-14 21:59:26 -05:00
.github/workflows chore(deps): update actions/setup-node action to v4.2.0 (#214) 2025-02-07 00:52:31 -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 fix: update to rs-actions-core 5.0.2, run npm update, get octokit fixes (#223) 2025-02-14 21:59:26 -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(node): move to node20 (#44) 2023-09-04 23:43:28 -04:00
action.yml fix: sensible cache-key default (#203) 2025-01-06 22:22:03 -05: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
CODEOWNERS Add CODEOWNERS 2023-08-12 00:28:57 -04:00
eslint.config.mjs fix: proper support of toolchain with cargo-hack (#204) 2025-01-10 00:39:15 -05:00
jest.config.json Add formatting and linting tools 2020-03-25 08:40:28 +03:00
LICENSE Start work on 2.0 2023-08-04 14:49:47 -04:00
package-lock.json fix: update to rs-actions-core 5.0.2, run npm update, get octokit fixes (#223) 2025-02-14 21:59:26 -05:00
package.json fix: update to rs-actions-core 5.0.2, run npm update, get octokit fixes (#223) 2025-02-14 21:59:26 -05:00
README.md fix: sensible cache-key default (#203) 2025-01-06 22:22:03 -05:00
renovate.json chore(renovate): point to shared Renovate config 2024-04-14 07:22:35 -04:00
tsconfig.eslint.json Refactoring, update dependencies, fix vulnerabilities, update ncc 2023-08-04 23:00:28 -04:00
tsconfig.json Refactoring, update dependencies, fix vulnerabilities, update ncc 2023-08-04 23:00:28 -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@v4
      - uses: actions-rust-lang/setup-rust-toolchain@v1
      - uses: clechasseur/rs-cargo@v3
        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 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@v4
      - uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          targets: armv7-unknown-linux-gnueabihf
      - uses: clechasseur/rs-cargo@v3
        with:
          command: build
          args: --target armv7-unknown-linux-gnueabihf
          tool: cross

License

MIT license