-
-
Notifications
You must be signed in to change notification settings - Fork 563
332 lines (287 loc) · 10.2 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
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:
# We only save cache when a cron job is started, this is to ensure
# that we don't save cache on every push causing excessive caching
# and github deleting useful caches we use in our workflows, we now
# run a cron job every 2 hours so as to update the cache store with the
# latest data so that we don't have stale cache.
- cron: "0 */2 * * *"
workflow_dispatch:
inputs:
commit_sha:
description: Commit SHA, to run workflow
ockam_command_cli_version:
description: SHA to build Ockam command CLI
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@b4ffde65f46336ab88eb53be808477a3936bae11
with:
ref: ${{ github.event.inputs.commit_sha }}
- name: Install Nix
uses: ./.github/actions/cache_nix
with:
cache-unique-id: ${{ matrix.lint_projects }}
id: nix-installer
- uses: ./.github/actions/cache_rust
with:
job_name: "${{ 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'
- build_projects: release
make_name: 'build_release'
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@b4ffde65f46336ab88eb53be808477a3936bae11
with:
ref: ${{ github.event.inputs.commit_sha }}
- name: Install Nix
uses: ./.github/actions/cache_nix
with:
cache-unique-id: ${{ matrix.build_projects }}
id: nix-installer
- uses: ./.github/actions/cache_rust
with:
job_name: "${{ 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@b4ffde65f46336ab88eb53be808477a3936bae11
with:
ref: ${{ github.event.inputs.commit_sha }}
- name: Install Nix
uses: ./.github/actions/cache_nix
with:
cache-unique-id: ${{ matrix.test_projects }}
id: nix-installer
- uses: ./.github/actions/cache_rust
with:
job_name: "${{ 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@b4ffde65f46336ab88eb53be808477a3936bae11
with:
ref: ${{ github.event.inputs.commit_sha }}
- name: Install Nix
uses: ./.github/actions/cache_nix
with:
cache-unique-id: ${{ matrix.check_projects }}
id: nix-installer
- uses: ./.github/actions/cache_rust
with:
job_name: "${{ 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@b4ffde65f46336ab88eb53be808477a3936bae11
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@b4ffde65f46336ab88eb53be808477a3936bae11
with:
ref: ${{ inputs.commit_sha }}
path: ockam_bats
- uses: ./ockam_bats/.github/actions/cache_rust
with:
directory_to_cache: "ockam_cli"
job_name: ${{ github.job }}
- name: Install Nix
uses: ./ockam_bats/.github/actions/cache_nix
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-13
toolchain: stable
target: aarch64-apple-darwin
use-cross-build: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
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 }}