Skip to content

Commit

Permalink
ci: fix workflow for testing golang library (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
plusvic authored Apr 2, 2024
1 parent b97ec77 commit 3be2a67
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
29 changes: 15 additions & 14 deletions .github/workflows/golang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:
fail-fast: false
matrix:
go-version: [ '1.19', '1.20', '1.21.x' ]
os: [ubuntu-latest, macos-latest]
os: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
with:
Expand All @@ -30,7 +30,7 @@ jobs:
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable

# Install OpenSSL on Windows
- name: Install OpenSSL
if: runner.os == 'Windows'
Expand All @@ -52,16 +52,17 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev
- name: Build Rust library
run: cargo build --release -p yara-x -p yara-x-capi

- name: Set LD_LIBRARY_PATH environment variable
if: runner.os == 'Linux'
shell: bash
run: echo "LD_LIBRARY_PATH=${{ github.workspace }}/target/release" >> $GITHUB_ENV

- name: Install cargo-c
run: cargo install cargo-c

- name: Build and install Rust library
run: cargo cinstall -p yara-x-capi --release --pkgconfigdir=${{ github.workspace }} --includedir=${{ github.workspace }} --libdir=${{ github.workspace }}

- name: Run Go tests
run: |
cd go
go test
cd go
go test
env:
PKG_CONFIG_PATH: ${{ github.workspace }}
LD_LIBRARY_PATH: ${{ github.workspace }}
6 changes: 3 additions & 3 deletions capi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ bootstrap-vcpkg.bat
vcpkg install openssl:x64-windows-static
set OPENSSL_DIR=%cd%\installed\x64-windows-static
```
Once you have installed the pre-requisites, go to the root directory
of the YARA-X repository and type:
Expand All @@ -48,7 +48,7 @@ cargo cinstall -p yara-x-capi --release
The command above will put the library and header files in the correct path
in your system (usually `/usr/local/lib` and `/usr/local/include` for Linux
and MacOS users), and will generate a `.pc` file so that `pkg-config` knows
and MacOS users), and will generate a `.pc` file so that `pkg-config` knows
about the library.
In Linux and MacOS you can check if everything went fine by compiling a simple
Expand All @@ -71,7 +71,7 @@ gcc `pkg-config --cflags yara_x_capi` `pkg-config --libs yara_x_capi` test.c
The compilation should succeed without errors.
Windows users can find all the files you need for importing the YARA-X library
Windows users can find all the files you need for importing the YARA-X library
in your project in the `target/x86_64-pc-windows-msvc/release` directory. This
includes:
Expand Down
2 changes: 1 addition & 1 deletion go/compiler.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package yara_x

// #include <yara-x.h>
// #include <yara_x.h>
import "C"
import (
"errors"
Expand Down
2 changes: 1 addition & 1 deletion go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package yara_x

// #cgo !static_link pkg-config: yara_x_capi
// #cgo static_link pkg-config: --static yara_x_capi
// #import <yara_x.h>
// #include <yara_x.h>
import "C"
import (
"errors"
Expand Down
2 changes: 1 addition & 1 deletion go/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/golang/protobuf/proto"
)

// #include <yara-x.h>
// #include <yara_x.h>
// void onMatchingRule(YRX_RULE*, void*);
import "C"

Expand Down

0 comments on commit 3be2a67

Please sign in to comment.