-
Notifications
You must be signed in to change notification settings - Fork 374
156 lines (137 loc) · 4.97 KB
/
protocol_tests.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
name: Protocol Foundry tests
on:
push:
branches:
- master
- 'release/**'
- 'feat/l2-epoch-system'
- 'martinvol/**'
- 'pahor167/**'
- 'soloseng/**'
pull_request:
branches:
- master
- 'release/**'
- 'feat/l2-epoch-system'
- 'martinvol/**'
- 'pahor167/**'
- 'soloseng/**'
env:
# Increment these to force cache rebuilding
FOUNDRY_CACHE_KEY: 2
# Supported Foundry version defined at celo-org (GitHub organisation) level, for consistency across workflows. Please contact DevOps to update value.
SUPPORTED_FOUNDRY_VERSION: ${{ vars.SUPPORTED_FOUNDRY_VERSION }}
jobs:
check:
defaults:
run:
working-directory: packages/protocol
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Set Swap Space
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c
with:
swap-size-gb: 32
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Fail if there are test with wrong extension
if: success() || failure()
run: |
if tree test-sol | grep -i ".sol" | grep -v ".sol"; then
echo "There are tests with wrong extensions"
tree test-sol | grep -i ".sol" | grep -v ".sol"
exit 1
fi
- name: Foundry cache
id: foundry-cache
uses: actions/cache@v4
with:
path: ./cache
key: ${{ runner.os }}-foundry-cache-${{ env.FOUNDRY_CACHE_KEY }}
- name: Foundry out
id: foundry-out
uses: actions/cache@v4
with:
path: ./out
key: ${{ runner.os }}-foundry-out-${{ env.FOUNDRY_CACHE_KEY }}
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: 'nightly-fa0e0c2ca3ae75895dd19173a02faf88509c0608' # TODO: revert back to env var
- name: Install forge dependencies
run: forge install
# "Run tests" already tries to compile the contracts
# Making it explicit here to have easier to read errors
- name: Compile Contracts
run: forge --version && forge compile
- name: Run unit tests common
# can't use gas limit because some setUp function use more than the limit
run: |
forge test -vvv \
--match-path "test-sol/unit/common/*"
- name: Run unit tests governance/network
if: success() || failure()
run: |
forge test -vvv \
--match-path "test-sol/unit/governance/network/*" \
--block-gas-limit 50000000
- name: Run unit tests governance/validators
if: success() || failure()
run: |
forge test -vvv \
--match-path "test-sol/unit/governance/validators/*" \
--block-gas-limit 50000000
- name: Run unit tests governance/voting
# can't use gas limit because some setUp function use more than the limit
if: success() || failure()
run: |
forge test -vvv \
--match-path "test-sol/unit/governance/voting/*"
- name: Run unit tests stability
if: success() || failure()
run: |
forge test -vvv \
--match-path "test-sol/unit/stability/*" \
--block-gas-limit 50000000
- name: Run unit tests identity
if: success() || failure()
run: |
forge test -vvv \
--match-path "test-sol/unit/identity/*" \
--block-gas-limit 50000000
- name: Fail if there are tests without folder
if: success() || failure()
run: |
if ls test-sol | grep -qi '\.t\.sol'; then
echo "All tests should be in a folder"
exit 1
fi
- name: Run all unit tests in case some were missed (excl. integration and e2e tests)
# can't use gas limit because some setUp function use more than the limit
# Excludes e2e and integration tests, because they require a connection to an anvil devchain
# serving at localhost.
run: |
forge test -vvv \
--match-path "test-sol/unit/*"
- name: Run integration tests (that don't require an anvil devchain)
if: success() || failure()
run: |
forge test -vvv \
--match-path "test-sol/integration/*" \
- name: Generate migrations and run devchain
if: success() || failure()
run: ./scripts/foundry/create_and_migrate_anvil_devchain.sh
- name: Run migration tests against local anvil devchain
run: |
source ./scripts/foundry/constants.sh
FOUNDRY_PROFILE=devchain forge test -vvv \
--match-path "test-sol/devchain/migration/*" \
--fork-url $ANVIL_RPC_URL
- name: Run e2e tests against local anvil devchain
run: |
source ./scripts/foundry/constants.sh
FOUNDRY_PROFILE=devchain forge test -vvv \
--match-path "test-sol/devchain/e2e/*" \
--fork-url $ANVIL_RPC_URL