Skip to content

qRoC/cargo-actions

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Integration Rust Cargo with GitHub Actions

Overview

General result
General result
Error in code
Error in code
Failed test
Failed test

Inputs

  • Required command: Cargo command like build, check, test, etc.
  • args: Arguments for the cargo command.
  • manifest-path: Path to the Cargo.toml. By default, is the working directory.
  • token: GitHub token. Used for enable more powerful annotation system. Strongly recommended*
  • toolchain: Toolchain to use. For example: nightly.

* Default GitHub Actions annotations supports only up to 10 warnings and 10 errors for per the step. With token you up this limit to 1000

Outputs

  • notice_count: Notice count.
  • warning_count: Warning count.
  • failure_count: Failure count.

Example

# if `with.token` is used
permissions:
  checks: write

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: qRoC/cargo-actions@v1
        with:
          command: build
          args: --verbose
          token: ${{ secrets.GITHUB_TOKEN }}

  code_style:
    continue-on-error: true
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: qRoC/cargo-actions@v1
        with:
          command: fmt
          toolchain: nightly
          args: --all -- --check
          token: ${{ secrets.GITHUB_TOKEN }}

  lint:
    continue-on-error: true
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: qRoC/cargo-actions@v1
        with:
          command: clippy
          args: --all-features --all-targets -- -D warnings
          token: ${{ secrets.GITHUB_TOKEN }}

  tests:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: qRoC/cargo-actions@v1
        with:
          command: test
          args: --all-features --no-fail-fast --jobs 1
          token: ${{ secrets.GITHUB_TOKEN }}

  audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: qRoC/cargo-actions@v1
        with:
          command: audit

For developers

  1. Install the dependencies.
$ yarn install
  1. Do some changes.

  2. Build the typescript and package it for distribution.

$ yarn build && yarn package
  1. Run the tests.
$ yarn test
  1. Publish changes.
$ git add -A
$ git commit -m "..."
$ git push origin main
  1. Move distribution tag.
git tag -fa v1 -m "Update v1 tag"
git push origin main --force