name: Setup
runs:
  using: composite
  steps:
    - uses: actions/setup-node@v3
      with:
        node-version-file: ".nvmrc"
        registry-url: https://registry.npmjs.org

    - name: Set up Bun
      uses: oven-sh/setup-bun@v1
      with:
        bun-version: 1.0.9

    - uses: pnpm/action-setup@v2
      name: Install pnpm
      with:
        version: 8.10.2
        run_install: false

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

    - name: Get pnpm store directory
      shell: bash
      run: |
        echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

    - uses: actions/cache@v3
      name: Setup pnpm cache
      with:
        path: ${{ env.STORE_PATH }}
        key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
        restore-keys: |
          ${{ runner.os }}-pnpm-store-

    - name: Install dependencies
      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

