diff --git a/.github/workflows/automation.yml b/.github/workflows/automation.yml index b22e8edc6..cd8461010 100644 --- a/.github/workflows/automation.yml +++ b/.github/workflows/automation.yml @@ -5,21 +5,21 @@ on: types: [opened, edited, synchronize] jobs: - triage: - runs-on: protocol-x64-16core - name: Labels - permissions: - contents: read - pull-requests: write + # triage: + # runs-on: protocol-x64-16core + # name: Labels + # permissions: + # contents: read + # pull-requests: write - steps: - - name: Checkout code - uses: actions/checkout@v4 + # steps: + # - name: Checkout code + # uses: actions/checkout@v4 - - uses: actions/labeler@v5 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" - sync-labels: true + # - uses: actions/labeler@v5 + # with: + # repo-token: "${{ secrets.GITHUB_TOKEN }}" + # sync-labels: true lint-pr-title: runs-on: ubuntu-latest diff --git a/.github/workflows/foundry-advanced.yml b/.github/workflows/foundry-advanced.yml new file mode 100644 index 000000000..2e627e123 --- /dev/null +++ b/.github/workflows/foundry-advanced.yml @@ -0,0 +1,114 @@ +name: Foundry + +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + + +env: + FOUNDRY_PROFILE: medium + +jobs: + # ----------------------------------------------------------------------- + # Forge Test + # ----------------------------------------------------------------------- + + test-suite: + name: Test + runs-on: protocol-x64-16core + strategy: + matrix: + suite: [Fork] + max-parallel: 1 + + steps: + # Check out repository with all submodules for complete codebase access. + - uses: actions/checkout@v4 + with: + submodules: recursive + + # Restore Forge cache + - name: Cache Forge Build + uses: actions/cache@v3 + with: + path: | + cache/ + out/ + key: ${{ runner.os }}-forge-${{ hashFiles('**/foundry.toml', '**/remappings.txt', 'src/**/*.sol', 'lib/**/*.sol') }} + restore-keys: | + ${{ runner.os }}-forge- + + # Install the Foundry toolchain. + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: stable + + # Run Forge's formatting checker to ensure consistent code style. + - name: "Forge Fmt" + run: | + forge fmt --check + FOUNDRY_PROFILE=test forge fmt --check + id: fmt + + # Build the project and display contract sizes. + - name: Forge Build + run: | + forge --version + forge build --sizes + + # # Run the test suite in parallel based on the matrix configuration. + # - name: Run ${{ matrix.suite }} tests + # run: | + # case "${{ matrix.suite }}" in + # Fork) forge test --match-contract Integration --fork-url "${{ secrets.RPC_MAINNET }}" ;; + # esac + # env: + # FOUNDRY_PROFILE: ${{ matrix.suite == 'Fork' && 'forktest' || 'medium' }} + + # Start Anvil with a forked state from mainnet + - name: Start Anvil Fork + run: | + # Show Anvil version + anvil --version + + # Start Anvil with the latest block and public RPC endpoint + anvil --fork-url https://eth.llamarpc.com \ + --port 8545 \ + --chain-id 1 \ + --block-time 12 \ + --no-rate-limit \ + --fork-block-number 22179220 & + + # Give it time to start up + sleep 10 + + # Check if Anvil is running + if ! curl -s -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545 > /dev/null; then + echo "Anvil failed to start properly" + exit 1 + fi + + # Save the PID so we can kill it later + echo $! > anvil.pid + + # Run the test suite with the local Anvil instance + - name: Run ${{ matrix.suite }} tests + run: | + case "${{ matrix.suite }}" in + Fork) forge test --match-contract Integration --fork-url http://localhost:8545 --fork-retries 1 -vvv ;; + esac + env: + FOUNDRY_PROFILE: ${{ matrix.suite == 'Fork' && 'forktest' || 'medium' }} + RPC_MAINNET: "http://localhost:8545" # Set the environment variable to point to Anvil + + # Clean up Anvil when done + - name: Clean up Anvil + if: always() + run: | + if [ -f anvil.pid ]; then + kill $(cat anvil.pid) || true + fi \ No newline at end of file diff --git a/.github/workflows/foundry.yml b/.github/workflows/foundry.yml index d5d8f430b..7b0fd1bc7 100644 --- a/.github/workflows/foundry.yml +++ b/.github/workflows/foundry.yml @@ -5,14 +5,11 @@ on: pull_request: push: branches: - - "dev" + - main env: FOUNDRY_PROFILE: medium - RPC_MAINNET: ${{ secrets.RPC_MAINNET }} - RPC_HOLESKY: ${{ secrets.RPC_HOLESKY }} - CHAIN_ID: ${{ secrets.CHAIN_ID }} jobs: # ----------------------------------------------------------------------- @@ -24,7 +21,7 @@ jobs: runs-on: protocol-x64-16core strategy: matrix: - suite: [Unit, Integration, Fork] + suite: [Unit, Integration] steps: # Check out repository with all submodules for complete codebase access. @@ -68,7 +65,6 @@ jobs: case "${{ matrix.suite }}" in Unit) forge test --no-match-contract Integration ;; Integration) forge test --match-contract Integration ;; - Fork) forge test --match-contract Integration ;; esac env: FOUNDRY_PROFILE: ${{ matrix.suite == 'Fork' && 'forktest' || 'medium' }} @@ -80,8 +76,8 @@ jobs: continuous-fuzzing: name: Test (Intense) runs-on: protocol-x64-16core - # Only run on push events to dev branch, not on PR events - if: github.event_name == 'push' && github.ref == 'refs/heads/dev' + # Only run on push events to main branch, not on PR events + if: github.event_name == 'push' && github.ref == 'refs/heads/main' strategy: fail-fast: true steps: @@ -120,7 +116,7 @@ jobs: echo -e "\033[1;33mWarning: This workflow may take several hours to complete.\033[0m" echo -e "\033[1;33mThis intense fuzzing workflow is optional but helps catch edge cases through extended testing.\033[0m" FOUNDRY_PROFILE=intense forge test -vvv - + # ----------------------------------------------------------------------- # Forge Storage Diff # ----------------------------------------------------------------------- @@ -164,13 +160,15 @@ jobs: run-coverage: name: Coverage runs-on: protocol-x64-16core - # Only run coverage checks on dev, testnet-holesky, and mainnet branches, or PRs targeting these branches + # Only run coverage checks on main, preprod, testnet, and mainnet branches, or PRs targeting these branches if: | - github.ref == 'refs/heads/dev' || - github.ref == 'refs/heads/testnet-holesky' || + github.ref == 'refs/heads/main' || + github.ref == 'refs/heads/preprod' || + github.ref == 'refs/heads/testnet' || github.ref == 'refs/heads/mainnet' || - github.base_ref == 'dev' || - github.base_ref == 'testnet-holesky' || + github.base_ref == 'main' || + github.base_ref == 'preprod' || + github.base_ref == 'testnet' || github.base_ref == 'mainnet' strategy: fail-fast: true