-
Notifications
You must be signed in to change notification settings - Fork 117
135 lines (111 loc) · 4.2 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
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: ubuntu-latest
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: 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: 5
retry_wait_seconds: 5
max_attempts: 3
shell: bash
command: '[ "$(cast balance 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266)" = 10000000000000000000000 ]' # Default address
on_retry_command: docker compose logs
- name: Get address of Bundler contract
run: echo "BUNDLER_CONTRACT_ADDRESS=$(docker compose logs | grep Bundler | awk '{ print $5 }')" >> $GITHUB_ENV
shell: bash
- name: Show environment
run: env
shell: bash
- name: Check that L2 contract was deployed
uses: nick-fields/retry@v2
with:
timeout_seconds: 5
retry_wait_seconds: 5
max_attempts: 3
shell: bash
command: '[ $(cast call $BUNDLER_CONTRACT_ADDRESS "trustedCaller()") = 0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266 ]' # Default address
on_retry_command: docker compose logs
test:
strategy:
fail-fast: true
timeout-minutes: 15
runs-on: ubuntu-latest
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
coverage:
runs-on: ubuntu-latest
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/*' --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/lcov-reporter-action@v0.3.1
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