name: EVM Foundry Continuous Integration

on:
  push:
    branches:
      - main
  pull_request_target:

jobs:
  check:
    name: Foundry
    runs-on: ubuntu-latest
    env:
      RPC_URL: ${{ secrets.ETH_RPC_URL }}
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
        with:
          ref: ${{ github.event.pull_request.head.sha }}
          submodules: recursive

      - name: Install Foundry
        uses: foundry-rs/foundry-toolchain@de808b1eea699e761c404bda44ba8f21aba30b2c

      - name: Check formatting
        run: forge fmt --check
        working-directory: foundry

      - name: Run tests
        run: forge test -vvv
        working-directory: foundry

      - name: Run snapshot
        run: NO_COLOR=1 forge snapshot >> $GITHUB_STEP_SUMMARY
        working-directory: foundry
