pipeprogress 2023.3.0

Progress bar for long pipe operations
Documentation
##################################################
# Name: rust.yml
# Description: Workflow for Rust projects
##################################################

name: Rust

on:

  pull_request:
    branches:
      - trunk
    types:
      - opened
      - reopened
      - synchronize
      - ready_for_review
      - review_requested
    paths-ignore:
      - 'docs/**'
      - '**.md'

env:

  CARGO_TERM_COLOR: always

defaults:

  run:
    shell: bash

jobs:

  #########################
  # Test the package for linting
  # and ensure formatted correctly
  #########################

  cargo_check:

    name: Cargo Check

    runs-on: ${{ matrix.os }}

    timeout-minutes: 60

    strategy:
      fail-fast: true
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            toolchain: stable
          - target: x86_64-unknown-linux-musl
            os: ubuntu-latest
            toolchain: stable
          - target: x86_64-apple-darwin
            os: macos-latest
            toolchain: stable
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            toolchain: stable
          #- target: aarch64-unknown-linux-gnu
          #  os: ubuntu-latest
          #  toolchain: stable
        #exclude:

    steps:

      - id: setup_rust
        name: Setup the Rust environment
        uses: actions-rs/toolchain@v1
        with:
          target: ${{ matrix.target }}
          toolchain: ${{ matrix.toolchain }}
          default: true

      - id: setup_rust_arm64
        name: Setup the Rust environment for ARM64
        if: matrix.target == 'aarch64-unknown-linux-gnu' && matrix.os == 'ubuntu-latest'
        run: |
          sudo apt install gcc-multilib

      - id: checkout_repository
        name: Checkout repository
        uses: actions/checkout@v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          persist-credentials: true

      - id: cache_artifacts_cargo_registry
        name: Cache Cargo registry
        uses: actions/cache@v2
        with:
          path: ~/.cargo/registry
          key: ${{ matrix.target }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ matrix.target }}-cargo-registry-

      - id: cache_artifacts_cargo_index
        name: Cache Cargo index
        uses: actions/cache@v2
        with:
          path: ~/.cargo/git
          key: ${{ matrix.target }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ matrix.target }}-cargo-index-

      - id: cache_artifacts_cargo_target
        name: Cache Cargo build
        uses: actions/cache@v2
        with:
          path: target/release
          key: ${{ matrix.target }}-target-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ matrix.target }}-target-

      - id: cargo_check
        name: Run Cargo check
        run: |
          cargo --version
          cargo check --verbose

      - id: cargo_fmt
        name: Run Cargo format
        run: |
          rustup component add rustfmt
          rustup component list --toolchain ${{ matrix.toolchain }}
          cargo fmt --version
          cargo fmt --all -- --check

      - id: cargo_clippy
        name: Run Cargo clippy
        run: |
          rustup component add clippy
          rustup component list --toolchain ${{ matrix.toolchain }}
          cargo clippy --version
          cargo clippy --all --all-features -- -D warnings

  #########################
  # Run Unit Tests
  #########################

  cargo_test:

    name: Cargo Test

    runs-on: ${{ matrix.os }}

    timeout-minutes: 60

    strategy:
      fail-fast: true
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            toolchain: stable
          - target: x86_64-unknown-linux-musl
            os: ubuntu-latest
            toolchain: stable
          - target: x86_64-apple-darwin
            os: macos-latest
            toolchain: stable
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            toolchain: stable
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
            toolchain: stable
        #exclude:

    steps:

      - id: setup_rust
        name: Setup the Rust environment
        uses: actions-rs/toolchain@v1
        with:
          target: ${{ matrix.target }}
          toolchain: ${{ matrix.toolchain }}
          default: true

      - id: checkout_repository
        name: Checkout repository
        uses: actions/checkout@v2

      - id: cache_artifacts_cargo_registry
        name: Cache Cargo registry
        uses: actions/cache@v2
        with:
          path: ~/.cargo/registry
          key: ${{ matrix.target }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ matrix.target }}-cargo-registry-

      - id: cache_artifacts_cargo_index
        name: Cache Cargo index
        uses: actions/cache@v2
        with:
          path: ~/.cargo/git
          key: ${{ matrix.target }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ matrix.target }}-cargo-index-

      - id: cache_artifacts_cargo_target
        name: Cache Cargo build
        uses: actions/cache@v2
        with:
          path: target/release
          key: ${{ matrix.target }}-target-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ matrix.target }}-target-

      - id: cargo_test
        name: Run Cargo tests
        run: |
          cargo --version
          cargo test --verbose