positive 0.8.0

A type-safe wrapper for guaranteed positive decimal values
Documentation
name: Build

on:
  push:
    branches:
      - '**'
  pull_request:
    branches:
      - main
      - 'release/**'

permissions:
  contents: read

concurrency:
  group: build-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: always
  CARGO_NET_RETRY: 3
  RUSTUP_MAX_RETRIES: 3

jobs:
  # Portability. The crate is pure Rust over rust_decimal with no platform
  # code, so one job per supported OS family is enough to catch a regression;
  # the previous matrix ran two Ubuntu versions, which tested nothing the other
  # did not.
  build:
    name: build (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - macos-latest
          - windows-latest

    steps:
      - name: Checkout
        # actions/checkout v7.0.1
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1

      # One toolchain step, no curl, no retry wrapper, no failure-only
      # fallback. The previous job installed rustup by piping curl into sh
      # inside a retry action, then ran a second setup step, then declared a
      # fallback `if: failure()` that could never run because the steps before
      # it had already failed the job.
      - name: Install Rust
        # dtolnay/rust-toolchain master (the generic action; the version branches
        # such as `1.14` hardcode that Rust release and reject a `toolchain` input)
        uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772
        id: toolchain
        with:
          toolchain: stable

      - name: Cache Rust dependencies
        # actions/cache v6.1.0
        uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9
        with:
          path: |
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          # Keyed on the toolchain as well as the manifest: a cache built by a
          # different rustc cannot be reused, and the previous key omitted it.
          # `cachekey` comes from the `id: toolchain` step above — without that
          # id the expression expands empty and the scoping silently does
          # nothing. The restore key carries the toolchain too, so a partial
          # restore cannot cross toolchains either.
          # ~/.cargo/bin is no longer cached, so a stale binary cannot shadow a
          # pinned install.
          key: ${{ runner.os }}-build-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('**/Cargo.toml') }}
          restore-keys: |
            ${{ runner.os }}-build-${{ steps.toolchain.outputs.cachekey }}-

      - name: Build
        run: cargo build --all-features --all-targets

  # Minimum supported Rust version. `rust-version` in Cargo.toml is a promise
  # to consumers, so it is verified rather than asserted.
  #
  # The library only: dev-dependencies such as criterion do not constrain
  # anyone depending on this crate. 1.88 is required by utoipa 6.
  msrv:
    name: msrv (1.88, library)
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        # actions/checkout v7.0.1
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1

      - name: Install MSRV toolchain
        # dtolnay/rust-toolchain master (the generic action; the version branches
        # such as `1.14` hardcode that Rust release and reject a `toolchain` input)
        uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772
        with:
          toolchain: '1.88'

      - name: Cache Rust dependencies
        # actions/cache v6.1.0
        uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9
        with:
          path: |
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-msrv-1.88-${{ hashFiles('**/Cargo.toml') }}
          restore-keys: |
            ${{ runner.os }}-msrv-1.88-

      # `+1.88` overrides rust-toolchain.toml, which pins `stable` for local
      # development; without it cargo would silently use stable here and the
      # job would prove nothing.
      # Printed and asserted, not assumed. rust-toolchain.toml pins `stable`
      # for local development and silently overrides whatever the runner has
      # installed, so without the `+1.88` override and this check the job
      # would go green while compiling on stable and proving nothing.
      - name: Confirm the toolchain really is 1.88
        run: |
          rustc +1.88 --version
          rustc +1.88 --version | grep -q '^rustc 1\.88\.' \
            || { echo "MSRV job is not running on 1.88"; exit 1; }

      - name: Check the library at MSRV, in every feature configuration
        run: |
          cargo +1.88 check --lib --all-features
          cargo +1.88 check --lib --no-default-features