Skip to content

unstoppabledomains/solidity-sizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

solidity-sizer

A GitHub action that comments the pull request with the size of the Solidity contracts.

Usage

Contracts size and delta

hardhat size-contracts doesn't support git based delta calculation, it uses cache/.hardhat_contract_sizer_output.json to store contracts size data and then just compare new results against this file to get delta.

So, we need two jobs to get the delta between the source and target branches:

  • target-contracts-size will checkout the target branch, run hardhat size-contracts and put cache/.hardhat_contract_sizer_output.json into the artifacts.
  • pr-contracts-size will checkout the source branch, download artifacts and run solidity-sizer which will calculate the delta using hardhat_contract_sizer_output.json from target-contracts-size
on: pull_request

jobs:
  target-contracts-size:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.event.pull_request.base.ref }}
      - uses: actions/setup-node@v2
        with:
          node-version: 16.x
      - run: yarn install
      - run: yarn compile:size
      - uses: actions/upload-artifact@v3
        with:
          name: hardhat-contract-sizer-output
          path: cache/.hardhat_contract_sizer_output.json

  pr-contracts-size:
    runs-on: ubuntu-latest
    needs: target-contracts-size
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: 16.x
      - run: yarn install
      - uses: actions/download-artifact@v3
        with:
          name: hardhat-contract-sizer-output
          path: cache/
      - uses: unstoppabledomains/solidity-sizer@v0.1.0
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Only contracts size

on: pull_request
  contracts-size:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: 16.x
      - run: yarn install
      - uses: actions/download-artifact@v3
        with:
          name: hardhat-contract-sizer-output
          path: cache/
      - uses: unstoppabledomains/solidity-sizer@v0.1.0
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Inputs

Action inputs

Name Description Required Default
GITHUB_TOKEN Token that is used to create comment
command Command that will run hardhat size-contracts yarn run hardhat size-contracts

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published