GitHub Actions best practices for Rust projects

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • fluvio

    Lean and mean distributed stream processing system written in rust and web assembly.

  • Thanks for reading, I hope this can be helpful to others who are also setting up GitHub actions with Rust projects. If you want to learn more about the Fluvio project, feel free to check out our GitHub or come join our community Discord.

  • sccache

    Sccache is a ccache-like tool. It is used as a compiler wrapper and avoids compilation when possible. Sccache has the capability to utilize caching in remote storage environments, including various cloud storage options, or alternatively, in local storage.

  • # .github/workflows/ci.yml name: CI on: pull_request: workflow_dispatch: jobs: tests: name: ${{ matrix.make.name }} (${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] rust: [stable] make: - name: Clippy task: "check-clippy" - name: Unit tests task: "build-all-test run-all-unit-test" - name: Doc tests task: "run-all-doc-test" include: - os: ubuntu-latest sccache-path: /home/runner/.cache/sccache - os: macos-latest sccache-path: /Users/runner/Library/Caches/Mozilla.sccache exclude: - os: macos-latest rust: stable make: name: Clippy env: RUST_BACKTRACE: full RUSTC_WRAPPER: sccache RUSTV: ${{ matrix.rust }} SCCACHE_CACHE_SIZE: 2G SCCACHE_DIR: ${{ matrix.sccache-path }} # SCCACHE_RECACHE: 1 # Uncomment this to clear cache, then comment it back out steps: - uses: actions/checkout@v2 - name: Install sccache (ubuntu-latest) if: matrix.os == 'ubuntu-latest' env: LINK: https://github.com/mozilla/sccache/releases/download SCCACHE_VERSION: 0.2.13 run: | SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl mkdir -p $HOME/.local/bin curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache echo "$HOME/.local/bin" >> $GITHUB_PATH - name: Install sccache (macos-latest) if: matrix.os == 'macos-latest' run: | brew update brew install sccache - name: Install Rust ${{ matrix.rust }} uses: actions-rs/toolchain@v1 with: toolchain: ${{ matrix.rust }} profile: minimal override: true - name: Cache cargo registry uses: actions/cache@v2 continue-on-error: false with: path: | ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: | ${{ runner.os }}-cargo- - name: Save sccache uses: actions/cache@v2 continue-on-error: false with: path: ${{ matrix.sccache-path }} key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }} restore-keys: | ${{ runner.os }}-sccache- - name: Start sccache server run: sccache --start-server - name: ${{ matrix.make.name }} run: make ${{ matrix.make.task }} - name: Print sccache stats run: sccache --show-stats - name: Stop sccache server run: sccache --stop-server || true

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • cache

    Cache dependencies and build outputs in GitHub Actions

  • Use the GitHub actions cache to save the sccache cache directory

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts