Rubilmax/foundry-gas-diff

forge test --gas-report >> gasreport.ansi fail in Git workflow

Closed this issue · 6 comments

Description

At the moment install the plugins in the git workflow of own repo, this fail in this job

Run touch gasreport.ansi
  touch gasreport.ansi
  forge test --gas-report >> gasreport.ansi
  shell: /usr/bin/bash -e {0}
  env:
    FOUNDRY_FUZZ_SEED: 0xf918dca568a9678b0953a5296872f0139bae
    FOUNDRY_VIA_IR: false
Error: Process completed with exit code 1.

[2]https://github.com/keyper-labs/KeyperModule/actions/runs/3583017651/jobs/6027933980#step:4:2
[3]https://github.com/keyper-labs/KeyperModule/actions/runs/3583017651/jobs/6027933980#step:4:3
[4]https://github.com/keyper-labs/KeyperModule/actions/runs/3583017651/jobs/6027933980#step:4:4
[6]https://github.com/keyper-labs/KeyperModule/actions/runs/3583017651/jobs/6027933980#step:4:6

when run the forge test --gas-report and try to create the gesreport.ansi, this fail in all moments

TRY

i try to changes the yaml file, but i can't found a solutions!!, pls check and let me know how fixed

Hi @alfredolopez80, it seems to be a very specific issue related to your CI setup. I can't offer you my help without access to your project.

Besides, it seems the command fails at running forge test, which is not related to foundry-gas-diff

Not, the exactly command you use i test it on cli and works very well and generate the file, but in the git work flow fail

Then it has something to do with your CI setup, because apparently you are able to run forge test in CLI but not in your CI

Reminder: foundry-gas-diff is not forge

Not the exactly command you use i test it on cli and works very well and generate the file, but in the git work flow fail

Let me share the complete yaml file

Yeap, i agree i add this file: foundry-gas-diff.yml into the path ./github/workflows/

name: Report gas diff

on:
  push:
    branches:
      - dev
  pull_request:
    # Optionally configure to run only for changes in specific files. For example:
    paths:
    - src/**
    # - test/**
    - foundry.toml
    - remappings.txt
    - .github/workflows/foundry-gas-diff.yml

jobs:
  compare_gas_reports:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: recursive

      - name: Install Foundry
        uses: onbjerg/foundry-toolchain@v1
        with:
          version: nightly
      # Add any step generating a gas report to a temporary file named gasreport.ansi. For example:
      - name: Run tests
        env:
          # make fuzzing semi-deterministic to avoid noisy gas cost estimation
          # due to non-deterministic fuzzing (but still use pseudo-random fuzzing seeds)
          # gasreport.ansi <- this file name should be unique in your repository!
          FOUNDRY_FUZZ_SEED: 0x${{ github.event.pull_request.base.sha || github.sha }}
          FOUNDRY_VIA_IR: false
        run: |
          touch gasreport.ansi
          forge test --gas-report >> gasreport.ansi
      - name: Compare gas reports
        uses: Rubilmax/foundry-gas-diff@v3.11
        with:
          summaryQuantile: 0.9 # only display the 10% most significant gas diffs in the summary (defaults to 20%)
          sortCriteria: avg,max # sort diff rows by criteria
          sortOrders: desc,asc # and directions
          ignore: test-foundry/**/* # filter out gas reports from specific paths (test/ is included by default)
        id: gas_diff

      - name: Add gas diff to sticky comment
        if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
        uses: marocchino/sticky-pull-request-comment@v2
        with:
          # delete the comment in case changes no longer impact gas costs
          delete: ${{ !steps.gas_diff.outputs.markdown }}
          message: ${{ steps.gas_diff.outputs.markdown }}

Need additional setting in my repo?? pls let me know

In additional this repo I have another yaml: node.js.yml, this this configuration:

on: [push]

name: test

jobs:
  check:
    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

      - name: Set Env Vars
        env:
          MASTER_COPY_ADDRESS: "0xd4a1E956fFe2D07CD71c8fABf538f2BfC0e3899B"
          PROXY_FACTORY_ADDRESS: "0xEAb613456d3efD309101BB02872BEdCecE2879E2"
          KEYPER_MODULE_ADDRESS: "0xc74f6cAFb3e89006FE9c0E8Be8Dc06888e178F1b"
          OWNER_1: "0x9CDd325E49A6a8a82288fdC3B6C14b25221D1Cfa"
          OWNER_2: "0xEd4AD3605740D6a9232e05F4d8A2b3377f81a8AA"
          THRESHOLD: 1
          FOUNDRY_VIA_IR: true
        run: |
          touch .env
          echo "MASTER_COPY_ADDRESS=$MASTER_COPY_ADDRESS" >> .env
          echo "PROXY_FACTORY_ADDRESS=$PROXY_FACTORY_ADDRESS" >> .env
          echo "KEYPER_MODULE_ADDRESS=$KEYPER_MODULE_ADDRESS" >> .env
          echo "OWNER_1=$OWNER_1" >> .env
          echo "OWNER_2=$OWNER_2" >> .env
          echo "THRESHOLD=$THRESHOLD" >> .env
          echo "FOUNDRY_VIA_IR=$FOUNDRY_VIA_IR" >> .env

      - name: Run tests
        run: forge test -vvv --gas-report

      - name: Run coverage
        run: forge coverage

I think is not problem, but let me know, if need enable something else!!

Please invite me into your repository and create an appropriate issue in your repository, as it has nothing to do with foundry-gas-diff. Closing this now.