-
Notifications
You must be signed in to change notification settings - Fork 132
397 lines (381 loc) · 14.9 KB
/
ci-test.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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
name: ci-test
on:
push:
branches: [auto, canary, gha-test-*]
pull_request:
branches: [main, release-*, gha-test-*]
defaults:
run:
shell: bash
env:
max_threads: 16
pre_command: cd /opt/git/diem/
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
changes-target-branch: ${{ steps.changes.outputs.changes-target-branch }}
changes-base-git-rev: ${{ steps.changes.outputs.changes-base-git-rev }}
changes-base-githash: ${{ steps.changes.outputs.changes-base-githash }}
changes-pull-request-number: ${{ steps.changes.outputs.changes-pull-request-number }}
any-changes-founds: ${{ steps.any-changes-found.outputs.changes-found }}
test-rust: ${{ steps.rust-changes.outputs.changes-found }}
test-dev-setup: ${{ steps.dev-setup-sh-changes.outputs.changes-found }}
test-non-rust-lint: ${{ steps.non-rust-lint-changes.outputs.changes-found }}
steps:
- uses: actions/checkout@v2.4.0
with:
# This ensures that the tip of the PR is checked out instead of the merge between the base ref and the tip
# On `push` this value will be empty and will "do-the-right-thing"
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0 #get all the history!!!
- name: Git Hooks and Checks
run: ./scripts/git-checks.sh
- id: changes
name: determine changes
uses: diem/actions/changes@faadd16607b77dfa2231a8f366883e01717b3225
with:
workflow-file: ci-test.yml
github-token: ${{secrets.GITHUB_TOKEN}}
- id: any-changes-found
name: determine if there are any files listed in the CHANGES_CHANGED_FILE_OUTPUTFILE.
run: |
res=true
if [[ ! -f "$CHANGES_CHANGED_FILE_OUTPUTFILE" ]] || [[ "$(cat "$CHANGES_CHANGED_FILE_OUTPUTFILE" | wc -l)" == 0 ]]; then
res=false;
fi
echo "::set-output name=changes-found::$(echo $res)";
- id: rust-changes
name: find rust/cargo changes.
uses: diem/actions/matches@faadd16607b77dfa2231a8f366883e01717b3225
with:
pattern: '^documentation\|^docker\|^scripts\|^developers.diem.com'
invert: "true"
- id: non-rust-lint-changes
name: find shell/dockerfile changes
uses: diem/actions/matches@faadd16607b77dfa2231a8f366883e01717b3225
with:
pattern: 'Dockerfile$\|.*.sh$\|^developers.diem.com\|^shuffle'
- id: dev-setup-sh-changes
name: find dev-setup.sh/base docker image changes
uses: diem/actions/matches@faadd16607b77dfa2231a8f366883e01717b3225
with:
pattern: 'docker/ci\|scripts/dev_setup.sh'
dev-setup-sh-test:
runs-on: ubuntu-latest
timeout-minutes: 30
needs: prepare
if: ${{ needs.prepare.outputs.test-dev-setup == 'true' }}
strategy:
fail-fast: false
matrix:
target_os: [github]
steps:
- uses: actions/checkout@v2.4.0
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: build image with dev-setup.sh
run: docker build -f docker/ci/${{ matrix.target_os }}/Dockerfile -t diem/build_environment:test .
- name: Early terminate workflow
if: ${{ failure() }}
uses: ./.github/actions/early-terminator
with:
github-token: ${{secrets.GITHUB_TOKEN}}
lint:
runs-on: ubuntu-latest
timeout-minutes: 30
needs: prepare
if: ${{ needs.prepare.outputs.any-changes-founds == 'true' }}
container:
image: ghcr.io/diem/diem_build_environment:${{ needs.prepare.outputs.changes-target-branch }}
volumes:
- "${{github.workspace}}:/opt/git/diem"
steps:
- uses: actions/checkout@v2.4.0
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/actions/build-setup
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
with:
key: ${{ needs.prepare.outputs.changes-target-branch }}
- name: cargo lint
run: $pre_command && cargo x lint
- name: cargo clippy
run: $pre_command && cargo xclippy --workspace --all-targets
- name: cargo fmt
run: $pre_command && cargo xfmt --check
- uses: ./.github/actions/build-teardown
- name: Early terminate workflow
if: ${{ failure() }}
uses: ./.github/actions/early-terminator
with:
github-token: ${{secrets.GITHUB_TOKEN}}
unit-test:
runs-on: ubuntu-20.04-xl
timeout-minutes: 90
needs: prepare
if: ${{ needs.prepare.outputs.test-rust == 'true' }}
container:
image: ghcr.io/diem/diem_build_environment:${{ needs.prepare.outputs.changes-target-branch }}
volumes:
- "${{github.workspace}}:/opt/git/diem"
steps:
- uses: actions/checkout@v2.4.0
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0 #get all the history!!!
- uses: ./.github/actions/build-setup
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
with:
key: ${{ needs.prepare.outputs.changes-target-branch }}
- name: run unit tests
run: |
$pre_command && cargo nextest --nextest-profile ci --jobs ${max_threads} --test-threads ${max_threads} --changed-since "origin/$TARGET_BRANCH"
env:
TARGET_BRANCH: ${{ needs.prepare.outputs.changes-target-branch }}
- name: run doctests
run: |
$pre_command && cargo xtest --doc --jobs ${max_threads} --changed-since "origin/$TARGET_BRANCH"
env:
TARGET_BRANCH: ${{ needs.prepare.outputs.changes-target-branch }}
- name: organize unit test results
if: always()
run: |
$pre_command && mkdir -p target/junit-reports && mv target/nextest/ci/junit.xml target/junit-reports/unit-test.xml
- name: upload unit test results
if: always()
uses: actions/upload-artifact@v2
with:
name: unit-test-results
path: target/junit-reports/unit-test.xml
- uses: ./.github/actions/build-teardown
- name: Early terminate workflow
if: ${{ failure() }}
uses: ./.github/actions/early-terminator
with:
github-token: ${{secrets.GITHUB_TOKEN}}
hardhat-tests:
runs-on: ubuntu-latest
timeout-minutes: 90
needs: prepare
if: ${{ needs.prepare.outputs.test-rust == 'true' }}
container:
image: ghcr.io/diem/diem_build_environment:${{ needs.prepare.outputs.changes-target-branch }}
volumes:
- "${{github.workspace}}:/opt/git/diem"
steps:
- uses: actions/checkout@v2.4.0
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/actions/build-setup
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
- name: compile and install move-cli
run: "cargo install --features evm-backend --path language/tools/move-cli"
- name: set up hardhat-move
working-directory: language/evm/hardhat-move
run: "npm install"
- name: compile hardhat-move
working-directory: language/evm/hardhat-move
run: "npm run build"
- name: set up hardhat
working-directory: language/evm/hardhat-examples
run: "./setup.sh"
- name: run hardhat tests
working-directory: language/evm/hardhat-examples
run: "npx hardhat test"
# TODO: reenable this once we figure a way to keep package-lock.json stable.
# - uses: ./.github/actions/build-teardown
move-cli-tests-evm:
runs-on: ubuntu-20.04-xl
timeout-minutes: 90
needs: prepare
steps:
- uses: actions/checkout@v2.4.0
- uses: ./.github/actions/build-setup
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
- name: run EVM-based move cli tests
run: "cargo test --features evm-backend -p move-cli --test build_testsuite_evm --test move_unit_tests_evm"
move-unit-test-framework-tests-evm:
runs-on: ubuntu-20.04-xl
timeout-minutes: 90
needs: prepare
steps:
- uses: actions/checkout@v2.4.0
- uses: ./.github/actions/build-setup
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
- name: run EVM-based move unit test framework tests
run: "cargo test --features evm-backend -p move-unit-test --test move_unit_test_testsuite"
- name: Early terminate workflow
if: ${{ failure() }}
uses: ./.github/actions/early-terminator
with:
github-token: ${{secrets.GITHUB_TOKEN}}
diem-framework-build-all-packages:
runs-on: ubuntu-20.04-xl
timeout-minutes: 90
needs: prepare
steps:
- uses: actions/checkout@v2.4.0
- uses: ./.github/actions/build-setup
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
- name: build Diem Framework Packages
run: "language/documentation/examples/diem-framework/build_all.sh"
diem-framework-test-all-packages:
runs-on: ubuntu-20.04-xl
timeout-minutes: 90
needs: prepare
steps:
- uses: actions/checkout@v2.4.0
- uses: ./.github/actions/build-setup
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
- name: test Diem Framework Packages
run: "language/documentation/examples/diem-framework/test_all.sh"
diem-framework-prove-all-packages:
runs-on: ubuntu-20.04-xl
timeout-minutes: 90
needs: prepare
steps:
- uses: actions/checkout@v2.4.0
- uses: ./.github/actions/build-setup
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
- name: prove Diem Framework Packages
run: "language/documentation/examples/diem-framework/prove_all.sh"
# Compile (but don't run) the benchmarks, to insulate against bit rot
build-benchmarks:
runs-on: ubuntu-20.04-xl
timeout-minutes: 90
needs: prepare
if: ${{ needs.prepare.outputs.test-rust == 'true' }}
container:
image: ghcr.io/diem/diem_build_environment:${{ needs.prepare.outputs.changes-target-branch }}
volumes:
- "${{github.workspace}}:/opt/git/diem"
steps:
- uses: actions/checkout@v2.4.0
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/actions/build-setup
- uses: actions/cache@v2.1.6
with:
path: "/opt/cargo/git\n/opt/cargo/registry\n/opt/cargo/.package-cache"
key: crates-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: "crates-${{ runner.os }}"
- name: build benchmarks
run: cargo x bench --no-run
- uses: ./.github/actions/build-teardown
- name: Early terminate workflow
if: ${{ failure() }}
uses: ./.github/actions/early-terminator
with:
github-token: ${{secrets.GITHUB_TOKEN}}
perf-benchmarks:
name: run-perf-benchmarks
runs-on: ubuntu-latest
timeout-minutes: 30
needs:
- prepare
- build-benchmarks
env:
CRITERION_HOME: /tmp/benches
steps:
- uses: actions/checkout@v2.4.0
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/cache@v2.1.6
with:
path: "/opt/cargo/git\n/opt/cargo/registry\n/opt/cargo/.package-cache"
key: crates-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: "crates-${{ runner.os }}"
- name: Download the previous baseline
continue-on-error: true
uses: actions/download-artifact@v2
with:
name: bench-baseline
- name: Run performance benchamrks
run: |
# Replace this with a cargo x bench
cargo bench --package language-benchmarks
- name: Archive criterion results
uses: actions/upload-artifact@v2
with:
name: bench-baseline
retention-days: 5
path: |
/tmp/benches
- name: Early terminate workflow
if: ${{ failure() }}
uses: ./.github/actions/early-terminator
with:
github-token: ${{secrets.GITHUB_TOKEN}}
build-move-analyzer-vscode-extension:
name: Build VS Code extension for move-analyzer
runs-on: ubuntu-latest
needs:
- prepare
steps:
- uses: actions/checkout@v2.4.0
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Use Node.js 14
uses: actions/setup-node@v2.4.0
with:
node-version: "14"
- name: Install NPM dependencies
working-directory: language/move-analyzer/editors/code
run: npm install
- name: Build the extension
working-directory: language/move-analyzer/editors/code
run: npm run pretest
- name: Test the extension
# VS Code tests require display output. This action simulates such a
# display, using Xvfb. (It's roughly equivalent to prefixing the 'run'
# commands below with `xvfb-run <command>`.) Without a simulated display
# such as this one, the tests would fail with the error message:
# "Unable to open X display."
uses: GabrielBB/xvfb-action@v1.5
with:
working-directory: language/move-analyzer/editors/code
run: npm run test
- name: Package the extension
working-directory: language/move-analyzer/editors/code
run: npm run package
- name: Upload VS Code extension
uses: actions/upload-artifact@v2
with:
name: move-analyzer-vscode-extension
path: language/move-analyzer/editors/code/move-analyzer.vsix
- name: Early terminate workflow
if: ${{ failure() }}
uses: ./.github/actions/early-terminator
with:
github-token: ${{secrets.GITHUB_TOKEN}}
# check-for-broken-links:
# name: Check for broken links in files
# runs-on: ubuntu-latest
# needs:
# - prepare
# steps:
# - uses: actions/checkout@v2
# - name: Set up Ruby 2.6
# uses: ruby/setup-ruby@v1
# with:
# ruby-version: 2.7
# - name: Run Checks
# run: |
# gem install awesome_bot
# # Don't look in git or target dirs. Don't check png, bib, tex, js, or shell files
# # We allow links to be redirects, allow duplicates, and we also allow Too Many Requests (429) errors
# find . -not \( -path "./.git*" -prune \) -not \( -path "./target" -prune \) -type f -not -name "*.png" -not -name "*.sh" -not -name "*.bib" -not -name "*.tex" -not -name "*.js" | while read arg; do awesome_bot --allow-redirect --allow-dupe --allow 429 --skip-save-results $arg; done
build-move-cli-docker-image:
name: Build Docker image for the Move CLI
runs-on: ubuntu-latest
needs:
- prepare
steps:
- uses: actions/checkout@v2.4.0
- name: Build Dockerfile
run: "docker build -t move/cli -f docker/move-cli/Dockerfile ."
- name: Build BasicCoin Move module
run: |
cd ./language/documentation/tutorial/step_1/BasicCoin
docker run -v `pwd`:/project move/cli build