-
Notifications
You must be signed in to change notification settings - Fork 11
215 lines (209 loc) · 8.25 KB
/
rust.yml
File metadata and controls
215 lines (209 loc) · 8.25 KB
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
name: Rust
on:
workflow_dispatch:
pull_request:
push:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
build-windows:
name: Windows Build
runs-on: windows-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.11.0
- uses: actions/checkout@v2
- name: Setup rust toolchain
run: rustup show
- name: Prepare VM
uses: crazy-max/ghaction-chocolatey@v3
with:
args: install protoc llvm winfsp make
- name: Install FlatBuffers Compiler
run: |
$url = "https://github.com/google/flatbuffers/releases/download/v23.5.26/Windows.flatc.binary.zip"
Invoke-WebRequest $url -OutFile C:\flatc.zip
Expand-Archive C:\flatc.zip -DestinationPath C:\Windows
- name: Restore ast-grep cache
id: restore-ast-grep-windows
uses: actions/cache@v4
with:
path: C:\Users\runneradmin\.cargo\bin\ast-grep.exe
key: ast-grep-${{ runner.os }}
restore-keys: |
ast-grep-${{ runner.os }}
- name: Install ast-grep
if: steps.restore-ast-grep-windows.outputs.cache-hit != 'true'
# --force because cache-hit can be false (matched a partial key?) and
# then this command will fail if the previous step did restore the file.
run: cargo install --locked --force ast-grep
- name: Cargo Check
run: |
cargo check --tests --features server,spfs/server
# Use this someday to do real tests
#- name: Install Debug SPFS
# run: |
# make install-debug-spfs
build-and-test:
name: Linux Build and Test
runs-on: ubuntu-latest
timeout-minutes: 45
container:
image: rust:slim-bookworm
options: --security-opt seccomp=unconfined --privileged
env:
# Disable cnproc because we're in a container
SPFS_MONITOR_DISABLE_CNPROC: "1"
# Define a local origin repo for tests to use
SPFS_REMOTE_origin_ADDRESS: "file:///tmp/spfs-repos/origin"
SPFS_SUPPRESS_OVERLAYFS_PARAMS_WARNING: "1"
# Enable sccache for rust
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.11.0
- uses: actions/checkout@v2
- name: Prepare Container
run: |
apt-get update
apt-get install -y libcap2-bin sudo cmake tcsh rsync protobuf-compiler fuse libfuse-dev curl unzip pkg-config libssl-dev git
# spfs-fuse requires this option enabled
echo user_allow_other >> /etc/fuse.conf
FB_REL=https://github.com/google/flatbuffers/releases/
curl --proto '=https' --tlsv1.2 -sSfL ${FB_REL}/download/v23.5.26/Linux.flatc.binary.g++-10.zip | funzip > /usr/bin/flatc
chmod +x /usr/bin/flatc
rustup install nightly
rustup component add clippy
rustup component add rustfmt --toolchain nightly
- name: Configure cargo
run: |
mkdir -p .cargo
cat << EOF > .cargo/config.toml
[build]
# Disable incremental compilation to lower disk usage, and sccache
# can't cache incremental compiles.
incremental = false
[profile.dev]
# Disable debug information to lower disk usage.
debug = false
EOF
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Restore ast-grep cache
id: restore-ast-grep-linux
uses: actions/cache@v4
with:
path: /usr/local/cargo/bin/ast-grep
key: ast-grep-${{ runner.os }}
restore-keys: |
ast-grep-${{ runner.os }}
- name: Install ast-grep
if: steps.restore-ast-grep-linux.outputs.cache-hit != 'true'
# --force because cache-hit can be false (matched a partial key?) and
# then this command will fail if the previous step did restore the file.
run: cargo install --locked --force ast-grep
# Use the same FEATURES in these different steps to avoid recompiling
# as much as possible. Consider using a separate workflow with its own
# cache if there is a need to test building with a different set of
# features enabled.
- name: Build
run: make debug FEATURES=server,spfs/server
- name: Install Debug Binaries
run: make install-debug-spfs FEATURES=server,spfs/server
- name: Setup a local origin repo
run: SPFS_REMOTE_origin_ADDRESS="${SPFS_REMOTE_origin_ADDRESS}?create=true" spfs ls-tags -r origin
# Run test before lint, lint takes a while and it is useful to know that
# the tests are failing before knowing if the lints are passing.
- name: Run Unit Tests
run: make test FEATURES=server,spfs/server
- name: Lint
run: make lint FEATURES=server,spfs/server
- name: Lint Package Specs
run: |
export PATH="$PWD/target/debug:$PATH"
make packages.lint
- name: Configure SPFS for Integration tests
run: |
cat << EOF > /etc/spfs.toml
[environment]
variable_names_to_preserve = ["TMPDIR"]
EOF
- name: SPFS Integration Tests - Regular User
run: |
# Run tests as a normal user to verify privilege escalation
useradd -m e2e
su e2e -c crates/spfs/tests/integration/run_tests.sh
- name: SPFS Integration Tests - Root User
run: |
# Run tests that need root
crates/spfs/tests/integration/run_privileged_tests.sh
matrix-build:
name: build features ${{ matrix.no-default-features }} ${{ matrix.features }}
runs-on: ubuntu-latest
timeout-minutes: 45
container:
image: rust:slim-bookworm
options: --security-opt seccomp=unconfined --privileged
env:
# Enable sccache for rust
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
strategy:
fail-fast: false
matrix:
features:
# SPI's standand features
- migration-to-components,sentry,spfs/protobuf-src,spfs-vfs/protobuf-src,statsd,fuse-backend-rhel-7-6
no-default-features:
- ""
- --no-default-features
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.11.0
- uses: actions/checkout@v4
- name: Prepare Container
run: |
apt-get update
apt-get install -y build-essential libcap2-bin sudo cmake tcsh rsync protobuf-compiler fuse libfuse-dev curl unzip pkg-config libssl-dev git
# spfs-fuse requires this option enabled
echo user_allow_other >> /etc/fuse.conf
FB_REL=https://github.com/google/flatbuffers/releases/
curl --proto '=https' --tlsv1.2 -sSfL ${FB_REL}/download/v23.5.26/Linux.flatc.binary.g++-10.zip | funzip > /usr/bin/flatc
chmod +x /usr/bin/flatc
rustup component add clippy
- name: Configure cargo
run: |
mkdir -p .cargo
cat << EOF > .cargo/config.toml
[build]
# Disable incremental compilation to lower disk usage, and sccache
# can't cache incremental compiles.
incremental = false
EOF
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Restore ast-grep cache
id: restore-ast-grep-linux
uses: actions/cache@v4
with:
path: /usr/local/cargo/bin/ast-grep
key: ast-grep-${{ runner.os }}
restore-keys: |
ast-grep-${{ runner.os }}
- name: Install ast-grep
if: steps.restore-ast-grep-linux.outputs.cache-hit != 'true'
# --force because cache-hit can be false (matched a partial key?) and
# then this command will fail if the previous step did restore the file.
run: cargo install --locked --force ast-grep
# Use the same FEATURES in these different steps to avoid recompiling
# as much as possible. Consider using a separate workflow with its own
# cache if there is a need to test building with a different set of
# features enabled.
- name: Build
run: >-
cargo clippy
${{ matrix.no-default-features }}
--features "${{ matrix.features }}"
--all-targets