-
Notifications
You must be signed in to change notification settings - Fork 121
179 lines (147 loc) · 6.35 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: CI
on:
# CI is run on main because new branches can only access caches from master, not previous branches.
# So building on master allows new PR's to get the cache from before.
push:
branches: [main]
pull_request:
branches: [main]
env:
FOUNDRY_PROFILE: ci
L1_MAINNET_RPC_URL: ${{ secrets.L1_MAINNET_RPC_URL }}
L2_MAINNET_RPC_URL: ${{ secrets.L2_MAINNET_RPC_URL }}
jobs:
build-image:
timeout-minutes: 5
runs-on: ${{ vars.BUILDJET_DISABLED == 'true' && 'ubuntu-latest' || 'buildjet-16vcpu-ubuntu-2204' }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install Docker buildx
uses: docker/setup-buildx-action@v2
- name: Copy .env.local
run: cp .env.local .env
shell: bash
- name: Build Docker images defined in Docker Compose file
uses: docker/bake-action@v3
with:
load: true # Load images into local Docker engine after build
- name: Run containers defined in Docker Compose
shell: bash
run: docker compose up --detach
- name: Check that Anvil is running
uses: nick-fields/retry@v2
with:
timeout_seconds: 15
retry_wait_seconds: 5
max_attempts: 10
shell: bash
command: '[ "$(cast balance 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266)" = 4096000000000000000000 ]' # Default address
on_retry_command: docker compose logs && docker compose ps && cast balance 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
- name: Wait for contract to be deployed
uses: nick-fields/retry@v2
with:
timeout_seconds: 5
retry_wait_seconds: 5
max_attempts: 10
shell: bash
command: |
set -e -o pipefail
docker compose logs | grep Bundler | awk '{ print $5 }'
on_retry_command: docker compose logs
- name: Get contract addresses
run: |
echo "ID_CONTRACT_ADDRESS=$(docker compose logs | grep IdRegistry | awk '{ print $5 }')" >> $GITHUB_ENV
echo "KEY_CONTRACT_ADDRESS=$(docker compose logs | grep KeyRegistry | awk '{ print $5 }')" >> $GITHUB_ENV
echo "STORAGE_CONTRACT_ADDRESS=$(docker compose logs | grep StorageRegistry | awk '{ print $5 }')" >> $GITHUB_ENV
echo "BUNDLER_CONTRACT_ADDRESS=$(docker compose logs | grep Bundler | awk '{ print $5 }')" >> $GITHUB_ENV
shell: bash
- name: Confirm ID Registry contract was deployed
shell: bash
run: '[ $(cast call $ID_CONTRACT_ADDRESS "owner()") = 0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266 ]'
- name: Confirm Key Registry contract was deployed
shell: bash
run: '[ $(cast call $KEY_CONTRACT_ADDRESS "owner()") = 0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266 ]'
- name: Confirm Storage Registry contract was deployed
shell: bash
run: '[ $(cast call $STORAGE_CONTRACT_ADDRESS "paused()") = 0x0000000000000000000000000000000000000000000000000000000000000000 ]'
- name: Confirm Bundler contract was deployed
shell: bash
run: '[ $(cast call $BUNDLER_CONTRACT_ADDRESS "VERSION()") = 0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000a323032332e31312e313500000000000000000000000000000000000000000000 ]'
test:
strategy:
fail-fast: true
timeout-minutes: 15
runs-on: ${{ vars.BUILDJET_DISABLED == 'true' && 'ubuntu-latest' || 'buildjet-16vcpu-ubuntu-2204' }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run forge build
run: |
forge --version
forge build --sizes
- name: Run forge fmt
run: forge fmt --check
- name: Run forge tests
run: forge test -vvv
- name: Check forge snapshots
run: forge snapshot --check --match-contract Gas
halmos:
runs-on: ${{ vars.BUILDJET_DISABLED == 'true' && 'macos-latest' || 'buildjet-16vcpu-ubuntu-2204' }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install foundry
uses: foundry-rs/foundry-toolchain@v1
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install halmos
run: pip install halmos
- name: Run halmos
run: halmos --solver-timeout-assertion 0
coverage:
permissions:
contents: read
pull-requests: write
runs-on: ${{ vars.BUILDJET_DISABLED == 'true' && 'ubuntu-latest' || 'buildjet-2vcpu-ubuntu-2204' }}
steps:
- uses: actions/checkout@v3
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Check code coverage
run: forge coverage --report summary --report lcov
# Ignores coverage results for the test and script directories. Note that because this
# filtering applies to the lcov file, the summary table generated in the previous step will
# still include all files and directories.
# The `--rc lcov_branch_coverage=1` part keeps branch info in the filtered report, since lcov
# defaults to removing branch info.
- name: Filter directories
run: |
sudo apt update && sudo apt install -y lcov
lcov --remove lcov.info 'test/*' 'script/*' 'src/libraries/*' --output-file lcov.info --rc lcov_branch_coverage=1
# Post a detailed coverage report as a comment and deletes previous comments on each push.
- name: Post coverage report
if: github.event_name == 'pull_request' # This action fails when ran outside of a pull request.
uses: romeovs/[email protected]
with:
delete-old-comments: true
lcov-file: ./lcov.info
github-token: ${{ secrets.GITHUB_TOKEN }} # Adds a coverage summary comment to the PR.
# Fail coverage if the specified coverage threshold is not met
- name: Verify minimum coverage
uses: zgosalvez/github-actions-report-lcov@v2
with:
coverage-files: ./lcov.info
minimum-coverage: 94