-
Notifications
You must be signed in to change notification settings - Fork 19
383 lines (322 loc) · 13.8 KB
/
ci.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
---
name: Build And Test
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
env:
CARGO_TERM_COLOR: always
PUBLIC_SIMICS_PKGS_URL: "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/881ee76a-c24d-41c0-af13-5d89b2a857ff/simics-6-packages-2023-31-linux64.ispm"
PUBLIC_SIMICS_ISPM_URL: "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/881ee76a-c24d-41c0-af13-5d89b2a857ff/intel-simics-package-manager-1.7.5-linux64.tar.gz"
PUBLIC_SIMICS_PKGS_URL_WINDOWS: "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/881ee76a-c24d-41c0-af13-5d89b2a857ff/simics-6-packages-2023-31-win64.ispm"
PUBLIC_SIMICS_ISPM_URL_WINDOWS: "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/881ee76a-c24d-41c0-af13-5d89b2a857ff/intel-simics-package-manager-1.7.5-win64.exe"
PUBLIC_SIMICS_PACKAGE_VERSION_1000: "6.0.169"
MINGW_URL: "https://github.com/brechtsanders/winlibs_mingw/releases/download/13.2.0-16.0.6-11.0.0-ucrt-r1/winlibs-x86_64-posix-seh-gcc-13.2.0-llvm-16.0.6-mingw-w64ucrt-11.0.0-r1.7z"
MINGW_VERSION: "13.2.0-16.0.6-11.0.0-ucrt-r1"
jobs:
build_test_artifacts:
name: Build Test Artifacts
runs-on: ubuntu-latest
steps:
- name: Add ISPM to PATH
run: |
echo "${HOME}/simics/ispm/" >> "${GITHUB_PATH}"
- name: Install Dependencies
run: |
sudo apt-get -y update && \
sudo apt-get -y install \
clang libclang-dev cmake curl dosfstools g++ gcc git llvm make \
mtools ninja-build openssl libssl-dev python3 python3-pip
- name: Cache SIMICS Dependencies
id: cache-simics-packages
uses: actions/cache@v3
with:
path: ~/simics
key: simics-linux-${{ env.PUBLIC_SIMICS_PACKAGE_VERSION_1000 }}
- name: Install SIMICS (External)
if: ${{ steps.cache-simics-packages.outputs.cache-hit != 'true' }}
run: |
mkdir -p "${HOME}/simics/ispm/" && \
curl --noproxy -L -o "${HOME}/simics/ispm.tar.gz" \
"${{ env.PUBLIC_SIMICS_ISPM_URL }}" && \
curl --noproxy -L -o "${HOME}/simics/simics.ispm" \
"${{ env.PUBLIC_SIMICS_PKGS_URL }}" && \
tar -C "${HOME}/simics/ispm" --strip-components=1 \
-xvf "${HOME}/simics/ispm.tar.gz"
- name: Set up SIMICS Install Directory
run: |
ispm settings install-dir "${HOME}/simics"
- name: Install SIMICS Packages
if: ${{ steps.cache-simics-packages.outputs.cache-hit != 'true' }}
run: |
ispm packages --install-bundle "${HOME}/simics/simics.ispm" \
--non-interactive --trust-insecure-packages
- uses: actions/checkout@v4
with:
lfs: true
- name: Cache Test Artifacts
id: cache-test-artifacts
uses: actions/cache@v3
with:
path: examples/tests
key: cache-test-artifacts-${{ hashFiles('examples/tests/**/*') }}
- name: Build Test Artifacts
if: ${{ steps.cache-test-artifacts.outputs.cache-hit != 'true' }}
run: |
cd examples/tests/
./build.sh
- name: Upload Test Artifacts
uses: actions/upload-artifact@v3
with:
name: test-artifacts
path: examples/tests/
build_and_test:
name: Build and Test (Linux)
container: fedora:38
runs-on: ubuntu-latest
needs: build_test_artifacts
steps:
- name: Add ISPM to PATH
run: |
echo "${HOME}/simics/ispm/" >> "${GITHUB_PATH}"
- name: Install Dependencies
run: |
dnf -y update && \
dnf -y install \
alsa-lib atk clang clang-libs clang-resource-filesystem \
clang-tools-extra cmake cups curl dosfstools g++ gcc git \
git-lfs glibc-devel glibc-devel.i686 glibc-static \
glibc-static.i686 gtk3 lld lld-devel lld-libs llvm llvm-libs \
llvm-static make mesa-libgbm mtools ninja-build openssl \
openssl-devel openssl-libs python3 python3-pip yamllint
- uses: actions/checkout@v4
with:
lfs: true
- name: Delete Un-Built Test Dependencies
run: |
rm -rf examples/tests/
- name: Download Test Dependencies
uses: actions/download-artifact@v3
with:
name: test-artifacts
path: examples/tests/
- name: Take Ownership of Test Dependencies
run: |
ls -lahR examples/tests/
chown -R "${USER}:${USER}" examples/tests/
chmod -R 0755 examples/tests/
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
components: rustfmt,clippy,miri
- name: Cache SIMICS Dependencies
id: cache-simics-packages
uses: actions/cache@v3
with:
path: ~/simics
key: simics-linux-${{ env.PUBLIC_SIMICS_PACKAGE_VERSION_1000 }}
- name: Install SIMICS (External)
if: ${{ steps.cache-simics-packages.outputs.cache-hit != 'true' }}
run: |
mkdir -p "${HOME}/simics/ispm/" && \
curl --noproxy -L -o "${HOME}/simics/ispm.tar.gz" \
"${{ env.PUBLIC_SIMICS_ISPM_URL }}" && \
curl --noproxy -L -o "${HOME}/simics/simics.ispm" \
"${{ env.PUBLIC_SIMICS_PKGS_URL }}" && \
tar -C "${HOME}/simics/ispm" --strip-components=1 \
-xvf "${HOME}/simics/ispm.tar.gz"
- name: Set up SIMICS Install Directory
run: |
ispm settings install-dir "${HOME}/simics"
- name: Install SIMICS Packages
if: ${{ steps.cache-simics-packages.outputs.cache-hit != 'true' }}
run: |
ispm packages --install-bundle "${HOME}/simics/simics.ispm" \
--non-interactive --trust-insecure-packages
- name: Build and Install TSFFS SIMICS Package
run: |
ispm projects "$(pwd)" --create --ignore-existing-files \
--non-interactive
bin/project-setup --force
./build.rs
ispm packages \
-i linux64/packages/simics-pkg-31337-*-linux64.ispm \
--non-interactive --trust-insecure-packages
- name: Build Project
run: |
SIMICS_BASE=${HOME}/simics/simics-${{ env.PUBLIC_SIMICS_PACKAGE_VERSION_1000 }} cargo build
- name: CT39 - Clippy Check Project
run: |
SIMICS_BASE=${HOME}/simics/simics-${{ env.PUBLIC_SIMICS_PACKAGE_VERSION_1000 }} cargo clippy \
|| ( echo "❗ [CT39 (1/2)] Failed clippy static analysis checks" && exit 1 )
echo "✅ [CT39 (1/2)] Passed clippy static analysis checks"
- name: Test Project
run: |
TSFFS_TEST_CLEANUP_EACH=1 SIMICS_BASE=${HOME}/simics/simics-${{ env.PUBLIC_SIMICS_PACKAGE_VERSION_1000 }} cargo test -p command-ext -p raw-cstr -p version-tools -p tests -- --nocapture || ( echo "❗ Tests failed" && exit 1 )
echo "✅ Tests passed"
- name: Build Docs
run: |
SIMICS_BASE=${HOME}/simics/simics-${{ env.PUBLIC_SIMICS_PACKAGE_VERSION_1000 }} cargo doc --workspace --no-deps
- name: Test Docs
run: |
SIMICS_BASE=${HOME}/simics/simics-${{ env.PUBLIC_SIMICS_PACKAGE_VERSION_1000 }} cargo test --doc
- name: CT39 - MIRI Check Project
run: |
SIMICS_BASE=${HOME}/simics/simics-${{ env.PUBLIC_SIMICS_PACKAGE_VERSION_1000 }} \
MIRIFLAGS="-Zmiri-backtrace=full -Zmiri-disable-isolation -Zmiri-panic-on-unsupported" \
cargo miri test -p command-ext -p raw-cstr -p version-tools \
|| ( echo "❗ [CT39 (2/2)] Failed MIRI static analysis checks" && exit 1 )
echo "✅ [CT39 (2/2)] Passed MIRI static analysis checks"
build_windows:
name: Build and Test (Windows)
runs-on: windows-latest
steps:
- name: Add ISPM and MinGW to PATH
run: |
set PATH $env:PATH
"C:\MinGW\bin" | Out-File -FilePath $env:GITHUB_PATH
"C:\ISPM\" | Out-File -FilePath $env:GITHUB_PATH -Append
"$PATH" | Out-File -FilePath $env:GITHUB_PATH -Append
echo "Current PATH: " $env:GITHUB_PATH
- name: Cache MinGW
id: cache-mingw
uses: actions/cache@v3
with:
path: C:\MinGW\
key: mingw-${{ env.MINGW_VERSION }}
- name: Download and Extract MinGW-w64
if: ${{ steps.cache-mingw.outputs.cache-hit != 'true' }}
run: |
Invoke-WebRequest -URI ${{ env.MINGW_URL }} -OutFile mingw.7z
7z x mingw.7z -oC:\mingw-w64\
mv C:\mingw-w64\mingw64\ C:\MinGW\
- name: Download and Install Rust
run: |
Invoke-WebRequest -URI https://win.rustup.rs/x86_64 -o C:\rustup-init.exe
C:\rustup-init.exe --default-toolchain nightly --default-host x86_64-pc-windows-gnu -y
- name: Cache SIMICS
id: cache-simics-packages-windows
uses: actions/cache@v3
with:
path: |
C:\ISPM\
C:\SIMICS\
key: simics-windows-${{ env.PUBLIC_SIMICS_PACKAGE_VERSION_1000 }}
# ispm-installer.exe is a NSIS installer for the elctron build. We want the
# default options, so we pass /S to install silently:
# https://nsis.sourceforge.io/Docs/Chapter3.html#installerusage
#
# NOTE: We use | Out-Null on the installer command to make powershell wait for it
# to actually finish instead of forking it to the background
- name: Download and Install ISPM
if: ${{ steps.cache-simics-packages-windows.outputs.cache-hit != 'true' }}
run: |
Invoke-WebRequest -URI ${{ env.PUBLIC_SIMICS_ISPM_URL_WINDOWS }} -o C:\ispm-installer.exe
C:\ispm-installer.exe /S /D='C:\ISPM\' | Out-Null
- name: Set SIMICS Install Directory
run: |
ispm.exe settings install-dir C:\SIMICS\
- name: Download and Install SIMICS Packages
if: ${{ steps.cache-simics-packages-windows.outputs.cache-hit != 'true' }}
run: |
Invoke-WebRequest -URI ${{ env.PUBLIC_SIMICS_PKGS_URL_WINDOWS }} -o C:\simics-6-packages.ispm
ispm.exe packages --install-bundle C:\simics-6-packages.ispm --non-interactive --trust-insecure-packages
- uses: actions/checkout@v4
with:
lfs: true
- name: Setup, Build, and Install TSFFS
run: |
ispm.exe projects $(pwd) --create --non-interactive --ignore-existing-files
./bin/project-setup.bat --mingw-dir C:\MinGW\ --ignore-existing-files --force
cargo -Zscript build.rs
- name: Upload Distribution Package
uses: actions/upload-artifact@v3
with:
name: simics-pkg-31337-win64
path: win64/packages/simics-pkg-31337-*-win64.ispm
build_dist:
name: Build for Distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Cache Builder Dependencies
id: cache-builder-dependencies
uses: actions/cache@v3
with:
path: .github/builder/rsrc
key: cache-builder-dependencies
- name: Download Builder Dependencies
if: ${{ steps.cache-builder-dependencies.outputs.cache-hit != 'true' }}
run: |
mkdir -p .github/builder/rsrc
curl -L -o .github/builder/rsrc/ispm.tar.gz \
"${{ env.PUBLIC_SIMICS_ISPM_URL }}" && \
curl -L -o .github/builder/rsrc/simics.ispm \
"${{ env.PUBLIC_SIMICS_PKGS_URL }}"
- name: Build Distribution Package
run: |
docker build -t tsffs-dist -f .github/builder/Dockerfile .
docker create --name tsffs-dist tsffs-dist bash
docker cp tsffs-dist:/tsffs/linux64/packages/ packages/
docker rm -f tsffs-dist
- name: Upload Distribution Package
uses: actions/upload-artifact@v3
with:
name: simics-pkg-31337-linux64
path: packages/simics-pkg-31337-*-linux64.ispm
fuzz_tests:
name: Run Fuzz Tests
container: fedora:38
runs-on: ubuntu-latest
steps:
- name: Install Dependencies
run: |
dnf -y update && \
dnf -y install \
alsa-lib atk clang clang-libs clang-resource-filesystem \
clang-tools-extra cmake cups curl dosfstools g++ gcc git \
git-lfs glibc-devel glibc-devel.i686 glibc-static \
glibc-static.i686 gtk3 lld lld-devel lld-libs llvm llvm-libs \
llvm-static make mesa-libgbm mtools ninja-build openssl \
openssl-devel openssl-libs python3 python3-pip yamllint
- uses: actions/checkout@v4
with:
lfs: true
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
components: rustfmt,clippy,miri
- name: Install Cargo-Fuzz
run: |
cargo install cargo-fuzz
- name: CT632 (E/C) - Perform fuzz testing
run: |
cd modules/tsffs/src/util/version-tools
cargo fuzz build
timeout --preserve-status 600 cargo fuzz run \
fuzz_version_constraint_parse || exit 0
echo "Done fuzzing!"
if [ -d ./fuzz/artifacts ]; then
if find ./fuzz/artifacts -mindepth 1 -maxdepth 1 2> /dev/null | read -r; then
echo "❗ [CT632] Fuzz test found an issue"
exit 1
fi
fi
cd ../../../../../
cd modules/tsffs/src/util/util/raw-cstr
cargo fuzz build
timeout --preserve-status 600 cargo fuzz run \
fuzz_raw_cstr || exit 0
echo "Done fuzzing!"
if [ -d ./fuzz/artifacts ]; then
if find ./fuzz/artifacts -mindepth 1 -maxdepth 1 2> /dev/null | read -r; then
echo "❗ [CT632] Fuzz test found an issue"
exit 1
fi
fi
cd ../../../../../
echo "✅ [CT632] Fuzz test completed"
exit 0