Skip to content

Parameterized leverage buffer in vault #228

Parameterized leverage buffer in vault

Parameterized leverage buffer in vault #228

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
- name: Checkout Base Branch
uses: actions/checkout@v3
with:
ref: ${{ github.base_ref }}
- name: Install packages
run: yarn --frozen-lockfile
- name: Compile
run: yarn workspaces run compile
- name: Run gas report script for base branch
env:
MAINNET_NODE_URL: ${{ secrets.MAINNET_NODE_URL }}
run: yarn workspace @perennial/v2-core run gasReport
- name: Upload cache folder
uses: actions/upload-artifact@v4
with:
name: perennial-cache
path: packages/core/cache
if-no-files-found: error
retention-days: 1
include-hidden-files: true
- name: Checkout PR branch
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Download cache folder
uses: actions/download-artifact@v4
with:
name: perennial-cache
path: packages/core/cache
- name: Install packages
run: yarn --frozen-lockfile
- name: Compile and get code size diff
run: ./code-size.sh
- name: Run Gas Report Script for PR branch and get gas diff
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 Diff:') || comment.body.includes('### Gas Report Diff:'));
};
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 Diff:\n\n${code_size}\n`
});
// Post the Gas Report comment
await github.rest.issues.createComment({
...context.repo,
issue_number: prNumber,
body: `### Gas Report Diff:\n\n${gas_report}\n`
});