foundryup 0.0.7

Manage foundry toolchain installations with ease
name: CI

permissions: {}

on:
  push:
    branches: [master]
  pull_request:
  merge_group:

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: full

jobs:
  test:
    runs-on: ${{ matrix.os }}
    timeout-minutes: 30
    permissions:
      contents: read
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: depot-ubuntu-22.04
            target: x86_64-unknown-linux-gnu
            platform: linux
            arch: amd64
          - os: depot-ubuntu-22.04-arm
            target: aarch64-unknown-linux-gnu
            platform: linux
            arch: arm64
          - os: depot-ubuntu-22.04
            target: x86_64-unknown-linux-musl
            platform: alpine
            arch: amd64
          - os: depot-ubuntu-22.04-arm
            target: aarch64-unknown-linux-musl
            platform: alpine
            arch: arm64
          - os: macos-14
            target: x86_64-apple-darwin
            platform: darwin
            arch: amd64
          - os: macos-latest
            target: aarch64-apple-darwin
            platform: darwin
            arch: arm64
          - os: depot-windows-latest
            target: x86_64-pc-windows-msvc
            platform: win32
            arch: amd64
    steps:
      - uses: actions/checkout@v7
        with:
          persist-credentials: false
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
      - name: Install musl-tools
        if: contains(matrix.target, 'musl')
        run: |
          sudo apt-get update
          sudo apt-get install -y musl-tools
          if [ "${{ matrix.target }}" = "aarch64-unknown-linux-musl" ]; then
            sudo apt-get install -y gcc-aarch64-linux-gnu
          fi
      - uses: Swatinem/rust-cache@v2
        with:
          cache-on-failure: true
          cache-targets: false
          prefix-key: v1-rust
      - uses: taiki-e/install-action@nextest
      - name: Build
        run: cargo build --target ${{ matrix.target }}
      - name: Test
        run: cargo nextest run --no-fail-fast --target ${{ matrix.target }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  typos:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v7
        with:
          persist-credentials: false
      - uses: crate-ci/typos@cf5f1c29a8ac336af8568821ec41919923b05a83 # v1

  shellcheck:
    runs-on: depot-ubuntu-latest
    timeout-minutes: 5
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Shellcheck
        shell: bash
        run: ./.github/scripts/shellcheck.sh

  clippy:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v7
        with:
          persist-credentials: false
      - uses: dtolnay/rust-toolchain@fa04a1451ff1842e2626ccb99004d0195b455a88 # master
        with:
          toolchain: nightly
          components: clippy
      - uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1
      - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
        with:
          cache-on-failure: true
      - run: cargo clippy --workspace --all-targets --all-features
        env:
          RUSTFLAGS: -Dwarnings

  rustfmt:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v7
        with:
          persist-credentials: false
      - uses: dtolnay/rust-toolchain@fa04a1451ff1842e2626ccb99004d0195b455a88 # master
        with:
          toolchain: nightly
          components: rustfmt
      - run: cargo fmt --all --check

  ci-success:
    runs-on: ubuntu-latest
    if: always()
    needs:
      - test
      - typos
      - shellcheck
      - clippy
      - rustfmt
    timeout-minutes: 30
    steps:
      - name: Decide whether the needed jobs succeeded or failed
        uses: re-actors/alls-green@release/v1
        with:
          jobs: ${{ toJSON(needs) }}