name: Foundry CI

on:
  pull_request:
    paths:
      - "evm/**"

env:
  FOUNDRY_PROFILE: ci

jobs:
  check:
    strategy:
      fail-fast: true

    name: Foundry Lint & Test
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: evm
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: recursive

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

      - name: Run Forge build
        run: |
          forge --version
          forge build --sizes --via-ir
        id: build

      - name: Run Forge format check
        run:  |
          forge --version
          forge fmt --check
        id: format

      - name: Run Forge tests
        run: |
          forge test -vvv --via-ir
        id: test
        env:
          ETH_RPC_URL: ${{ secrets.ETH_RPC_URL }}