-
Notifications
You must be signed in to change notification settings - Fork 14
558 lines (463 loc) · 15.2 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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
name: CI
on:
push:
branches:
- master
tags:
- '*'
pull_request:
jobs:
format:
runs-on: ubuntu-22.04
steps:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- uses: actions/checkout@v1
- name: rustfmt check
run: cargo fmt --check
xen:
runs-on: ubuntu-22.04
steps:
- name: install Xen headers and libraries
run: sudo apt-get install -y libxen-dev
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: actions/checkout@v1
- name: build and check Xen driver
run: |
cargo build --features xen
cargo clippy --features xen -- -D warnings
kvm:
runs-on: ubuntu-22.04
steps:
- name: clone libkvmi
uses: actions/checkout@v2
with:
repository: bitdefender/libkvmi
path: libkvmi
ref: bf5776319e1801b59125c994c459446f0ed6837e
- name: build and install libkvmi
run: |
./bootstrap
./configure
make
sudo make install
working-directory: libkvmi
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: actions/checkout@v1
- name: build and check KVM driver
run: |
cargo build --features kvm
cargo clippy --features kvm -- -D warnings
- name: remove compilation artifacts
run: cargo clean
- name: test KVM driver
run: cargo test --lib --features kvm
env:
RUSTFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "coverage-%p-%m.profraw"
- name: install grcov
uses: actions-rs/[email protected]
with:
crate: grcov
version: latest
use-tool-cache: true
# - name: generate coverage report
# id: coverage
# uses: actions-rs/[email protected]
# - name: upload coverage report to codecov.io
# uses: codecov/codecov-action@v1
# with:
# file: ${{ steps.coverage.outputs.report }}
# flags: unittests
# fail_ci_if_error: true
memflow:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-22.04, windows-2022 ]
steps:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: actions/checkout@v1
- name: build and check Memflow driver
run: |
cargo build --features mflow
cargo clippy --features mflow -- -D warnings
virtualbox_linux:
runs-on: ubuntu-22.04
steps:
- name: clone Icebox repository
run: git clone https://github.com/thalium/icebox --depth 1
- name: Compile and install FDP library
run: |
cd icebox/src/FDP
g++ -std=c++11 -shared -fPIC FDP.cpp -o libFDP.so -lrt
sudo cp include/* /usr/local/include
sudo cp libFDP.so /usr/local/lib
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: actions/checkout@v1
- name: build and check VirtualBox driver
run: |
cargo build --features virtualbox
cargo clippy --features virtualbox -- -D warnings
virtualbox_windows:
runs-on: windows-2022
steps:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Clone Icebox repository
uses: actions/checkout@v2
with:
repository: thalium/icebox
path: icebox
- uses: actions/checkout@v2
with:
path: libmicrovmi
# adds cl.exe in the PATH
- name: Setup command prompt for Microsoft Visual C++
uses: ilammy/msvc-dev-cmd@v1
- name: Compile and install FDP library
run: |
# install in C:\FDP to avoid issues with quotes etc
cl /c FDP.cpp /out:FDP.obj
cl /LD FDP.obj /link /out:FDP.dll
lib /NOLOGO FDP.obj /OUT:FDP.lib
dir
New-Item -Path "C:\FDP" -ItemType "directory"
copy FDP.dll "C:\FDP"
copy FDP.lib "C:\FDP"
copy "include\*" "C:\FDP"
working-directory: icebox/src/FDP
- name: Install Clang
run: choco install llvm
- name: build VirtualBox driver
run: cargo build --manifest-path libmicrovmi/Cargo.toml --features virtualbox
env:
BINDGEN_EXTRA_CLANG_ARGS: -I"C:\FDP" -L"C:\FDP"
CARGO_BUILD_RUSTFLAGS: -L C:\FDP
c_api:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, windows-2022]
steps:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: actions/checkout@v1
- name: build libmicrovmi
run: cargo build
- name: build C API
run: |
cd c_examples
cmake -B build
cmake --build build
examples:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, windows-2022]
steps:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: actions/checkout@v1
- name: check examples with clippy
run: cargo clippy --examples -- -D warnings
release_python:
# build a libmicrovmi python bindings release
# and upload it as artifact
runs-on: ubuntu-22.04
steps:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Set up Python 3.8 🐍
uses: actions/setup-python@v1
with:
python-version: '3.8'
- uses: actions/checkout@v1
- name: install nox and check formatting, linting, type checking and testing
run: |
pip install nox
nox -r
working-directory: python
- name: build Python extension and check with clippy
run: |
cargo build -p pymicrovmi
cargo clippy -p pymicrovmi -- -D warnings
- name: install Python package
run: |
python -m pip install -r requirements.txt
./setup.py install
working-directory: python
- name: smoke test
run: python3 -c 'from microvmi import Microvmi, DriverType, CommonInitParamsPy, DriverInitParamsPy, KVMInitParamsPy'
- name: Build Wheels with manylinux
run: nox -r -s generate_wheels -- --features xen,kvm,virtualbox,mflow --release
working-directory: python
# upload all generated wheels *.whl
- name: upload artifact
uses: actions/upload-artifact@v4
with:
name: python_wheels
path: python/dist/manylinux/*
release_debian_package:
# create a debian package with libmicrovmi release
# and upload it as artifact
needs: [format, xen, kvm, virtualbox_linux, memflow]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v1
- name: install Xen headers
run: sudo apt-get install -y libxen-dev
- name: clone Icebox
uses: actions/checkout@v2
with:
repository: thalium/icebox
path: icebox
- name: install VirtualBox's FDP headers
run: |
g++ -std=c++11 -shared -fPIC FDP.cpp -o libFDP.so -lrt
sudo cp include/* /usr/local/include
sudo cp libFDP.so /usr/local/lib
working-directory: icebox/src/FDP
- name: clone libkvmi
uses: actions/checkout@v2
with:
repository: bitdefender/libkvmi
path: libkvmi
ref: bf5776319e1801b59125c994c459446f0ed6837e
- name: build and install libkvmi
run: |
./bootstrap
./configure
make
sudo make install
working-directory: libkvmi
- name: install cargo deb dependencies
run: sudo apt-get install -y dpkg liblzma-dev
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo
- name: install cargo deb
run: cargo install cargo-deb
- name: build debian package
# must keep --no-strip because cargo metadata doesn't expose
# workspace profiles
# also --release is already added by cargo deb
run: cargo deb --no-strip -- --features xen,kvm,virtualbox,mflow
- name: upload artifact
uses: actions/upload-artifact@v4
with:
name: microvmi_deb
# microvmi_x.x.x_amd64.deb
path: target/debian/*
release_windows:
# build libmicrovmi release with all windows drivers
# and upload it as an artefact
needs: [virtualbox_windows, memflow]
runs-on: windows-2022
steps:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Clone Icebox repository
uses: actions/checkout@v2
with:
repository: thalium/icebox
path: icebox
- uses: actions/checkout@v2
with:
path: libmicrovmi
# adds cl.exe in the PATH
- name: Setup command prompt for Microsoft Visual C++
uses: ilammy/msvc-dev-cmd@v1
- name: Compile and install FDP library
run: |
# install in C:\FDP to avoid issues with quotes etc
cl /c FDP.cpp /out:FDP.obj
cl /LD FDP.obj /link /out:FDP.dll
lib /NOLOGO FDP.obj /OUT:FDP.lib
dir
New-Item -Path "C:\FDP" -ItemType "directory"
copy FDP.dll "C:\FDP"
copy FDP.lib "C:\FDP"
copy "include\*" "C:\FDP"
working-directory: icebox/src/FDP
- name: Install Clang
run: choco install llvm
- name: build libmicrovmi with virtualbox and memflow driver
run: cargo build --manifest-path libmicrovmi/Cargo.toml --features virtualbox,mflow --release
env:
BINDGEN_EXTRA_CLANG_ARGS: -I"C:\FDP" -L"C:\FDP"
CARGO_BUILD_RUSTFLAGS: -L C:\FDP
- name: create output directory and copy artifact content
run: |
mkdir output
copy ./target/release/microvmi.dll output
copy ./target/release/capi/libmicrovmi.h output
working-directory: libmicrovmi
- name: upload artifact
uses: actions/upload-artifact@v4
with:
name: microvmi_win32
path: libmicrovmi/output/*
github_release:
needs: [c_api, examples, release_python, release_debian_package, release_windows]
runs-on: ubuntu-22.04
outputs:
upload_url: ${{ steps.step_upload_url.outputs.upload_url }}
version: ${{ steps.get_version.outputs.version }}
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3
- name: Get the version
id: get_version
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo
- name: Create a Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.version }}
release_name: ${{ steps.get_version.outputs.version }}
- id: step_upload_url
run: echo "upload_url=${{ steps.create_release.outputs.upload_url }}" >> $GITHUB_OUTPUT
publish_debian_package:
needs: github_release
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v2
id: download
with:
name: microvmi_deb
- name: Get artifact path and name
id: artefact
run: |
PATHNAME=$(find . -maxdepth 1 -name '*.deb')
NAME=$(basename "$PATHNAME")
echo "path=$PATHNAME" >> $GITHUB_OUTPUT
echo "name=$NAME" >> $GITHUB_OUTPUT
- name: Upload Debian package as Release asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.github_release.outputs.upload_url }}
asset_path: ${{ steps.artefact.outputs.path }}
asset_name: ${{ steps.artefact.outputs.name }}
asset_content_type: application/vnd.debian.binary-package
publish_windows:
# publish the windows release on Github Release
runs-on: ubuntu-22.04
needs: github_release
steps:
- uses: actions/checkout@v1
# download artifacts
- uses: actions/download-artifact@v2
id: download
with:
# download to tmp_dir
name: microvmi_win32
path: tmp_dir
# create zip archive of tmp_dir content without including the folder itself
- name: create zip archive
run: zip -r ../microvmi_win32.zip *
working-directory: tmp_dir
- name: Upload Zip folder as Release asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.github_release.outputs.upload_url }}
asset_path: ./microvmi_win32.zip
asset_name: microvmi_win32.zip
asset_content_type: application/zip
publish_book:
# build and publish the book on Github pages
needs: github_release
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v1
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-mdbook
- name: install mdbook
run: cargo install mdbook
- name: build book
run: mdbook build doc
- name: Deploy 🚀
uses: JamesIves/[email protected]
with:
branch: gh-pages
# note: FOLDER doesn't care about the job's working directory
folder: doc/book
single_commit: true
publish_crates_io:
needs: github_release
runs-on: ubuntu-22.04
# publish on crates.io
# this should be triggered by cargo release, which creates a new tag and pushes to the repo
# cargo release --no-dev-version --skip-publish minor
steps:
- name: Install Xen headers and libraries
run: sudo apt-get install -y libxen-dev
- uses: actions/checkout@v1
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Publish
shell: bash
run: |
cargo publish --features xen --token ${{ secrets.CRATES_TOKEN }}
publish_pypi:
needs: github_release
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
# download all wheels into a new manylinux directory
- uses: actions/download-artifact@v2
id: download
with:
name: python_wheels
path: manylinux
- name: Publish on PyPI 🚀
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_ACCESS_TOKEN }}
packages_dir: manylinux