name: account-integrations/safe

on:
  push:
    branches:
      - main
  pull_request:
    paths:
      - account-integrations/safe/**

defaults:
  run:
    working-directory: ./account-integrations/safe

jobs:
  foundry:
    strategy:
      fail-fast: true

    name: Foundry project
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: recursive

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

      # Uncomment the lines below to install & generate zk assets
      # - working-directory: ./account-integrations/zkp/lib/circom
      #   run: cargo build --release

      # - working-directory: ./account-integrations/zkp/lib/circom
      #   run: cargo install --path circom

      # - uses: actions/setup-node@v3
      #   with:
      #     node-version: "18.x"
      #     cache: "yarn"
      #     cache-dependency-path: account-integrations/zkp/yarn.lock

      # - working-directory: ./account-integrations/zkp
      #   run: yarn install --frozen-lockfile

      # - working-directory: ./account-integrations/zkp
      #   run: yarn build

      # - working-directory: ./account-integrations/safe
      #   run: yarn install --frozen-lockfile

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

      - name: Run Forge tests
        run: |
          forge test -vvv
        id: test

  hardhat:
    strategy:
      fail-fast: true

    name: Hardhat project
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: recursive

      - name: Setup Node 18
        uses: actions/setup-node@v3
        with:
          node-version: "18.x"
          cache: "yarn"
          cache-dependency-path: account-integrations/safe/yarn.lock

      # Uncommment the lines below to install & generate zk assets
      # - working-directory: ./account-integrations/zkp/lib/circom
      #   run: cargo build --release

      # - working-directory: ./account-integrations/zkp/lib/circom
      #   run: cargo install --path circom

      # - working-directory: ./account-integrations/zkp
      #   run: yarn install --frozen-lockfile

      # - working-directory: ./account-integrations/zkp
      #   run: yarn build

      - name: Install Yarn dependencies
        run: yarn install --frozen-lockfile

      - name: Run hardhat compile
        run: yarn hardhat compile
