Skip to content

Commit

Permalink
Add CI flow for linux plugin build
Browse files Browse the repository at this point in the history
  • Loading branch information
wargio committed Nov 27, 2023
1 parent 7b0eebe commit 3f0d78f
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .ci-scripts/ci-build-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash
set -e

CI_BRANCH="$1"
CI_JSDEC="$PWD"
CI_RZ_VERSION=$(curl -s GET https://api.github.com/repos/rizinorg/rizin/tags\?per_page\=1 | jq -r '.[].name')

echo "CI_BRANCH: $CI_BRANCH"
echo "CI_RZ_VERSION: $CI_RZ_VERSION"
echo "CI_JSDEC: $CI_JSDEC"

# avoid placing rizin in the same folder.
cd ..

# create a rizin folder and get inside it.
mkdir rizin
cd rizin
CI_RIZIN="$PWD"
echo "CI_RIZIN: $CI_RIZIN"

DEBUGME=1 pwd ; ls -lah

# download the latest tagged rizin version and extract it
wget -O "rizin.tar.xz" "https://github.com/rizinorg/rizin/releases/download/$CI_RZ_VERSION/rizin-$CI_RZ_VERSION-static-x86_64.tar.xz"
DEBUGME=1 pwd ; ls -lah
tar xvf "rizin.tar.xz"

DEBUGME=1 pwd ; ls -lah

# add the extracted content to the pkg-config/path
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$CI_RIZIN/lib/pkgconfig"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CI_RIZIN/lib"
export CFLAGS="$CFLAGS -I$CI_RIZIN/include/librz -I$CI_RIZIN/include/librz/sdb"
export PATH="$PATH:$CI_RIZIN/bin"
echo "PATH: $PATH"
echo "CFLAGS: $CFLAGS"
echo "PKG_CONFIG_PATH: $PKG_CONFIG_PATH"
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"

# go back to the source folder of jsdec
cd "$CI_JSDEC"

# build jsdec and install in the rizin dir.
meson -Dstandalone=false --prefix="$CI_RIZIN" build
ninja -v -C build install

# check if it was installed correctly and try to run it.
HAS_JSDEC=$(rizin -Qc "Lc" | grep jsdec)
if [ -z "$HAS_JSDEC" ]; then
echo "rizin failed to load jsdec."
rizin -e log.level=2 -Qc "Lc" | grep jsdec || sleep 0
exit 1
fi

OUTPUT=$(rizin -Qc 'af ; pdd' /bin/ls)
CHECK=$(echo -e "$OUTPUT" | grep "jsdec pseudo code output")
echo -e "$OUTPUT"
if [ -z "$CHECK" ]; then
exit 1
fi
34 changes: 34 additions & 0 deletions .github/workflows/build-plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: build-plugin

on:
push:
branches:
- master
- dev
pull_request:


# Automatically cancel any previous workflow on new push.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
linux:
runs-on: ubuntu-latest
container:
image: alpine:edge
options: --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --security-opt apparmor=unconfined
steps:
- name: Install dependencies
run: apk add --no-cache git gcc g++ linux-headers cmake curl wget unzip py3-wheel py3-setuptools py3-pip meson ninja xz
- name: Checkout jsdec
run: |
git clone https://github.com/${{ github.repository }}
cd jsdec
git fetch origin ${{ github.ref }}
git checkout -b local_branch FETCH_HEAD
- name: build & run the plugin
run: |
chmod +x .ci-scripts/ci-build-linux.sh
.ci-scripts/ci-build-linux.sh "${{ github.ref_name }}"
1 change: 1 addition & 0 deletions .github/workflows/continuous-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- master
- dev
pull_request:

jobs:
Expand Down

0 comments on commit 3f0d78f

Please sign in to comment.