-
Notifications
You must be signed in to change notification settings - Fork 40
295 lines (259 loc) · 11.9 KB
/
ci-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
name: CI Rust
on:
workflow_call:
inputs:
run-wasm-tests:
description: Run wasm test
required: true
default: false
type: boolean
check-cargo-deny:
description: Run cargo-deny
required: true
default: false
type: boolean
workflow_dispatch:
inputs:
run-wasm-tests:
description: Run wasm test
required: true
default: false
type: boolean
check-cargo-deny:
description: Run cargo-deny
required: true
default: false
type: boolean
# We set `concurrency` to prevent having this workflow being run on code that is not up-to-date on a PR (a user make multiple push in a quick manner).
# But on the main branch, we don't want that behavior.
# Having the workflow run on each merge commit is something we would like, that could help us where a regression was made and missed by previous checks.
#
# For that we use `head_ref` that is only defined on `pull-request` and fallback to `run_id` (this is a counter, so it's value is unique between workflow call).
concurrency:
group: ci-rust-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
poetry-version: 1.5.1
CARGO_CI_FLAGS: --locked --profile=ci-rust
CARGO_NEXTEST_CI_FLAGS: --profile=ci --locked --cargo-profile=ci-rust
WINFSP_VERSION: 2.0.23075
WINFSP_TEST_EXE: C:/Program Files (x86)/WinFsp/bin/winfsp-tests-x64.exe
permissions:
contents: read
packages: read
jobs:
# Cannot factorize the jobs with a matrix since we use a service container that is
# only available on linux (see https://github.com/orgs/community/discussions/25578)
test-rust-linux:
name: "🐧 Linux: 🦀 Rust tests"
# Just a fail-safe timeout, see the fine grain per-task timeout instead
timeout-minutes: 30
runs-on: ubuntu-22.04
# Testbed server comes as a Docker image, so it will eventually goes out of sync
# with the tests (typically a new API is introduced in the Parsec server, or a new
# testbed template is introduced).
# In such case, the container url should be updated from the, see:
# https://github.com/Scille/parsec-cloud/pkgs/container/parsec-cloud%2Fparsec-testbed-server
env:
TESTBED_SERVER: http://localhost:6777
services:
parsec-testbed-server:
image: ghcr.io/scille/parsec-cloud/parsec-testbed-server:3.2.1-a.0.dev.20053.312b36d
ports:
- 6777:6777
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin v4.2.2
timeout-minutes: 5
- name: Retrieve runner specs
id: runner-specs
uses: ./.github/actions/system-info
timeout-minutes: 1
- uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # pin v1.10.1
with:
# We setup the cache by hand, see below
cache: false
timeout-minutes: 10
- name: Retrieve Rust cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # pin v2.7.5
with:
# Cache is limited to 10Go (and cache is ~700mo per platform !). On top of that.
# cache is only shared between master and the PRs (and not across PRs).
# So we only save the cache on master build given it's the ones that are the
# most likely to be reused.
save-if: ${{ github.ref == 'refs/heads/master' }}
key: ${{ steps.runner-specs.outputs.os }}-${{ steps.runner-specs.outputs.release }}
timeout-minutes: 5
# Install fuse
- name: Install build dependencies
shell: bash
run: |
until sudo apt-get -y install fuse3 libfuse3-dev libdbus-1-dev; do
echo "Fail to install APT package retrying ...";
done
timeout-minutes: 5
# Install cargo nextest command
- uses: taiki-e/install-action@ec9269c9ddb8f79f082e226dcbb74bfb4c652ab1 # pin v2.45.14
with:
- name: Categorize workspace crates
id: crates
shell: bash
run: |
(
for type in agnostic platform bindings; do
echo -n "$type=" && python misc/libparsec_crates_flags.py $type
done
) | tee -a $GITHUB_OUTPUT
timeout-minutes: 2
- name: Test agnostic rust codebase
run: cargo nextest run ${{ env.CARGO_NEXTEST_CI_FLAGS }} ${{ steps.crates.outputs.agnostic }}
env:
RUST_LOG: debug
timeout-minutes: 10
# By default `libparsec_crypto` uses RustCrypto, so here we test the sodiumoxide
# implementation and it compatibility with the rest of the project
- name: Test sodiumoxide rust crypto
run: cargo nextest run ${{ env.CARGO_NEXTEST_CI_FLAGS }} --package libparsec_crypto --features use-sodiumoxide
env:
RUST_LOG: debug
timeout-minutes: 10
- name: Check agnostic & platform crates using sodium crypto features
run: cargo check ${{ env.CARGO_CI_FLAGS }} ${{ steps.crates.outputs.agnostic }} ${{ steps.crates.outputs.platform }} --features use-sodiumoxide
timeout-minutes: 10
env:
RUST_LOG: debug
- name: unlock keyring
uses: t1m0thyj/unlock-keyring@728cc718a07b5e7b62c269fc89295e248b24cba7 # pin v1.1.0
# Use sodiumoxide here given 1) it is composed of C code, so not totally
# platform independant and 2) it is what is going to be used in release
- name: Test platform crates using sodium crypto features (🐧 Linux specific)
shell: bash
run: cargo nextest run ${{ env.CARGO_NEXTEST_CI_FLAGS }} ${{ steps.crates.outputs.platform }} --features libparsec_crypto/use-sodiumoxide
timeout-minutes: 30
env:
RUST_LOG: debug
- name: Test platform-async on wasm
if: inputs.run-wasm-tests
run: wasm-pack test --headless --firefox libparsec/crates/platform_async
timeout-minutes: 10
- name: Test platform-storage on wasm
if: inputs.run-wasm-tests
run: wasm-pack test --headless --firefox libparsec/crates/platform_storage
timeout-minutes: 10
- name: Build CLI binary
run: cargo build ${{ env.CARGO_CI_FLAGS }} --package parsec-cli
timeout-minutes: 5
- name: Test CLI
run: cargo nextest run ${{ env.CARGO_NEXTEST_CI_FLAGS }} --package parsec-cli
timeout-minutes: 10
- name: Retrieve clippy args
id: clippy-args
shell: bash
run: yq -r '"args=" + (.repos | map(.hooks) | flatten | map(select(.id == "clippy"))[0] | .args | join(" "))' .pre-commit-config.yaml | tee -a $GITHUB_OUTPUT
timeout-minutes: 1
- name: Check rust code format
run: cargo fmt --check
timeout-minutes: 2
- name: SQL lint
# Cannot use `./misc/lint_sql.py` here since it would require us to install the
# whole Python server project.
shell: bash -eux {0}
run: |
pipx install sqlfluff
sqlfluff lint --disable-progress-bar --config libparsec/crates/platform_storage/src/native/sql/.sqlfluff libparsec/crates/platform_storage/src/native/sql/
# Clippy basically compile the project, hence it's faster to run it in
# the job where compilation cache is reused !
- name: Check cargo-clippy
run: cargo clippy ${{ env.CARGO_CI_FLAGS }} --verbose ${{ steps.clippy-args.outputs.args }}
timeout-minutes: 10
- name: Check restricted usage with cargo-deny
if: inputs.check-cargo-deny
run: |
echo "::add-matcher::.github/custom-problem-matchers/cargo-deny.json"
# cargo-deny outputs the report on stderr and it needs to be redirected to stdout for the problem matcher to work.
cargo deny --color=never check --hide-inclusion-graph --show-stats 2>&1
echo "::remove-matcher owner=cargo-deny::"
timeout-minutes: 2
test-rust-non-linux:
strategy:
fail-fast: false
matrix:
include:
- name: 🍎 macOS
os: macos-14
- name: 🏁 Windows
os: windows-2022
name: "${{ matrix.name }}: 🦀 Rust tests"
# Just a fail-safe timeout, see the fine grain per-task timeout instead
timeout-minutes: 60
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin v4.2.2
timeout-minutes: 5
- name: Retrieve runner specs
id: runner-specs
uses: ./.github/actions/system-info
timeout-minutes: 1
- uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # pin v1.10.1
with:
# We setup the cache by hand, see below
cache: false
timeout-minutes: 10
- name: Retrieve Rust cache
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # pin v2.7.5
with:
# Cache is limited to 10Go (and cache is ~700mo per platform !). On top of that.
# cache is only shared between master and the PRs (and not across PRs).
# So we only save the cache on master build given it's the ones that are the
# most likely to be reused.
save-if: ${{ github.ref == 'refs/heads/master' }}
key: ${{ steps.runner-specs.outputs.os }}-${{ steps.runner-specs.outputs.release }}
timeout-minutes: 5
# Building OpenSSL requires a perl interpreter.
# The default one does not provide windows-style filesystem
# paths so we have to switch to Strawberry.
- name: Use strawberry perl
if: startsWith(matrix.os, 'windows')
shell: bash
run: echo OPENSSL_SRC_PERL=C:/Strawberry/perl/bin/perl >> $GITHUB_ENV
timeout-minutes: 1
- name: Install winfsp
if: startsWith(matrix.os, 'windows')
shell: bash -eux {0}
run: |
choco install winfsp -y --version=${{ env.WINFSP_VERSION }}
curl -L https://github.com/winfsp/winfsp/releases/download/v2.0/winfsp-tests-${{ env.WINFSP_VERSION }}.zip -o D:/a/_temp/winfsp-tests.zip
unzip D:/a/_temp/winfsp-tests.zip -d D:/a/_temp/
mv 'D:/a/_temp/winfsp-tests-x64.exe' 'C:/Program Files (x86)/WinFsp/bin/'
- name: Install macFUSE
if: startsWith(matrix.os, 'macos')
run: brew install --cask macfuse
timeout-minutes: 5
# Install cargo nextest command
- uses: taiki-e/install-action@ec9269c9ddb8f79f082e226dcbb74bfb4c652ab1 # pin v2.45.14
with:
tool: [email protected]
- name: Check rust agnostic codebase
shell: bash -ex {0}
run: |
NON_BINDINGS_CRATES=`python3 misc/libparsec_crates_flags.py agnostic platform`
cargo check ${{ env.CARGO_CI_FLAGS }} $NON_BINDINGS_CRATES --features use-sodiumoxide
timeout-minutes: 15 # It can be very slow if cache has missed
env:
RUST_LOG: debug
# By default `libparsec_crypto` uses RustCrypto, so here we test the sodiumoxide
# implementation and its compatibility with the rest of the project
- name: Test rust crypto crate with sodium
run: cargo nextest run ${{ env.CARGO_NEXTEST_CI_FLAGS }} --package libparsec_crypto --features use-sodiumoxide
timeout-minutes: 10
- name: Test Rust platform codebase with sodium
shell: bash -ex -o pipefail {0}
run: |
PLATFORM_CRATES=`python3 misc/libparsec_crates_flags.py platform`
if [[ '${{ matrix.os }}' = macos* ]]; then
# Mountpoint cannot be tested on macOS because it requires macFUSE installation,
# that required the installation of a kernel extension that require a restart.
PLATFORM_CRATES=`echo $PLATFORM_CRATES | sed -e 's/-p libparsec_platform_mountpoint//'`
fi
cargo nextest run ${{ env.CARGO_NEXTEST_CI_FLAGS }} $PLATFORM_CRATES --features libparsec_crypto/use-sodiumoxide
timeout-minutes: 10