name: Setup
runs:
  using: composite
  steps:
    - uses: pnpm/action-setup@v2
      with:
        version: 8.6.0

    - uses: actions/setup-node@v3
      with:
        node-version-file: ".nvmrc"
        registry-url: https://registry.npmjs.org
        cache: pnpm

    - name: Install Foundry
      uses: foundry-rs/foundry-toolchain@v1
      with:
        version: nightly

    # Workaround for parallel building with forge:
    # https://github.com/foundry-rs/foundry/issues/4736
    - name: Setup forge hack
      shell: bash
      run: forge build

    - name: Install node modules
      run: pnpm install --frozen-lockfile
      shell: bash

    - name: Derive appropriate SHAs for base and head for `nx affected` commands
      uses: nrwl/nx-set-shas@v3

    - name: Echo nx shas
      run: |
        echo "nx using following shas:"
        echo "BASE: ${{ env.NX_BASE }}"
        echo "HEAD: ${{ env.NX_HEAD }}"
      shell: bash

