-
Notifications
You must be signed in to change notification settings - Fork 15
647 lines (557 loc) · 18.4 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
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
name: CI
on:
push:
branches:
- master
tags:
- '*'
pull_request:
jobs:
format:
runs-on: ubuntu-20.04
steps:
- name: install stable toolchain with rustfmt
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt
- uses: actions/checkout@v1
- name: rustfmt check
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
xen:
runs-on: ubuntu-20.04
steps:
- name: install Xen headers and libraries
run: sudo apt-get install -y libxen-dev
- name: install stable toolchain with clippy
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
- uses: actions/checkout@v1
- name: build Xen driver
uses: actions-rs/cargo@v1
with:
command: build
args: --features xen
- name: annotate commit with clippy warnings
uses: actions-rs/clippy-check@v1
with:
name: clippy xen
token: ${{ secrets.GITHUB_TOKEN }}
args: --features xen -- -D warnings
kvm:
runs-on: ubuntu-20.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 stable toolchain with clippy
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
- uses: actions/checkout@v1
- name: build KVM driver
uses: actions-rs/cargo@v1
with:
command: build
args: --features kvm
- name: annotate commit with clippy warnings
uses: actions-rs/clippy-check@v1
with:
name: clippy kvm
token: ${{ secrets.GITHUB_TOKEN }}
args: --features kvm -- -D warnings
- name: remove compilation artifacts from stable toolchain
uses: actions-rs/cargo@v1
with:
command: clean
- name: install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- name: test KVM driver
uses: actions-rs/cargo@v1
with:
command: test
# The target arg is a workaround in order to prevent build.rs files from being compiled with RUSTFLAGS
# -Cpanic=abort can lead to issues with bindgen during compile time
# --lib only unit tests in the library, avoid integration tests
args: --lib --features kvm --no-fail-fast --target x86_64-unknown-linux-gnu
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
- name: install grcov
uses: actions-rs/install@v0.1
with:
crate: grcov
version: latest
use-tool-cache: true
- name: generate coverage report
id: coverage
uses: actions-rs/grcov@v0.1
- 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-20.04, windows-2022 ]
steps:
- name: install stable toolchain with clippy
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
- uses: actions/checkout@v1
- name: build Memflow driver
uses: actions-rs/cargo@v1
with:
command: build
args: --features mflow
- name: annotate commit with clippy warnings
uses: actions-rs/clippy-check@v1
with:
name: clippy memflow
token: ${{ secrets.GITHUB_TOKEN }}
args: --features mflow -- -D warnings
virtualbox_linux:
runs-on: ubuntu-20.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 stable toolchain with clippy
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
- uses: actions/checkout@v1
- name: build VirtualBox driver
uses: actions-rs/cargo@v1
with:
command: build
args: --features virtualbox
- name: annotate commit with clippy warnings
uses: actions-rs/clippy-check@v1
with:
name: clippy virtualbox
token: ${{ secrets.GITHUB_TOKEN }}
args: --features virtualbox -- -D warnings
virtualbox_windows:
runs-on: windows-2022
steps:
- name: install stable toolchain with clippy
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
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
uses: actions-rs/cargo@v1
with:
command: build
args: --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-20.04, windows-2022]
steps:
- name: install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- uses: actions/checkout@v1
- name: build libmicrovmi
uses: actions-rs/cargo@v1
with:
command: build
- name: build C API
run: |
cd c_examples
cmake -B build
cmake --build build
examples:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2022]
steps:
- name: install stable toolchain with clippy
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
- uses: actions/checkout@v1
- name: build examples with clippy
uses: actions-rs/clippy-check@v1
with:
name: clippy examples
token: ${{ secrets.GITHUB_TOKEN }}
args: --examples -- -D warnings
release_python:
# build a libmicrovmi python bindings release
# and upload it as artifact
runs-on: ubuntu-20.04
steps:
- name: install stable toolchain with clippy
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
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
uses: actions-rs/cargo@v1
with:
command: build
args: -p pymicrovmi
- name: annotate commit with clippy warnings
uses: actions-rs/clippy-check@v1
with:
name: clippy python
token: ${{ secrets.GITHUB_TOKEN }}
args: -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@v2
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-20.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@v2
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 stable toolchain with clippy
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
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
uses: actions-rs/cargo@v1
with:
command: build
args: --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@v2
with:
name: microvmi_win32
path: libmicrovmi/output/*
github_release:
# create a Github release
# only when
# - push on master
# - tag starts with 'v*'
needs: [c_api, examples, release_python, release_debian_package, release_windows]
runs-on: ubuntu-20.04
# output these value to be used by other jobs so they can add assets
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@v1
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- 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 "::set-output name=upload_url::${{ steps.create_release.outputs.upload_url }}"
publish_debian_package:
# publish the debian package in the Github Release
needs: github_release
runs-on: ubuntu-20.04
steps:
# the deploy action below depends on a checkout of the repo
# otherwise it fails trying to remote the 'origin' remote
# https://github.com/JamesIves/github-pages-deploy-action/issues/335
- uses: actions/checkout@v2
# download artifacts
- 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 ::set-output name=path::${PATHNAME}
echo ::set-output name=name::${NAME}
- name: Upload Debian package as Release asset
uses: actions/upload-release-asset@v1.0.2
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-20.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/upload-release-asset@v1.0.2
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-20.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/github-pages-deploy-action@4.1.0
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-20.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: Publish
shell: bash
run: |
cargo publish --features xen --token ${{ secrets.CRATES_TOKEN }}
publish_pypi:
needs: github_release
runs-on: ubuntu-20.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/gh-action-pypi-publish@v1.3.1
with:
user: __token__
password: ${{ secrets.PYPI_ACCESS_TOKEN }}
packages_dir: manylinux