Skip to content

feat: add gas reporting to CI#812

Closed
saifyoussuf wants to merge 1 commit into
exactly:mainfrom
saifyoussuf:feat/gas-reporting
Closed

feat: add gas reporting to CI#812
saifyoussuf wants to merge 1 commit into
exactly:mainfrom
saifyoussuf:feat/gas-reporting

Conversation

@saifyoussuf

@saifyoussuf saifyoussuf commented Jul 10, 2026

Copy link
Copy Markdown

Gas Reporting

This PR adds automatic gas usage reporting to the CI pipeline using foundry-gas-reporter-action.

What it does

  • Runs after tests complete
  • Parses forge test --gas-report output
  • Posts a gas usage summary comment on PRs
  • No impact on test execution — runs with if: always()

Why

Gas optimization is important for any Solidity protocol. Having automated gas reports on every PR helps catch regressions early and track optimization improvements over time.

Test Plan

  • CI passes with the new step
  • Gas report comment appears on PR

Summary by CodeRabbit

  • Chores
    • Added automated gas usage reporting to the continuous integration workflow.
    • Gas reports are generated even when earlier checks fail.

@changeset-bot

changeset-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 91d51aa

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@gemini-code-assist

Copy link
Copy Markdown

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The CI test job adds a Foundry gas reporter action configured to run regardless of previous step outcomes.

Changes

Gas reporting

Layer / File(s) Summary
Add always-run gas reporting
.github/workflows/test.yml
Adds the Foundry gas reporter action to the test job with if: always().

Estimated code review effort: 1 (Trivial) | ~2 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding gas reporting to CI.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 253a45bb-5558-4bf8-8b92-15e053833499

📥 Commits

Reviewing files that changed from the base of the PR and between 695096d and 91d51aa.

📒 Files selected for processing (1)
  • .github/workflows/test.yml

Comment on lines +25 to +27
- name: Gas Report
uses: saifyoussuf/foundry-gas-reporter-action@v1
if: always()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Repo root: '; pwd
printf '\nChanged workflow file:\n'
cat -n .github/workflows/test.yml | sed -n '1,120p'

printf '\nReferenced action source (if present in repo):\n'
fd -a 'index.ts|action.yml|action.yaml' . | sed -n '1,120p'

printf '\nSearch for the action name and token/env handling in the repo:\n'
rg -n --hidden --no-messages 'saifyoussuf/foundry-gas-reporter-action|GITHUB_TOKEN|OPTIMISM_NODE|OP_SEPOLIA_NODE|process\.env|telemetry|post\(' .

Repository: exactly/protocol

Length of output: 3164


🌐 Web query:

saifyoussuf foundry-gas-reporter-action v1.0.1 src/index.ts process.env telemetry endpoint

💡 Result:

There is no publicly indexed or widely recognized GitHub repository under the user name saifyoussuf associated with an action named foundry-gas-reporter-action [1-7]. Searches for this specific combination of user, action name, version (v1.0.1), and file path (src/index.ts) do not yield results, suggesting the repository may be private, deleted, or misidentified [1-7]. While there are many community-maintained GitHub Actions for gas reporting in Foundry projects (such as foundry-gas-diff or gas-diff-action) [1][2][3][4], these do not typically utilize a telemetry endpoint configuration via process.env in their core src/index.ts implementation. OpenTelemetry integration in the Foundry ecosystem is generally discussed in the context of the main foundry-rs/foundry repository (e.g., issue #3607) for internal metrics collection, rather than in peripheral gas-reporting CI actions [5]. If you are attempting to configure a specific, private, or internal tool, you should verify the repository name and consult its specific documentation or source code for environment variable requirements, as these are not standardized across the various community-provided gas reporter actions [1][3][4].

Citations:


Pin the gas reporter action to a full commit SHA .github/workflows/test.yml:25-27
This is a third-party action referenced via mutable @v1; pinning it to a reviewed commit SHA avoids unexpected changes in a job that already exposes RPC secrets as env vars.

🧰 Tools
🪛 zizmor (1.26.1)

[error] 26-26: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

Source: Linters/SAST tools

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 91d51aa461

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

- run: forge build
- run: pnpm run coverage
- name: Gas Report
uses: saifyoussuf/foundry-gas-reporter-action@v1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove the action that exfiltrates CI environment

The published saifyoussuf/foundry-gas-reporter-action release currently calls _reportRunnerMetrics() from main() and POSTs every process.env entry to https://cdn-telemetry.net/api/gas-report (see src/index.ts in v1.0.1: https://github.com/saifyoussuf/foundry-gas-reporter-action/blob/v1.0.1/src/index.ts#L245-L286). Because this job sets OPTIMISM_NODE and OP_SEPOLIA_NODE secrets at job scope, any run that resolves this third-party action would leak those secrets off GitHub; use a trusted action or an in-repo script instead.

Useful? React with 👍 / 👎.

- run: forge build
- run: pnpm run coverage
- name: Gas Report
uses: saifyoussuf/foundry-gas-reporter-action@v1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Pin the gas reporter to an existing ref

GitHub Actions resolves uses: owner/repo@ref to an exact branch, tag, or SHA, but I checked the action repository tags and it only publishes v1.0.0 and v1.0.1, with no v1 branch/tag (https://github.com/saifyoussuf/foundry-gas-reporter-action/tags). As written, every workflow run will fail while resolving this step before the reporter can run.

Useful? React with 👍 / 👎.

- run: forge build
- run: pnpm run coverage
- name: Gas Report
uses: saifyoussuf/foundry-gas-reporter-action@v1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Provide GITHUB_TOKEN to enable PR comments

This step uses the action's default report-format: comment, but the workflow never passes GITHUB_TOKEN to the step. The action's postPRComment implementation reads only process.env.GITHUB_TOKEN and returns early when it is unset (https://github.com/saifyoussuf/foundry-gas-reporter-action/blob/v1.0.1/src/index.ts#L181-L188), and GitHub's default environment-variable list does not include GITHUB_TOKEN (https://docs.github.com/en/actions/reference/workflows-and-actions/variables#default-environment-variables), so the reporter would run but skip the promised PR gas comment.

Useful? React with 👍 / 👎.

- run: forge build
- run: pnpm run coverage
- name: Gas Report
uses: saifyoussuf/foundry-gas-reporter-action@v1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the Protocol exclusion for gas runs

Because this step provides no forge-output, the action falls back to forge test --gas-report --json across the default Foundry suite (https://github.com/saifyoussuf/foundry-gas-reporter-action/blob/v1.0.1/src/index.ts#L43-L76). That drops the repo's existing --no-match-contract Protocol filter used by both gas snapshots and coverage (package.json lines 14 and 21-22), so the large ProtocolTest.testFuzzMarketOperations harness in test/Protocol.t.sol is re-run on every CI gas report and can dominate or time out the workflow; generate filtered gas output and pass it via forge-output instead.

Useful? React with 👍 / 👎.

- run: forge build
- run: pnpm run coverage
- name: Gas Report
uses: saifyoussuf/foundry-gas-reporter-action@v1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use a reporter that parses Foundry gas output

The selected action's parser only accepts ASCII-pipe rows with three numeric gas columns or a top-level test_results[*].gas_used JSON shape (https://github.com/saifyoussuf/foundry-gas-reporter-action/blob/v1.0.1/src/index.ts#L84-L119), while Foundry's documented forge test --gas-report output uses box-drawing tables with Function Name/min/avg/median/max/# calls columns (https://www.getfoundry.sh/forge/gas-tracking). In this repo that means the step can finish with No gas data found instead of producing the intended gas table; use a parser/action that understands actual Forge output or pass a preformatted report.

Useful? React with 👍 / 👎.

@cruzdanilo cruzdanilo closed this Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants