hoard 0.6.1

Hoard backups of files across your filesystem into one location.
Documentation
on:
  push:
  release:
    types: [created]

name: Checks and Releases

jobs:
  changes:
    runs-on: ubuntu-latest
    outputs:
      rust: ${{ steps.filter.outputs.rust }}
      cargo: ${{ steps.filter.outputs.cargo }}
    steps:
      - uses: actions/checkout@v4
      - uses: dorny/paths-filter@v2
        id: filter
        with:
          filters: |
            cargo:
              - 'Cargo.toml'
              - 'Cargo.lock'
            rust:
              - '**/*.rs'

  fossa:
    name: Fossa License Check
    runs-on: ubuntu-latest
    needs: changes
    if: needs.changes.outputs.cargo == 'true'
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - uses: fossa-contrib/fossa-action@v2
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          # Push-only API key
          fossa-api-key: 7b6d2d5fb78bb718019e16184020ef6d

  msrv:
    name: Cargo MSRV
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true
          components: clippy, rustfmt

      - name: Install cargo-msrv
        uses: actions-rs/install@v0.1
        with:
          crate: cargo-msrv
          version: latest
          use-tool-cache: true

      - name: Install cargo-make
        uses: actions-rs/install@v0.1
        with:
          crate: cargo-make
          version: latest
          use-tool-cache: true

      - name: Cargo msrv
        uses: actions-rs/cargo@v1
        with:
          command: make
          args: msrv-verify

  deny:
    name: Cargo deny
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true
          components: clippy, rustfmt

      - name: Install cargo-deny
        uses: actions-rs/install@v0.1
        with:
          crate: cargo-deny
          version: latest
          use-tool-cache: true

      - name: Install cargo-make
        uses: actions-rs/install@v0.1
        with:
          crate: cargo-make
          version: latest
          use-tool-cache: true

      - name: Cargo deny
        uses: actions-rs/cargo@v1
        with:
          command: make
          args: deny

  fmt:
    name: Cargo fmt
    runs-on: ubuntu-latest
    needs: changes
    if: needs.changes.outputs.rust == 'true' || github.event_name == 'release'
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - uses: Swatinem/rust-cache@v2
        with:
          cache-on-failure: true

      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true
          components: clippy, rustfmt

      - name: Cargo fmt
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: -- --check

  operation_upgrade:
    name: Operation Version Upgrade
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - uses: Swatinem/rust-cache@v2
        with:
          cache-on-failure: true

      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true

      - name: Run test script
        run: bash ./operation_upgrade_test.sh

  check-stable:
    name: Check Commit
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        # Linux is handled by the coverage check
        os: ["windows-latest", "macos-latest", "ubuntu-latest"]
    needs: changes
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - uses: Swatinem/rust-cache@v2
        with:
          cache-on-failure: true

      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        if: matrix.os == 'ubuntu-latest'
        with:
          toolchain: stable
          override: true
          components: llvm-tools-preview

      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        if: matrix.os != 'ubuntu-latest'
        with:
          toolchain: stable
          override: true

      - name: Install Grcov
        uses: actions-rs/install@v0.1
        if: matrix.os == 'ubuntu-latest'
        with:
          crate: grcov
          version: latest
          use-tool-cache: true

      - name: Cargo Test
        uses: actions-rs/cargo@v1
        if: matrix.os != 'windows-latest'
        with:
          command: test
          args: --all-features --no-fail-fast -- --test-threads=1
        env:
          RUST_BACKTRACE: '1'
          CARGO_INCREMENTAL: '0'
          RUSTFLAGS: '-Cinstrument-coverage'
          RUSTDOCFLAGS: '-Cinstrument-coverage'
          LLVM_PROFILE_FILE: 'profraw/hoard-cargo-tests-%p-%m.profraw'

      - name: Cargo Test
        uses: actions-rs/cargo@v1
        if: matrix.os == 'windows-latest'
        with:
          command: test
          args: --all-features --no-fail-fast --release -- --test-threads=1
        env:
          RUST_BACKTRACE: '1'
          CARGO_INCREMENTAL: '0'
          RUSTFLAGS: '-Cinstrument-coverage'
          RUSTDOCFLAGS: '-Cinstrument-coverage'
          LLVM_PROFILE_FILE: 'profraw/hoard-cargo-tests-%p-%m.profraw'

      - name: Run grcov
        if: matrix.os == 'ubuntu-latest'
        run: |
          grcov profraw/*.profraw --binary-path target/debug \
            -s . -t lcov --branch --ignore-not-existing --ignore '../**' --ignore '/*' -o coverage.lcov \
          --excl-br-line "($EXCLUDE_DERIVE|$EXCLUDE_PANICS|$EXCLUDE_TRACING|$EXCLUDE_PROPAGATE_ERROR|$EXCLUDE_MANUAL|$EXCLUDE_LONE_CLOSING_BRACE)" \
          --excl-line "($EXCLUDE_DERIVE|$EXCLUDE_PANICS|$EXCLUDE_TRACING|$EXCLUDE_PROPAGATE_ERROR|$EXCLUDE_MANUAL|$EXCLUDE_LONE_CLOSING_BRACE)" \
          --excl-br-start "(grcov: ignore-start|mod tests)" --excl-start "(grcov: ignore-start|mod tests)" \
          --excl-br-stop "grcov: ignore-end" --excl-stop "grcov: ignore-end"
        env:
          RUSTFLAGS: "-Cinstrument-coverage"
          RUSTUP_TOOLCHAIN: "stable"
          HOARD_LOG: "trace"
          EXCLUDE_DERIVE: "#\\[derive\\("
          EXCLUDE_PANICS: "panic!|todo!|unimplemented!|unreachable!"
          EXCLUDE_TRACING: "tracing::(error|warn|info|debug|trace)(_span)?"
          EXCLUDE_PROPAGATE_ERROR: "(return|(Err\\(err(or)?\\)|err(or)?) =>) (Some\\()?Err\\(err(or)?(\\.into\\(\\))?\\)"
          EXCLUDE_MANUAL: "grcov: ignore"
          EXCLUDE_LONE_CLOSING_BRACE: "^\\s*\\}\\s*$"


      - name: Upload to codecov.io
        if: matrix.os == 'ubuntu-latest'
        uses: codecov/codecov-action@v3
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          files: coverage.lcov

  release:
    if: github.event_name == 'release'
    runs-on: ${{ matrix.os }}
    needs: [fmt, check-stable]
    strategy:
      matrix:
        include:
          ## TIER ONE
          - os: "ubuntu-latest"
            target: aarch64-unknown-linux-gnu
            deps: gcc-aarch64-linux-gnu
          - os: "ubuntu-latest"
            target: i686-unknown-linux-gnu
            deps: gcc-i686-linux-gnu
          - os: "ubuntu-latest"
            target: x86_64-unknown-linux-gnu
            deps: gcc
          - os: "macos-11"
            target: x86_64-apple-darwin
          - os: "windows-latest"
            target: i686-pc-windows-msvc
          - os: "windows-latest"
            target: x86_64-pc-windows-msvc
          ## TIER TWO WITH HOST TOOLS
          - os: "ubuntu-latest"
            target: aarch64-unknown-linux-musl
            deps: gcc-aarch64-linux-gnu musl-tools
          - os: "ubuntu-latest"
            target: arm-unknown-linux-gnueabihf
            deps: gcc-arm-linux-gnueabihf
          - os: "ubuntu-latest"
            target: x86_64-unknown-linux-musl
            deps: gcc musl-tools
          - os: "macos-11"
            target: aarch64-apple-darwin
          - os: "windows-latest"
            target: aarch64-pc-windows-msvc
          ## TIER 2 NO HOST TOOLS
          #- os: "ubuntu-latest"
          #  target: aarch64-linux-android
          #  deps: gcc-aarch64-linux-gnu
          #- os: "ubuntu-latest"
          #  target: arm-linux-androideabi
          #  deps: gcc-arm-linux-gnueabi
          - os: "ubuntu-latest"
            target: arm-unknown-linux-musleabihf
            deps: gcc-arm-linux-gnueabihf musl-tools
          #- os: "ubuntu-latest"
          #  target: armv7-linux-androideabi
          #  deps: gcc-arm-linux-gnueabi
          - os: "ubuntu-latest"
            target: i686-unknown-linux-musl
            deps: gcc-i686-linux-gnu musl-tools
          #- os: "ubuntu-latest"
          #  tasrget: i686-linux-android
          #  desps: gcc-i686-linux-gnu
          #- oss: "ubuntu-latest"
          #  tasrget: x86_64-linux-android
          #  desps: gcc

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - uses: Swatinem/rust-cache@v2
        with:
          cache-on-failure: true

      - name: Install stable toolchain - ${{ matrix.target }}
        uses: actions-rs/toolchain@v1
        with:
          target: ${{ matrix.target }}
          toolchain: stable
          override: true
          default: true
          profile: minimal

      - name: Install deps (Linux)
        if: matrix.os == 'ubuntu-latest'
        run: sudo apt-get update && sudo apt-get install ${{ matrix.deps }}

      - name: Update XCode tools
        if: matrix.os == 'macos-11'
        uses: devbotsxyz/xcode-select@v1

      - name: Build and Upload Binary
        uses: taiki-e/upload-rust-binary-action@v1
        with:
          bin: hoard
          target: ${{ matrix.target }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          CARGO_PROFILE_RELEASE_LTO: true
          CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 1
          CARGO_PROFILE_RELEASE_OPT_LEVEL: 3