Skip to content

chore(deps): bump docker/setup-buildx-action from 3.12.0 to 4.0.0 #638

chore(deps): bump docker/setup-buildx-action from 3.12.0 to 4.0.0

chore(deps): bump docker/setup-buildx-action from 3.12.0 to 4.0.0 #638

Workflow file for this run

name: Code Coverage
on:
pull_request:
branches:
- main
jobs:
comment-forge-coverage:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
env:
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}
SEPOLIA_RPC_URL: ${{ secrets.SEPOLIA_RPC_URL }}
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install foundry toolchain
uses: foundry-rs/foundry-toolchain@8789b3e21e6c11b2697f5eb56eddae542f746c10 # v1.7.0
with:
version: stable
cache-key: ${{ github.job }}-${{ github.sha }}
- name: Run Forge build
id: build
run: |
forge --version
forge soldeer update
forge build --sizes
- name: Run Forge coverage
id: coverage
run: |
{
echo 'COVERAGE<<EOF'
echo '| File | % Lines | % Statements | % Branches | % Funcs |'
echo '|------|---------|--------------|------------|---------|'
forge coverage --no-match-coverage script --skip DeploymentAddresses --skip Estimate --report summary | grep '^|' | grep -v 'test/' | grep -v '^|-' | grep -v 'File'
echo 'EOF'
} >> "$GITHUB_OUTPUT"
- name: Verify coverage is updated
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const file = "coverage.txt"
if(!fs.existsSync(file)) {
console.log("Nothing to check");
return
}
const currentCoverage = fs.readFileSync(file, "utf8").trim();
const newCoverage = (`${{ steps.coverage.outputs.COVERAGE }}`).trim();
if (newCoverage != currentCoverage) {
core.setFailed(`Code coverage not updated. Run : forge coverage | grep '^|' | grep -v 'test/' > coverage.txt`);
}
- name: Comment on PR
id: comment
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const {data: comments} = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
})
const botComment = comments.find(comment => comment.user.id === 41898282)
const output = `${{ steps.coverage.outputs.COVERAGE }}`;
const commentBody = `Forge code coverage:\n${output}\n`;
if (botComment) {
github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
})
} else {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
});
}