misc_utils 4.3.0

A small collection of convenient and utility functions developed for personal use.
Documentation
name: Rust CI
on:
  push:
    branches-ignore:
      - "dependabot/**"
      - "pre-commit-ci-update-config"
  pull_request:
  # Run every Saturday night
  schedule:
    - cron: "0 4 * * 6"

jobs:
  clippy_check:
    strategy:
      fail-fast: false
      matrix:
        os: ["ubuntu-latest", "windows-latest"]
        rust: ["stable"]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: ${{ matrix.rust }}
          components: clippy

      - name: clippy "No Default Features" (${{ matrix.os }} / ${{ matrix.rust }})
        run: cargo clippy
          --quiet
          --workspace
          --no-default-features
          --all-targets
      - name: clippy "Default" (${{ matrix.os }} / ${{ matrix.rust }})
        run: cargo clippy
          --quiet
          --workspace
          --all-targets
      - name: clippy "All Features" (${{ matrix.os }} / ${{ matrix.rust }})
        run: cargo clippy
          --quiet
          --workspace
          --all-features
          --all-targets

  rustfmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          components: rustfmt
      - name: Rustfmt Check
        uses: actions-rust-lang/rustfmt@v1

  build_and_test:
    name: Build and Test
    strategy:
      matrix:
        os: ["ubuntu-latest", "windows-latest"]
        rust: ["stable", "nightly"]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: ${{ matrix.rust }}

      # The tests are split into build and run steps, to see the time impact of each
      # cargo test --all-targets does NOT run doctests
      # since doctests are important this should not be added
      # https://github.com/rust-lang/cargo/issues/6669
      - name: "Test Build (No Default Features / ${{ matrix.os }} / ${{ matrix.rust }})"
        run: cargo test --no-default-features --no-run
      - name: "Test Run (No Default Features / ${{ matrix.os }} / ${{ matrix.rust }})"
        run: cargo test --no-default-features --no-fail-fast

      - name: "Test Build (Default Features / ${{ matrix.os }} / ${{ matrix.rust }})"
        run: cargo test --no-run
      - name: "Test Run (Default Features / ${{ matrix.os }} / ${{ matrix.rust }})"
        run: cargo test --no-fail-fast

      - name: "Test Build (All Features / ${{ matrix.os }} / ${{ matrix.rust }})"
        run: cargo test --all-features  --no-run
      - name: "Test Run (All Features / ${{ matrix.os }} / ${{ matrix.rust }})"
        run: cargo test --all-features --no-fail-fast

  # Added to summarize the matrix (otherwise we would need to list every single
  # job in bors.toml)
  # https://forum.bors.tech/t/bors-with-github-workflows/426
  tests-result:
    name: Tests result
    if: always()
    needs:
      - rustfmt
      - clippy_check
      - build_and_test
    runs-on: ubuntu-latest
    steps:
      - name: Mark the job as a success
        if: "needs.rustfmt.result == 'success' && needs.clippy_check.result == 'success' && needs.build_and_test.result == 'success'"
        run: exit 0
      - name: Mark the job as a failure
        if: "!(needs.rustfmt.result == 'success' && needs.clippy_check.result == 'success' && needs.build_and_test.result == 'success')"
        run: exit 1