-
Notifications
You must be signed in to change notification settings - Fork 1
200 lines (165 loc) · 5.57 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: ci
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_run:
workflows:
- pr
types:
- completed
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
go-modules:
name: Test and Build Go Modules
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup Cache
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.work.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.23
check-latest: true
cache-dependency-path: go.work.sum
- name: Determine Modules
run: |
WORKSPACE_MODULES=$(go list -f '{{.Dir}}' -m)
ADDITIONAL_MODULES=(
"${GITHUB_WORKSPACE}/external/geth"
)
ALL_MODULES=$(printf "%s\n" "${WORKSPACE_MODULES}" "${ADDITIONAL_MODULES[@]}")
echo "GO_MODULES<<EOF" >> ${GITHUB_ENV}
echo "${ALL_MODULES}" >> ${GITHUB_ENV}
echo "EOF" >> ${GITHUB_ENV}
echo "GO_LINT_MODULES=$(printf "%s " $(echo "${ALL_MODULES}" | sed 's|$|/...|' | grep -v '/external/geth'))" >> ${GITHUB_ENV}
- name: Run Gofmt
run: |
GOFMT_OUTPUT=$(echo ${GO_MODULES} | tr ' ' '\n' | xargs gofmt -d -e -l)
if [ -n "${GOFMT_OUTPUT}" ]; then
echo "The following files are not formatted correctly:"
echo "${GOFMT_OUTPUT}"
exit 1
fi
- name: Run Tidy & Workspace Sync
run: |
echo ${GO_MODULES} | tr ' ' '\n' | xargs -L1 go mod tidy -C
go work sync
git checkout ${{ github.event.pull_request.head.ref }}
git diff --name-only --exit-code . || (echo "Golang modules/workspace not in sync with go.mod/go.sum/go.work/go.work.sum files" && exit 1)
git reset --hard HEAD
- name: Run Lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.61
args: --timeout 15m --verbose ${{ env.GO_LINT_MODULES }}
- name: Run Build
run: echo ${GO_MODULES} | tr ' ' '\n' | xargs -I {} sh -c 'go build -C {} -ldflags=-checklinkname=0 -v ./...' # The -ldflags=-checklinkname=0 is required for the https://github.com/fjl/memsize module and can be removed when the module is no longer used by external/geth: https://github.com/fjl/memsize/commit/09937c23818edfe26b4f6ede71d28126c7f9657c#diff-2b7814d3fca2e99e56c51b6ff2aa313ea6e9da6424804240aa8ad891fdfe0900R9
env:
GOWORK: off
- name: Run Test
run: echo ${GO_MODULES} | tr ' ' '\n' | grep -v '/external/geth' | xargs -I {} sh -c 'go test -short -race {}/...'
- name: Setup Protobuf
uses: bufbuild/buf-setup-action@v1.31.0
- name: Protobuf Version
run: buf --version
- name: Check Protobuf Parity
run: |
make bufgen
git checkout ${{ github.event.pull_request.head.ref }}
git diff --name-only --exit-code . || (echo "Generated files not in parity with the source files." && exit 1)
git reset --hard HEAD
working-directory: p2p
foundry:
name: Foundry Checks and Reports
runs-on: ubuntu-24.04
timeout-minutes: 30
defaults:
run:
working-directory: contracts
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Print Versions
run: |
git --version
node --version
npm --version
forge --version
- name: Run Tests
run: forge clean && forge test -vvv --via-ir
- name: Run Snapshot
run: forge clean && forge snapshot --via-ir
contracts:
name: Test and Build Contracts Scripts
runs-on: ubuntu-24.04
timeout-minutes: 30
defaults:
run:
working-directory: contracts
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Install solhint
run: npm install -g solhint
- name: Print Versions
run: |
git --version
node --version
npm --version
forge --version
solhint --version
- name: Install abigen
run: |
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install -y ethereum
abigen --version
- name: Check ABI Parity
run: |
bash script.sh
git checkout ${{ github.event.pull_request.head.ref }}
git diff --name-only --exit-code . || (echo "Generated files not in parity with the source files." && exit 1)
git reset --hard HEAD
working-directory: contracts-abi
- name: Run solhint solidity linter
run: solhint '**/*.sol'
working-directory: contracts
infrastructure:
uses: ./.github/workflows/infrastructure.yml
secrets: inherit
needs:
- go-modules
- foundry
- contracts