Ci/update python #570
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.9 🐍 | |
uses: actions/setup-python@v1 | |
with: | |
python-version: '3.9' | |
- 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@v4 | |
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@v4 | |
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@v4 | |
- uses: actions/download-artifact@v4 | |
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@v4 | |
# download artifacts | |
- uses: actions/download-artifact@v4 | |
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@v4 | |
- uses: actions/cache@v4 | |
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@v4 | |
- 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@v4 | |
# download all wheels into a new manylinux directory | |
- uses: actions/download-artifact@v4 | |
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 |