Skip to content

Commit

Permalink
ci: GitHub actions add windows-latest test build
Browse files Browse the repository at this point in the history
  • Loading branch information
3c7 authored and MatejKastak committed Jan 9, 2024
1 parent d1ff982 commit cff1a4f
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 11 deletions.
76 changes: 65 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ jobs:
- name: Install YARA deps
run: sudo apt-get install -y automake libtool make gcc pkg-config libssl-dev libjansson-dev libmagic-dev
- name: Build YARA
run: cd yari-sys/yara && ./bootstrap.sh && CFLAGS="-fPIC" ./configure --enable-debug --disable-shared --enable-static --enable-cuckoo --enable-magic --enable-dotnet --with-crypto && make
run: |
cd yari-sys/yara
./bootstrap.sh
CFLAGS="-fPIC" ./configure --enable-debug --disable-shared --enable-static --enable-cuckoo --enable-magic --enable-dotnet --with-crypto
make
- name: Build
run: cargo build --verbose
run: cargo build
- name: Run Rust tests
run: cargo test --verbose
run: cargo test
- name: Run tests with yari using bundled bindings
run: |
cargo clean
YARI_USE_BUNDLED_BINDINGS=1 cargo test --verbose
YARI_USE_BUNDLED_BINDINGS=1 cargo test
- uses: actions/setup-python@v4
with:
python-version: '3.10'
Expand All @@ -48,19 +52,69 @@ jobs:
uses: actions/checkout@v3
with:
submodules: 'true'
- name: Install (Yara) Dependencies
- name: Install YARA deps
run: brew install autoconf automake libtool pkg-config jansson libmagic openssl [email protected] [email protected] [email protected]
- name: Build Yara
run: cd yari-sys/yara && ./bootstrap.sh && CFLAGS="-fPIC -I$(brew --prefix)/include" LDFLAGS="-L$(brew --prefix)/lib $LDFLAGS" LIBRARY_PATH="$(brew --prefix)/lib:$LIBRARY_PATH" ./configure --enable-debug --disable-shared --enable-static --enable-cuckoo --enable-magic --enable-dotnet --with-crypto && make
run: |
cd yari-sys/yara
./bootstrap.sh
CFLAGS="-fPIC -I$(brew --prefix)/include" LDFLAGS="-L$(brew --prefix)/lib $LDFLAGS" LIBRARY_PATH="$(brew --prefix)/lib:$LIBRARY_PATH" ./configure --enable-debug --disable-shared --enable-static --enable-cuckoo --enable-magic --enable-dotnet --with-crypto
make
- name: Build Yari (yari-sys)
run: cd yari-sys && CFLAGS="-I$(brew --prefix)/include" LDFLAGS="-L$(brew --prefix)/lib $LDFLAGS" LIBRARY_PATH="$(brew --prefix)/lib:$LIBRARY_PATH" cargo build --release
- name: Build Yari (yari-cli)
run: cd yari-cli && CFLAGS="-I$(brew --prefix)/include" LDFLAGS="-L$(brew --prefix)/lib $LDFLAGS" LIBRARY_PATH="$(brew --prefix)/lib:$LIBRARY_PATH" cargo build --release
- name: Build Yari (yari-py)
run: cd yari-py && python3.12 -mvenv .venv && .venv/bin/pip install maturin pytest && CFLAGS="-I$(brew --prefix)/include" LDFLAGS="-L$(brew --prefix)/lib $LDFLAGS" LIBRARY_PATH="$(brew --prefix)/lib:$LIBRARY_PATH" .venv/bin/maturin build --release -i python3.10 -i python3.11 -i python3.12
- name: Run Rust tests
run: CFLAGS="-I$(brew --prefix)/include" LDFLAGS="-L$(brew --prefix)/lib $LDFLAGS" LIBRARY_PATH="$(brew --prefix)/lib:$LIBRARY_PATH" cargo test --verbose
run: CFLAGS="-I$(brew --prefix)/include" LDFLAGS="-L$(brew --prefix)/lib $LDFLAGS" LIBRARY_PATH="$(brew --prefix)/lib:$LIBRARY_PATH" cargo test
- name: Run Rust tests with bundled bindings
run: cargo clean && YARI_USE_BUNDLED_BINDINGS=1 CFLAGS="-I$(brew --prefix)/include" LDFLAGS="-L$(brew --prefix)/lib $LDFLAGS" LIBRARY_PATH="$(brew --prefix)/lib:$LIBRARY_PATH" cargo test --verbose
run: |
cargo clean
YARI_USE_BUNDLED_BINDINGS=1 CFLAGS="-I$(brew --prefix)/include" LDFLAGS="-L$(brew --prefix)/lib $LDFLAGS" LIBRARY_PATH="$(brew --prefix)/lib:$LIBRARY_PATH" cargo test
- name: Run Python tests
run: cd yari-py && .venv/bin/maturin develop && .venv/bin/pytest
run: |
cd yari-py
python3.12 -m venv .venv
.venv/bin/pip install maturin pytest
CFLAGS="-I$(brew --prefix)/include" LDFLAGS="-L$(brew --prefix)/lib $LDFLAGS" LIBRARY_PATH="$(brew --prefix)/lib:$LIBRARY_PATH" .venv/bin/maturin build -i python3.10 -i python3.11 -i python3.12
.venv/bin/maturin build
.venv/bin/maturin develop
.venv/bin/pytest
build-windows:
runs-on: windows-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Setup Nuget.exe
uses: nuget/setup-nuget@v1
with:
nuget-version: 'latest'
- name: Setup msbuild
uses: microsoft/[email protected]
- name: Install YARA Dependencies
run: nuget.exe restore windows/vs2017/yara.sln
working-directory: ./yari-sys/yara
- name: Build YARA
run: msbuild /m /p:Platform=x64 /p:Configuration=Release /p:PlatformToolset="v142" /p:WindowsTargetPlatformVersion="10.0.19041.0" windows/vs2017/yara.sln
working-directory: ./yari-sys/yara
shell: cmd
- name: Build yari-sys
run: |
cargo build
cargo test -- --nocapture --show-output
working-directory: ./yari-sys
- name: Build Python wheels
run: |
pip install --upgrade pip
python -m venv env
. env/Scripts/activate
pip install maturin pytest
maturin develop
pytest tests
working-directory: ./yari-py
2 changes: 2 additions & 0 deletions yari-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ fn link_lib(name: &str) {
#[cfg(target_os = "windows")]
fn link_windows() {
link_lib("libyara64");
link_lib("crypt32");
link_lib("user32");
}

#[cfg(any(target_os = "linux", target_os = "macos"))]
Expand Down
7 changes: 7 additions & 0 deletions yari-sys/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ use yari_sys::Module;
use yari_sys::{Context, ContextBuilder};

pub fn context() -> Context {
let _ = env_logger::builder().is_test(true).try_init();
ContextBuilder::default().build().unwrap()
}

pub fn context_with_cuckoo() -> Context {
let _ = env_logger::builder().is_test(true).try_init();
let test_root = Path::new(env!("CARGO_MANIFEST_DIR"));
let cuckoo_report = test_root.join("tests/assets/cuckoo.json");

Expand All @@ -18,6 +20,7 @@ pub fn context_with_cuckoo() -> Context {
}

fn context_with_sample(path: &str, rule: Option<&str>) -> Context {
let _ = env_logger::builder().is_test(true).try_init();
let test_root = Path::new(env!("CARGO_MANIFEST_DIR"));
let file = test_root.join(path);

Expand All @@ -29,14 +32,17 @@ fn context_with_sample(path: &str, rule: Option<&str>) -> Context {
}

pub fn context_with_elf_sample() -> Context {
let _ = env_logger::builder().is_test(true).try_init();
context_with_sample("tests/assets/elf_hello_world", None)
}

pub fn context_with_pe_signed_sample() -> Context {
let _ = env_logger::builder().is_test(true).try_init();
context_with_sample("tests/assets/pe_signed", None)
}

pub fn context_with_pe_sample_and_rule() -> Context {
let _ = env_logger::builder().is_test(true).try_init();
context_with_sample(
"tests/assets/pe_hello_world",
Some(
Expand All @@ -58,6 +64,7 @@ rule r {
}

pub fn context_with_elf_sample_and_rule() -> Context {
let _ = env_logger::builder().is_test(true).try_init();
context_with_sample(
"tests/assets/elf_hello_world",
Some(
Expand Down

0 comments on commit cff1a4f

Please sign in to comment.