v2.4 mini #298
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Gas Report and Code Size | |
on: [pull_request] | |
jobs: | |
gas-report-and-code-size: | |
permissions: | |
pull-requests: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18.19 | |
- uses: actions/checkout@v3 | |
- name: Install | |
run: yarn --frozen-lockfile | |
- name: Compile | |
run: yarn workspaces run compile | |
- name: Run Gas Report Script | |
env: | |
MAINNET_NODE_URL: ${{ secrets.MAINNET_NODE_URL }} | |
run: ./gas-report.sh | |
- name: Comment PR with Code Size and Gas Report | |
uses: actions/github-script@v7 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const fs = require('fs'); | |
const prNumber = context.payload.pull_request.number; | |
const isWorkflowComment = (comment) => { | |
return (comment.body.includes('### Code Size:') || comment.body.includes('### Gas Report:')); | |
}; | |
const { data: comments } = await github.rest.issues.listComments({ | |
...context.repo, | |
issue_number: prNumber, | |
}); | |
for (const comment of comments) { | |
if (isWorkflowComment(comment)) { | |
await github.rest.issues.deleteComment({ | |
...context.repo, | |
comment_id: comment.id, | |
}); | |
} | |
} | |
const code_size = fs.readFileSync('code_size.txt', 'utf8'); | |
const gas_report = fs.readFileSync('gas_report.txt', 'utf8'); | |
// Post the Code Size comment | |
await github.rest.issues.createComment({ | |
...context.repo, | |
issue_number: prNumber, | |
body: `### Code Size:\n\`\`\`\n${code_size}\n\`\`\`` | |
}); | |
// Post the Gas Report comment | |
await github.rest.issues.createComment({ | |
...context.repo, | |
issue_number: prNumber, | |
body: `### Gas Report:\n\`\`\`\n${gas_report}\n\`\`\`` | |
}); |