forked from build-trust/ockam
-
Notifications
You must be signed in to change notification settings - Fork 0
406 lines (346 loc) · 13.1 KB
/
rust.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
398
399
400
401
402
403
404
405
406
name: Rust
permissions:
contents: read
on:
merge_group:
pull_request:
paths:
- ".github/workflows/rust.yml"
- ".github/actions/**"
- "**.rs"
- "**.toml"
- "**/Cargo.lock"
- "implementations/rust/ockam/ockam_command/tests/**"
- "**/Makefile"
- "tools/nix/**"
push:
paths:
- ".github/workflows/rust.yml"
- ".github/actions/**"
- "**.rs"
- "**.toml"
- "**/Cargo.lock"
- "implementations/rust/ockam/ockam_command/tests/**"
- "**/Makefile"
- "tools/nix/**"
branches:
- develop
schedule:
# At 1 am.
- cron: "0 1 * * *"
workflow_dispatch:
inputs:
commit_sha:
description: Commit SHA, to run workflow
ockam_command_cli_version:
description: SHA to build Ockam command CLI
ockam_crate_version_to_test_with_docs_examples:
description: Ockam crate version to tests docs.ockam.io library examples
ockam_docs_ref:
description: SHA or branch to run ockam docs test
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
env:
CI: true
jobs:
lint:
name: Rust - lint_${{ matrix.lint_projects }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
lint_projects:
- cargo_readme
- cargo_fmt_check
- cargo_clippy
- cargo_deny
- cargo_toml_files
defaults:
run:
shell: nix develop ./tools/nix#rust --keep CI --ignore-environment --command bash {0}
steps:
- name: Checkout repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
ref: ${{ github.event.inputs.commit_sha }}
- name: Install Nix
uses: ./.github/actions/nix_installer_and_cache
with:
cache-unique-id: ${{ matrix.lint_projects }}
id: nix-installer
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
with:
key: "${{ github.job }}-${{ matrix.lint_projects }}"
- name: Run lint ${{ matrix.lint_projects }}
run: make -f implementations/rust/Makefile lint_${{ matrix.lint_projects }}
- name: Nix Upload Store
uses: ./.github/actions/nix_upload_store
if: ${{ steps.nix-installer.outputs.cache-hit != 'true' }}
build:
name: Rust - build${{ matrix.build_projects != 'packages' && format('_{0}', matrix.build_projects) || '' }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- build_projects: packages
make_name: 'build'
- build_projects: docs
make_name: 'build_docs'
- build_projects: examples
make_name: 'build_examples'
- build_projects: nightly
make_name: 'build'
defaults:
run:
shell: nix develop ./tools/nix#rust${{matrix.build_projects == 'nightly' && '_nightly' || '' }} --keep CI --ignore-environment --command bash {0}
steps:
- name: Checkout repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
ref: ${{ github.event.inputs.commit_sha }}
- name: Install Nix
uses: ./.github/actions/nix_installer_and_cache
with:
cache-unique-id: ${{ matrix.build_projects }}
id: nix-installer
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
with:
key: "${{ github.job }}-${{ matrix.build_projects }}"
- name: Run build ${{ matrix.build_projects }}
run: make -f implementations/rust/Makefile ${{ matrix.make_name }}
- name: Nix Upload Store
uses: ./.github/actions/nix_upload_store
if: ${{ steps.nix-installer.outputs.cache-hit != 'true' }}
test:
name: Rust - test${{ matrix.test_projects != 'stable' && format('_{0}', matrix.test_projects) || '' }}
runs-on: ubuntu-22.04
services:
ockam_cloud:
image: ghcr.io/build-trust/ockam-cloud-node@sha256:518314876a5b07c263b88995792335c4426d940c10e5e638a60e66776d86cff5
env:
CLOUD_ADDRESS: ockam_cloud:4000
defaults:
run:
shell: nix develop ./tools/nix#rust${{ matrix.test_projects == 'nightly' && '_nightly' || '' }} --keep CI --ignore-environment --command bash {0}
strategy:
fail-fast: false
matrix:
test_projects:
- stable
- nightly
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
ref: ${{ github.event.inputs.commit_sha }}
- name: Install Nix
uses: ./.github/actions/nix_installer_and_cache
with:
cache-unique-id: ${{ matrix.test_projects }}
id: nix-installer
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
with:
key: "${{ github.job }}-${{ matrix.test_projects }}"
- name: Run test on ${{ matrix.test_projects }}
run: make -f implementations/rust/Makefile test
- name: Nix Upload Store
uses: ./.github/actions/nix_upload_store
if: ${{ steps.nix-installer.outputs.cache-hit != 'true' }}
check:
name: Rust - check_${{ matrix.check_projects }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- check_projects: cargo_update
nix_toolchain: 'rust'
- check_projects: no_std
nix_toolchain: 'rust_nightly'
- check_projects: nightly
nix_toolchain: 'rust_nightly'
defaults:
run:
shell: nix develop ./tools/nix#${{matrix.nix_toolchain }} --keep CI --ignore-environment --command bash {0}
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
ref: ${{ github.event.inputs.commit_sha }}
- name: Install Nix
uses: ./.github/actions/nix_installer_and_cache
with:
cache-unique-id: ${{ matrix.check_projects }}
id: nix-installer
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
with:
key: "${{ github.job }}-${{ matrix.check_projects }}"
- name: Run check on ${{ matrix.check_projects }}
run: make -f implementations/rust/Makefile check${{ matrix.check_projects != 'nightly' && format('_{0}', matrix.check_projects) || '' }}
- name: Nix Upload Store
uses: ./.github/actions/nix_upload_store
if: ${{ steps.nix-installer.outputs.cache-hit != 'true' }}
test_ockam_command:
name: Rust - test_ockam_command
strategy:
fail-fast: false
matrix:
build: [linux_86]
include:
- build: linux_86
os: ubuntu-22.04
rust: stable
target: x86_64-unknown-linux-gnu
runs-on: ${{ matrix.os }}
steps:
- name: Checkout ockam cli repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
ref: ${{ inputs.ockam_command_cli_version != '' && inputs.ockam_command_cli_version || inputs.commit_sha }}
path: ockam_cli
- name: Checkout ockam bats repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
ref: ${{ inputs.commit_sha }}
path: ockam_bats
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
with:
workspaces: "ockam_cli -> target"
- name: Install Nix
uses: ./ockam_bats/.github/actions/nix_installer_and_cache
with:
cache-unique-id: test_ockam_command
id: nix-installer
- name: Build Binary
working-directory: ockam_cli
shell: nix develop ./tools/nix#rust --keep CI --ignore-environment --command bash {0}
run: |
rustc --version
set -x
cargo build --bin ockam
- name: Set Path
run: |
echo "PATH=$(pwd)/ockam_cli/target/debug:$PATH" >> $GITHUB_ENV;
- name: Run Script On Ubuntu
working-directory: ockam_bats
shell: nix develop ./tools/nix#tooling --command bash {0}
run: |
ockam --version
echo $(which ockam)
echo $BATS_TEST_RETRIES
bats implementations/rust/ockam/ockam_command/tests/bats;
env:
OCKAM_DISABLE_UPGRADE_CHECK: 1
BATS_TEST_RETRIES: 2
- name: Nix Upload Store
uses: ./ockam_bats/.github/actions/nix_upload_store
if: ${{ steps.nix-installer.outputs.cache-hit != 'true' }}
ockam_command_cross_build:
name: Rust - ockam_command_cross_build
strategy:
fail-fast: false
matrix:
build: [linux_armv7, macos_silicon]
include:
- build: linux_armv7
os: ubuntu-20.04
toolchain: stable
target: armv7-unknown-linux-musleabihf
use-cross-build: true
- build: macos_silicon
os: macos-latest
toolchain: stable
target: aarch64-apple-darwin
use-cross-build: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
ref: ${{ inputs.commit_sha }}
- uses: ./.github/actions/build_binaries
with:
use_cross_build: ${{ matrix.use-cross-build }}
toolchain: ${{ matrix.toolchain }}
target: ${{ matrix.target }}
platform_operating_system: ${{ matrix.os }}
# test_orchestrator_ockam_command:
# name: Rust - test_orchestrator_ockam_command
# runs-on: ubuntu-20.04
# container: ghcr.io/build-trust/artifacts-helper:latest
# environment: ${{ github.event_name == 'merge_group' && 'merge_queue' || '' }}
# permissions:
# contents: read
# packages: read
# steps:
# - name: Run Ockam Bats Test On Development Cluster
# if: github.event_name == 'merge_group'
# uses: build-trust/.github/actions/run_bats_test@custom-actions
# with:
# perform_ockam_enroll: 'true'
# script_path: "/artifacts-scripts"
# ockam_repository_ref: ${{ inputs.commit_sha }}
# controller_id: ${{ secrets.ORCHESTRATOR_DEVELOPMENT_CONTROLLER_ID }}
# controller_addr: ${{ secrets.ORCHESTRATOR_DEVELOPMENT_CONTROLLER_ADDRESS }}
test_docs_rust_library_examples:
name: Rust - test_docs_rust_library_examples
runs-on: ubuntu-22.04
if: github.event_name == 'workflow_dispatch'
steps:
# Run ockam example code against a different version of ockam library
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
ref: ${{ inputs.commit_sha }}
path: ockam_examples
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
ref: ${{ inputs.ockam_crate_version_to_test_with_docs_examples }}
path: ockam_library
- name: Install Nix
uses: ./ockam_library/.github/actions/nix_installer_and_cache
with:
cache-unique-id: test_docs_rust_library_examples
id: nix-installer
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
with:
workspaces: "ockam_examples -> target"
- name: Move Implementation Directory From Ockam Library To Ockam Examples
run: |
cp -r ockam_library/implementations/rust/ockam ockam_examples/implementations/rust/ockam
- name: Run Ockam Examples
working-directory: ockam_examples
shell: nix develop ./tools/nix#rust --keep CI --ignore-environment --command bash {0}
run: cargo test -p hello_ockam
- name: Nix Upload Store
uses: ./.github/actions/nix_upload_store
if: ${{ steps.nix-installer.outputs.cache-hit != 'true' }}
lint_docs_ockam_io_rust_examples:
name: Rust - lint_docs_ockam_io_rust_examples
runs-on: ubuntu-22.04
steps:
- name: Checkout Ockam Repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
ref: ${{ inputs.commit_sha }}
path: ockam
- name: Checkout Ockam Documentation Repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
ref: ${{ inputs.ockam_docs_ref == '' && 'develop' || inputs.ockam_docs_ref }}
repository: build-trust/ockam-documentation
path: ockam-documentation
- name: Install Nix
uses: ./ockam/.github/actions/nix_installer_and_cache
with:
cache-unique-id: lint_docs_ockam_io_rust_examples
id: nix-installer
- name: Build Example Blocks
working-directory: ockam
run:
nix develop ./tools/nix#rust --keep CI --ignore-environment --command cargo install --path ./tools/docs/example_blocks
- name: Check Rust Documentation
run: |
CHECK_MD_DIR="ockam-documentation/reference/libraries/rust" CHECK_MD_DIR_RUST_EXAMPLE="ockam/examples/rust/get_started" OCKAM_HOME="ockam" ockam/tools/docs/check_documentation.sh
- name: Nix Upload Store
uses: ./ockam/.github/actions/nix_upload_store
if: ${{ steps.nix-installer.outputs.cache-hit != 'true' }}