forked from ExocoreNetwork/exocore-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
204 lines (196 loc) · 7.35 KB
/
forge-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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
name: Forge CI
on:
merge_group:
pull_request:
push:
branches:
- main
- release/**
tags:
- "*"
jobs:
setup:
# A full job can be used as a reusable workflow but not a step.
uses: ./.github/workflows/reusable-foundry-setup.yml
with:
# The below line does not accept environment variables,
# so it becomes the single source of truth for the version.
foundry-version: nightly
build:
runs-on: ubuntu-latest
needs: setup
# Takes about 3 minutes
timeout-minutes: 15
outputs:
# The cache-key only contains the version name. It is only used so that the name does not
# need to be repeated everywhere; instead setting the `foundry-version` above suffices.
cache-key: ${{ needs.setup.outputs.cache-key }}
# Github's cache actions are a bit weird to deal with. It wouldn't let me restore the
# binaries to /usr/bin, so I restored them to the original location and added it to PATH.
# This output will let us carry it to other jobs.
installation-dir: ${{ needs.setup.outputs.installation-dir }}
steps:
- name: Restore cached Foundry toolchain
uses: actions/cache/restore@v3
with:
path: ${{ needs.setup.outputs.installation-dir }}
key: ${{ needs.setup.outputs.cache-key }}
- name: Add Foundry to PATH
run: echo "${{ needs.setup.outputs.installation-dir }}" >> "$GITHUB_PATH"
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build
run: forge build
- name: Cache build artifacts
uses: actions/cache/save@v3
with:
path: |
./lib
./out
./cache
./broadcast
key: build-${{ github.event.pull_request.head.sha || github.event.after || github.sha }}
test:
runs-on: ubuntu-latest
needs: build
# No more than a few minutes
timeout-minutes: 5
steps:
- name: Restore cached Foundry toolchain
uses: actions/cache/restore@v3
with:
path: ${{ needs.build.outputs.installation-dir }}
key: ${{ needs.build.outputs.cache-key }}
- name: Add Foundry to PATH
run: echo "${{ needs.build.outputs.installation-dir }}" >> "$GITHUB_PATH"
- name: Checkout repository
uses: actions/checkout@v4
- name: Restore build artifacts
uses: actions/cache/restore@v3
with:
path: |
./lib
./out
./cache
./broadcast
key: build-${{ github.event.pull_request.head.sha || github.event.after || github.sha }}
- name: Test
run: forge test -vvv
- name: Set test snapshot as summary
run: NO_COLOR=1 forge snapshot >> $GITHUB_STEP_SUMMARY
format:
runs-on: ubuntu-latest
needs: build
# No more than a few minutes
timeout-minutes: 5
steps:
- name: Restore cached Foundry toolchain
uses: actions/cache/restore@v3
with:
path: ${{ needs.build.outputs.installation-dir }}
key: ${{ needs.build.outputs.cache-key }}
- name: Add Foundry to PATH
run: echo "${{ needs.build.outputs.installation-dir }}" >> "$GITHUB_PATH"
- name: Checkout repository
uses: actions/checkout@v4
- name: Restore build artifacts
uses: actions/cache/restore@v3
with:
path: |
./lib
./out
./cache
./broadcast
key: build-${{ github.event.pull_request.head.sha || github.event.after || github.sha }}
- name: Check formatting
run: forge fmt --check
extract-base-storage-layout-exocore-gateway:
runs-on: ubuntu-latest
needs: build
# A few minutes
timeout-minutes: 10
steps:
- name: Restore cached Foundry toolchain
uses: actions/cache/restore@v3
with:
path: ${{ needs.build.outputs.installation-dir }}
key: ${{ needs.build.outputs.cache-key }}
- name: Add Foundry to PATH
run: echo "${{ needs.build.outputs.installation-dir }}" >> "$GITHUB_PATH"
- name: Checkout base branch or previous commit
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref || github.event.before }}
# We don't have a `lib` folder to restore for this step, so we
# recursively checkout the submodules. In other steps, we use the
# `lib` folder from the `build` job.
submodules: recursive
- name: Generate base branch layout file
# Note that this `run` will do a `forge build` so we don't need to do it ourselves.
# The build artifacts of this step are not relevant to us either, so we don't need to
# cache them.
run: |
forge inspect src/core/ExocoreGateway.sol:ExocoreGateway storage-layout > ExocoreGateway.base.json
- name: Upload storage layout file as an artifact
uses: actions/upload-artifact@v4
with:
path: ExocoreGateway.base.json
name: compiled-layout-ExocoreGateway-base-${{ github.event.pull_request.base.sha || github.event.after || github.sha }}
extract-storage-layouts:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
contract: [Bootstrap, ClientChainGateway, RewardVault, Vault, ExocoreGateway, ExoCapsule]
# A few minutes
timeout-minutes: 10
steps:
- name: Restore cached Foundry toolchain
uses: actions/cache/restore@v3
with:
path: ${{ needs.build.outputs.installation-dir }}
key: ${{ needs.build.outputs.cache-key }}
- name: Add Foundry to PATH
run: echo "${{ needs.build.outputs.installation-dir }}" >> "$GITHUB_PATH"
- name: Checkout repository
uses: actions/checkout@v4
- name: Restore build artifacts
uses: actions/cache/restore@v3
with:
path: |
./lib
./out
./cache
./broadcast
key: build-${{ github.event.pull_request.head.sha || github.event.after || github.sha }}
- name: Generate storage layout file for ${{ matrix.contract }}
run: |
forge inspect src/core/${{ matrix.contract }}.sol:${{ matrix.contract }} storage-layout > ${{ matrix.contract }}.compiled.json;
- name: Upload storage layout file as an artifact
uses: actions/upload-artifact@v4
with:
path: ${{ matrix.contract }}.compiled.json
name: compiled-layout-${{ matrix.contract}}-${{ github.event.pull_request.head.sha || github.event.after || github.sha }}
combine-storage-layouts:
runs-on: ubuntu-latest
needs:
- extract-base-storage-layout-exocore-gateway
- extract-storage-layouts
# A few minutes
timeout-minutes: 10
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
# No name means all artifacts are downloaded within their respective subfolders
# inside the provided path.
with:
path: combined
- name: Zip up the compiled layouts
run: zip -j compiled-layouts.zip combined/*/*.json
- name: Upload the compiled layouts file as an artifact
uses: actions/upload-artifact@v4
with:
path: compiled-layouts.zip
name: compiled-layouts-${{ github.event.pull_request.head.sha || github.event.after || github.sha }}