-
Notifications
You must be signed in to change notification settings - Fork 2
283 lines (270 loc) · 13 KB
/
rust-lit-node-group-unit-and-integration-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
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# This workflow groups up the unit tests, the standard node build, and the tests that use the standard node build (integration tests, version upgrade tests)
name: rust-lit-node-group-unit-and-integration-tests
on:
workflow_dispatch: {}
workflow_call:
push:
paths:
- rust/lit-node/**
- .github/workflows/rust-lit-node-integration-tests.yml
- .github/workflows/rust-lit-node-build.yml
- .github/workflows/rust-lit-node-unit-tests.yml
- .github/workflows/rust-lit-node-version-upgrade-tests.yml
- .github/workflows/rust-lit-node-group-unit-and-integration-tests.yml
- scripts/github/**
branches:
- master
- develop
- datil
env:
CARGO_TERM_COLOR: always
RUST_LOG_STYLE: always
RUST_LOG: warn,lit_node=trace,web_user_tests=trace,integration_tests=trace,ecdsa=trace,test=trace
RUST_BACKTRACE: full
LIT_LOGGING_SERVICE_DISABLED: 1
LIT_CELO_DEPLOYER_PRIVATE_KEY: '0x3178746f7ae6a309d14444b4c6c85a96a4be2f53fa8950dea241d232f3e6c166'
LIT_ALFAJORES_DEPLOYER_PRIVATE_KEY: '0x3178746f7ae6a309d14444b4c6c85a96a4be2f53fa8950dea241d232f3e6c166'
LIT_MUMBAI_DEPLOYER_PRIVATE_KEY: '0x3178746f7ae6a309d14444b4c6c85a96a4be2f53fa8950dea241d232f3e6c166'
LIT_POLYGON_DEPLOYER_PRIVATE_KEY: '0x3178746f7ae6a309d14444b4c6c85a96a4be2f53fa8950dea241d232f3e6c166'
# the above are empty, do not put money in them
IN_GITHUB_CI: 1
LIT_LOGGING_TIMESTAMP: 1 # force adding timestamp since the CI timestamps are wrong
CARGO_INCREMENTAL: 0
IPFS_API_KEY: ${{ secrets.IPFS_API_KEY }}
defaults:
run:
shell: bash
working-directory: rust/lit-node
jobs:
# check if we need to build. this is necessary to make this workflow file be able to be run independently of master-trigger, which builds before calling this workflow. for example, on push to a branch, we want to run this workflow without having to run the master-trigger first.
build-if-needed:
uses: ./.github/workflows/rust-lit-node-build-if-needed.yml
with:
build_features: lit-actions,testing
secrets: inherit
# run the unit tests
lit_node_unit_tests:
needs: build-if-needed
runs-on: warp-ubuntu-latest-x64-8x # change to LargeRunner to run on github. Change to self-hosted to run on our own runner. Change to buildjet-8vcpu-ubuntu-2204 to run on buildjet with 8 cpus
timeout-minutes: 40
services:
anvil:
image: litptcl/anvil-lit:latest
ports:
- 8545:8545
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
steps:
- name: Clean workspace
working-directory: ${{ github.workspace }}
run: |
rm -rf ../../lit-assets
mkdir -p ${{ github.workspace }}
- name: Install deps
working-directory: ${{ github.workspace }}
run: sudo apt-get update && sudo apt-get install -y libudev-dev libsqlite3-dev cmake protobuf-compiler
- name: Checkout lit-assets
uses: actions/checkout@v3
- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable # keep this up to date with rust/lit-node/rust-toolchain.toml
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
cache-all-crates: 'true'
cache-provider: 'buildjet'
workspaces: |
rust/lit-node
- name: Install nextest
run: curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
- name: Setup local files for testing
run: make setup-local-files
# - name: Setup interactive ssh session
# uses: Warpbuilds/[email protected]
# with:
# limit-access-to-actor: true
- name: Run unit tests (lib and binaries)
run: 'cargo nextest run --final-status-level pass --profile unit-tests --lib --bin lit_node --nocapture --'
# after the standard build is done, run the integration tests
lit_node_integration_tests:
needs: build-if-needed
runs-on: warp-ubuntu-latest-x64-8x # change to LargeRunner to run on github. Change to self-hosted to run on our own runner. Change to buildjet-8vcpu-ubuntu-2204 to run on buildjet with 8 cpus
timeout-minutes: 45
strategy:
matrix:
partition: [1, 2, 3]
services:
anvil:
image: litptcl/anvil-lit:latest
ports:
- 8545:8545
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
steps:
- name: Install deps
working-directory: ${{ github.workspace }}
run: sudo apt-get update && sudo apt-get install -y zstd
- name: Checkout lit-assets
uses: actions/checkout@v3
- name: Use Node.js
uses: buildjet/setup-node@v3
with:
node-version: 18.17.0
cache: npm
cache-dependency-path: ${{ github.workspace }}/blockchain/contracts/package-lock.json
- name: Install dependencies for blockchain/contracts
working-directory: ${{ github.workspace }}/blockchain/contracts
run: npm install
- name: Run npx hardhat compile for blockchain/contracts
working-directory: ${{ github.workspace }}/blockchain/contracts
run: npx hardhat compile
- run: mkdir -p ~/.cargo/bin
- name: Install nextest
run: curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
- name: Download archive
uses: actions/download-artifact@v4
with:
name: nextest-archive-lit-actions,testing
path: rust/lit-node/
- name: Unzip archive so that we can get the lit_node binary
run: zstd -d -c nextest-archive.tar.zst | tar xf -
- name: Setup local files for testing
run: make setup-local-files
- name: Run acceptance, component and integration tests.
run: "~/.cargo/bin/cargo-nextest nextest run --archive-file nextest-archive.tar.zst --final-status-level pass --profile integration-tests -E 'test(/^acceptance|^component|^integration|^sdk/) - test(/long/)' --partition count:${{ matrix.partition }}/3 --nocapture --"
# after the standard build is done, run the upgrade tests
lit_node_version_upgrade_tests:
needs: build-if-needed
runs-on: warp-ubuntu-latest-x64-16x # change to LargeRunner to run on github. Change to self-hosted to run on our own runner. Change to buildjet-8vcpu-ubuntu-2204 to run on buildjet with 8 cpus
# TODO: enable this when you want to turn on version upgrade tests. there's also another spot below where you have to remove a hardcoded "false" with a comment like this.
if: false
timeout-minutes: 60
strategy:
matrix:
partition: [1, 2, 3]
services:
anvil:
image: litptcl/anvil-lit:latest
ports:
- 8545:8545
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
steps:
- name: Install deps
working-directory: ${{ github.workspace }}
run: sudo apt-get update && sudo apt-get install -y zstd libudev-dev libsqlite3-dev cmake protobuf-compiler
- name: Checkout lit-assets
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use Node.js
uses: buildjet/setup-node@v3
with:
node-version: 18.17.0
cache: npm
cache-dependency-path: ${{ github.workspace }}/blockchain/contracts/package-lock.json
- name: Install dependencies for blockchain/contracts
working-directory: ${{ github.workspace }}/blockchain/contracts
run: npm install
- name: Run npx hardhat compile for blockchain/contracts
working-directory: ${{ github.workspace }}/blockchain/contracts
run: npx hardhat compile
- name: Install rust because the version upgrade tests do a recompile
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable # keep this up to date with rust/lit-node/rust-toolchain.toml
components: rustfmt rust-src
- name: Install nextest
run: curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
- name: Download archive
uses: actions/download-artifact@v4
with:
name: nextest-archive-lit-actions,testing
path: rust/lit-node/
- name: Unzip archive so that we can get the lit_node binary
run: zstd -d -c nextest-archive.tar.zst | tar xf -
# Get the workflow run that has the latest build for target branches.
- name: Get the latest workflow run ID
id: get_latest_workflow_run_id
run: |
echo "LATEST_WORKFLOW_RUN_ID_HABANERO=$(cd scripts/ci_utils && cargo run --bin get_latest_workflow_run rust/lit-node-build-commit-hash 'origin/release-habanero-*')" >> "$GITHUB_OUTPUT"
echo "LATEST_WORKFLOW_RUN_ID_MANZANO=$(cd scripts/ci_utils && cargo run --bin get_latest_workflow_run rust/lit-node-build-commit-hash 'origin/release-manzano-*')" >> "$GITHUB_OUTPUT"
echo "LATEST_WORKFLOW_RUN_ID_CAYENNE=$(cd scripts/ci_utils && cargo run --bin get_latest_workflow_run rust/lit-node-build-commit-hash 'origin/release-cayenne-*')" >> "$GITHUB_OUTPUT"
env:
GH_PAT: ${{ secrets.GITHUB_TOKEN }}
RUST_LOG: debug
- name: Get the latest commit SHA
id: get_latest_commit_sha
run: |
echo "COMMIT_SHA_HABANERO=$(cd scripts/ci_utils && cargo run --bin get_target_branch_commit_hash 'origin/release-habanero-*')" >> "$GITHUB_OUTPUT"
echo "COMMIT_SHA_MANZANO=$(cd scripts/ci_utils && cargo run --bin get_target_branch_commit_hash 'origin/release-manzano-*')" >> "$GITHUB_OUTPUT"
echo "COMMIT_SHA_CAYENNE=$(cd scripts/ci_utils && cargo run --bin get_target_branch_commit_hash 'origin/release-cayenne-*')" >> "$GITHUB_OUTPUT"
env:
RUST_LOG: debug
- name: Download the latest build for release-habanero-* branch
uses: actions/download-artifact@v4
with:
name: lit_node_${{ steps.get_latest_commit_sha.outputs.COMMIT_SHA_HABANERO }}
run-id: ${{ steps.get_latest_workflow_run_id.outputs.LATEST_WORKFLOW_RUN_ID_HABANERO }}
github-token: ${{ secrets.GITHUB_TOKEN }}
path: rust/lit-node/
- name: Move the downloaded binary
run: mv lit_node target/debug/lit_node_${{ steps.get_latest_commit_sha.outputs.COMMIT_SHA_HABANERO }}
- name: Download the latest build for release-manzano-* branch
uses: actions/download-artifact@v4
with:
name: lit_node_${{ steps.get_latest_commit_sha.outputs.COMMIT_SHA_MANZANO }}
run-id: ${{ steps.get_latest_workflow_run_id.outputs.LATEST_WORKFLOW_RUN_ID_MANZANO }}
github-token: ${{ secrets.GITHUB_TOKEN }}
path: rust/lit-node/
- name: Move the downloaded binary
run: mv lit_node target/debug/lit_node_${{ steps.get_latest_commit_sha.outputs.COMMIT_SHA_MANZANO }}
- name: Download the latest build for release-cayenne-* branch
uses: actions/download-artifact@v4
with:
name: lit_node_${{ steps.get_latest_commit_sha.outputs.COMMIT_SHA_CAYENNE }}
run-id: ${{ steps.get_latest_workflow_run_id.outputs.LATEST_WORKFLOW_RUN_ID_CAYENNE }}
github-token: ${{ secrets.GITHUB_TOKEN }}
path: rust/lit-node/
- name: Move the downloaded binary
run: mv lit_node target/debug/lit_node_${{ steps.get_latest_commit_sha.outputs.COMMIT_SHA_CAYENNE }}
- name: Enable execute permissions for the binary
run: |
chmod +x target/debug/lit_node_${{ steps.get_latest_commit_sha.outputs.COMMIT_SHA_HABANERO }}
chmod +x target/debug/lit_node_${{ steps.get_latest_commit_sha.outputs.COMMIT_SHA_MANZANO }}
chmod +x target/debug/lit_node_${{ steps.get_latest_commit_sha.outputs.COMMIT_SHA_CAYENNE }}
- name: Setup local files for testing
run: make setup-local-files
- name: Run acceptance, component and integration tests.
run: "~/.cargo/bin/cargo-nextest nextest run --archive-file nextest-archive.tar.zst --final-status-level pass --profile version-upgrade-tests -E 'test(/^upgrades/)' --partition count:${{ matrix.partition }}/3 --nocapture --"
# AND together the results
check_status:
needs:
[
lit_node_unit_tests,
lit_node_integration_tests,
lit_node_version_upgrade_tests,
]
runs-on: ubuntu-latest
steps:
- name: Check status
working-directory: ${{ github.workspace }}
run: |
if [ ${{ needs.lit_node_unit_tests.result }} != 'success' ]; then
echo "Unit tests failed"
exit 1
fi
if [ ${{ needs.lit_node_integration_tests.result }} != 'success' ]; then
echo "Integration tests failed"
exit 1
fi
# TODO: enable this when you want to turn on version upgrade tests
if [ false && ${{ needs.lit_node_version_upgrade_tests.result }} != 'success' ]; then
echo "Version upgrade tests failed"
exit 1
fi
echo "All tests passed"