Skip to content

Commit c2fa2bf

Browse files
committed
ci: execute gas reports and coverage on each ci run
1 parent 45ae3c0 commit c2fa2bf

File tree

2 files changed

+37
-67
lines changed

2 files changed

+37
-67
lines changed

.github/workflows/comment.yml

+20-36
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,58 @@
1-
name: PR Comment
1+
# By calling this ci via `workflow_call` from another ci it has permissions to comment on prs from forks
2+
# This action expects the a artifact named `content` to be present in the workflow run
3+
# If the artifact contains a pr_number.txt, the action will comment on that pr. If not it comments on the commit.
4+
# The content of the messages composed by concatinating all *.txt files within content into a single file
5+
# If you want to enforce a specific order, you need to name the files in a way that sorts in the desired order
6+
name: Comment
27

38
on:
49
workflow_run:
510
workflows: [Test]
611
types:
712
- completed
813

9-
permissions:
10-
actions: read
11-
issues: write
12-
checks: read
13-
statuses: read
14-
pull-requests: write
15-
1614
jobs:
1715
comment:
1816
name: Comment Bot
1917
runs-on: ubuntu-latest
20-
# workflow run triggers on all types of "completed" including "cancelled" and similar
21-
# we want this action to only run on a success & failure though
22-
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure' }}
2318
steps:
2419
- uses: actions/download-artifact@v4
2520
with:
26-
name: pr_number
27-
path: pr/
21+
name: content
22+
path: /tmp/content
2823
run-id: ${{ github.event.workflow_run.id }}
29-
github-token: ${{ github.token }}
24+
github-token: ${{ secrets.READ_ONLY_PAT }}
3025

3126
- name: Read pr number
3227
id: get_pr_number
33-
run: echo "pr_number=$(cat pr/pr_number.txt)" >> $GITHUB_OUTPUT
28+
run: |
29+
echo "pr_number=$(cat /tmp/content/pr_number.txt)" >> $GITHUB_OUTPUT
30+
rm /tmp/content/pr_number.txt
3431
35-
- uses: actions/download-artifact@v4
36-
with:
37-
name: ${{ github.event.workflow_run.head_sha }}
38-
path: tmp/
39-
run-id: ${{ github.event.workflow_run.id }}
40-
github-token: ${{ github.token }}
32+
- name: Combine
33+
id: combine
34+
run: cat /tmp/content/*.txt > /tmp/all.txt
4135

4236
- name: Find Comment
43-
uses: peter-evans/find-comment@782f37b1a8a2b3e2eb9e86a994f0871e9dc146e3
37+
uses: peter-evans/find-comment@v3
4438
id: fc
4539
if: ${{ steps.get_pr_number.outputs.pr_number != null }}
4640
with:
4741
issue-number: ${{ steps.get_pr_number.outputs.pr_number }}
4842
comment-author: "github-actions[bot]"
49-
body-includes: Foundry report
5043

5144
- name: Create or update pr comment
52-
uses: peter-evans/create-or-update-comment@48bb05bd5554c378187694936d277d48652922e7
45+
uses: peter-evans/create-or-update-comment@v4
5346
if: ${{ steps.get_pr_number.outputs.pr_number != null }}
5447
with:
5548
comment-id: ${{ steps.fc.outputs.comment-id }}
5649
issue-number: ${{ steps.get_pr_number.outputs.pr_number }}
57-
body-file: tmp/template.md
50+
body-file: /tmp/all.txt
5851
edit-mode: replace
5952

60-
- id: get-comment-body
61-
if: ${{ steps.get_pr_number.outputs.pr_number == null }}
62-
run: |
63-
body="$(cat tmp/template.md)"
64-
delimiter="$(openssl rand -hex 8)"
65-
echo "body<<$delimiter" >> $GITHUB_OUTPUT
66-
echo "$body" >> $GITHUB_OUTPUT
67-
echo "$delimiter" >> $GITHUB_OUTPUT
68-
6953
- name: Create or update commit comment
70-
uses: peter-evans/commit-comment@ae7c3825ead23dab7a1ad8cd4df9617ab4bf0b37
54+
uses: peter-evans/commit-comment@v3
7155
if: ${{ steps.get_pr_number.outputs.pr_number == null }}
7256
with:
7357
sha: ${{ github.event.workflow_run.head_sha }}
74-
body: ${{ steps.get-comment-body.outputs.body }}
58+
body-file: /tmp/all.txt

.github/workflows/test.yml

+17-31
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v4
19+
1920
- uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6
2021
with:
2122
node-version-file: .nvmrc
@@ -36,58 +37,43 @@ jobs:
3637
- uses: actions/checkout@v4
3738
with:
3839
submodules: recursive
40+
3941
- uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6
4042
with:
4143
node-version-file: .nvmrc
4244
cache: "npm"
4345

44-
- name: Install Foundry
45-
uses: foundry-rs/foundry-toolchain@8f1998e9878d786675189ef566a2e4bf24869773
46-
with:
47-
version: nightly
48-
4946
- name: Install node dependencies
5047
run: npm ci --prefer-offline --no-audit
5148

52-
- name: Run Forge build
53-
run: |
54-
forge --version | sed -r 's/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g' | tee /tmp/foundry_version ; test ${PIPESTATUS[0]} -eq 0
55-
forge cache ls
56-
forge build | sed -r 's/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g' | tee /tmp/foundry_build ; test ${PIPESTATUS[0]} -eq 0
57-
id: build
49+
- name: Run Foundry setup
50+
uses: bgd-labs/github-workflows/.github/actions/foundry-setup@d738561b5afce35ca3752b28236c9dd68a3fa822
5851

5952
- name: Run Forge tests
60-
run: |
61-
forge test -vv | sed -r 's/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g' | tee /tmp/foundry_test
62-
echo "testStatus=${PIPESTATUS[0]}" >> $GITHUB_ENV
63-
id: test
53+
uses: bgd-labs/github-workflows/.github/actions/foundry-test@d738561b5afce35ca3752b28236c9dd68a3fa822
6454

65-
- name: Create comment body
66-
id: get-comment-body
67-
run: |
68-
printf "Foundry report\n\n" > /tmp/template.md
69-
printf "\`\`\`shell\n$(cat /tmp/foundry_version)\n\`\`\`\n\n" >> /tmp/template.md
70-
printf "<details><summary>Build log</summary>\n\n\`\`\`shell\n$(cat /tmp/foundry_build)\n\`\`\`\n</details>\n\n" >> /tmp/template.md
71-
printf "<details><summary>Test ${{ env.testStatus == 0 && 'success :rainbow:' || 'error :finnadie::x:'}}</summary>\n\n\`\`\`shell\n$(cat /tmp/foundry_test)\n\`\`\`\n</details>\n\n" >> /tmp/template.md
55+
- name: Run Gas report
56+
uses: bgd-labs/github-workflows/.github/actions/foundry-gas-report@d738561b5afce35ca3752b28236c9dd68a3fa822
7257

73-
- uses: actions/upload-artifact@v4
74-
with:
75-
name: ${{ github.event.pull_request.head.sha || github.sha }}
76-
path: /tmp/template.md
58+
- name: Cleanup
59+
# This test will currently fail on coverage due to the gas limit beaing breached with optimizer disabled
60+
run: rm tests/deployments/DeploymentsGasLimits.t.sol
61+
62+
- name: Run Lcov report
63+
uses: bgd-labs/github-workflows/.github/actions/foundry-lcov-report@d738561b5afce35ca3752b28236c9dd68a3fa822
7764

7865
- name: Save PR number
79-
if: github.event_name == 'pull_request'
66+
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
8067
env:
8168
PR_NUMBER: ${{ github.event.number }}
8269
run: |
8370
mkdir -p ./pr
84-
echo $PR_NUMBER > ./pr/pr_number.txt
71+
echo $PR_NUMBER > /tmp/content/pr_number.txt
8572
8673
- uses: actions/upload-artifact@v4
87-
if: github.event_name == 'pull_request'
8874
with:
89-
name: pr_number
90-
path: pr/pr_number.txt
75+
name: content
76+
path: /tmp/content
9177

9278
# we let failing tests pass so we can log them in the comment, still we want the ci to fail
9379
- name: Post test

0 commit comments

Comments
 (0)