Skip to content

Commit

Permalink
Out of Band NAPI
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Kovar <miroslav.kovar@absa.africa>
  • Loading branch information
mirgee committed Jan 11, 2023
1 parent 8481495 commit a2b777a
Show file tree
Hide file tree
Showing 118 changed files with 3,870 additions and 8,676 deletions.
65 changes: 65 additions & 0 deletions .github/actions/build-napi/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: 'build-napi-artifact'
description: |
Builds napi artifact using specified settings'
inputs:
docker:
required: true
target:
required: true
build:
required: true
node-version:
default: 18
rust-version:
default: 1.64.0

runs:
using: "composite"
steps:
- name: Setup node
uses: actions/setup-node@v3
if: ${{ !inputs.docker }}
with:
node-version: ${{ inputs.node-version }}
cache: npm
cache-dependency-path: ${{ github.workspace }}/wrappers/vcx-napi-rs/package-lock.json
- name: Install
uses: actions-rs/toolchain@v1
if: ${{ !inputs.docker }}
with:
toolchain: ${{ inputs.rust-version }}
target: ${{ inputs.target }}
default: true
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
target/
key: ${{ inputs.target }}-cargo-registry
- name: Install dependencies
run: npm install
working-directory: ${{ github.workspace }}/wrappers/vcx-napi-rs
shell: bash
- name: Build in docker
uses: addnab/docker-run-action@v3
if: ${{ inputs.docker }}
with:
image: ${{ inputs.docker }}
options: -v /home/runner/.cargo/git/db:/root/.cargo/git/db -v /home/runner/.cargo/registry/cache:/root/.cargo/registry/cache -v /home/runner/.cargo/registry/index:/root/.cargo/registry/index -v ${{ github.workspace }}:/build -w /build
run: ${{ inputs.build }}
- name: Build
run: ${{ inputs.build }}
if: ${{ !inputs.docker }}
working-directory: ${{ github.workspace }}/wrappers/vcx-napi-rs
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: bindings-${{ inputs.target }}
path: ${{ github.workspace }}/wrappers/vcx-napi-rs/*.node
if-no-files-found: error
17 changes: 12 additions & 5 deletions .github/actions/detect-skip-info/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,24 @@ runs:
shell: bash
run: |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'skip-ios') }}" == "true" ]]; then
echo "Detected tag to skip E2E tests"
echo "Detected tag to skip ios"
echo "skip-ios=true" >> $GITHUB_OUTPUT
else
echo "skip-ios=false" >> $GITHUB_OUTPUT
fi
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'skip-android') }}" == "true" ]]; then
echo "Detected tag to skip E2E tests"
echo "Detected tag to skip android"
echo "skip-android=true" >> $GITHUB_OUTPUT
else
else
echo "skip-android=false" >> $GITHUB_OUTPUT
fi;
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'skip-napi-m1') }}" == "true" ]]; then
echo "Detected tag to skip M1 napi build"
echo "skip-napi-m1=true" >> $GITHUB_OUTPUT
else
echo "skip-napi-m1=false" >> $GITHUB_OUTPUT
fi;
echo "Finished, GITHUB_OUTPUT:\n`cat $GITHUB_OUTPUT`"
52 changes: 52 additions & 0 deletions .github/actions/publish-napi/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: 'publish-napi'
description: |
Publishes vcx-napi-rs node packages
inputs:
publish-version:
required: true
npmjs-token:
required: true
node-version:
default: 18

runs:
using: "composite"
steps:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
cache: npm
cache-dependency-path: ${{ github.workspace }}/wrappers/vcx-napi-rs/package-lock.json
- name: Install dependencies
run: npm install
working-directory: ${{ github.workspace }}/wrappers/vcx-napi-rs
shell: bash
- name: Download napi artifacts
uses: actions/download-artifact@v3
with:
path: ${{ github.workspace }}/wrappers/vcx-napi-rs/artifacts
- name: Move artifacts
run: |
find . -type d -not -path \*\*/artifacts/bindings-\* -path \*\*/artifacts/\*\* -mindepth 2 -maxdepth 2 -exec rm -rf {} \+
ls -R artifacts
npm run artifacts
working-directory: ${{ github.workspace }}/wrappers/vcx-napi-rs
shell: bash
- name: Publish
run: |
if [[ "$PUBLISH_VERSION" ]]
then
npm set "//registry.npmjs.org/:_authToken" $NPMJS_TOKEN
npm version $PUBLISH_VERSION
npm run prepublish
npm publish
else
echo "New version was not defined, skipping release."
fi
working-directory: ${{ github.workspace }}/wrappers/vcx-napi-rs
shell: bash
env:
NPMJS_TOKEN: ${{ inputs.npmjs-token }}
PUBLISH_VERSION: ${{ inputs.publish-version }}
10 changes: 9 additions & 1 deletion .github/actions/setup-testing-nodejs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ runs:
docker run --rm -d --name indypool --network host ${{ env.DOCKER_IMAGE_POOL }}
sleep 5
docker-compose -f ./ci/agency/docker-compose.yml up -d
- name: "Build binding module"
shell: bash
run: (cd wrappers/vcx-napi-rs && npm install && npm run build:napi:debug)
- name: "Transpile TS wrapper"
shell: bash
run: (cd wrappers/node && npm install && npm run tscversion && npm run compile)
run: (cd wrappers/node && npm install && npm run compile)
- name: "Check wrappers"
shell: bash
run: |
ls -lah wrappers/vcx-napi-rs
ls -lah wrappers/node
93 changes: 88 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ env:
DOCKER_REPO_LOCAL_LIBVCX: libvcx
DOCKER_REPO_LOCAL_ANDROID: android-test

RUST_TOOLCHAIN_VERSON: 1.64.0
NODE_VERSION: 18

jobs:
verify-code-formatting:
runs-on: ubuntu-20.04
Expand All @@ -44,6 +47,7 @@ jobs:

SKIP_IOS: ${{ steps.skip-info.outputs.skip-ios }}
SKIP_ANDROID: ${{ steps.skip-info.outputs.skip-android }}
SKIP_NAPI_M1: ${{ steps.skip-info.outputs.skip-napi-m1 }}

DOCKER_IMG_CACHED_ALPINE_CORE: ${{ steps.docker-imgs.outputs.DOCKER_IMG_CACHED_ALPINE_CORE }}
DOCKER_IMG_CACHED_LIBVCX: ${{ steps.docker-imgs.outputs.DOCKER_IMG_CACHED_LIBVCX }}
Expand Down Expand Up @@ -377,7 +381,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [12.x, 18.x, 19.x]
node-version: [12.x, 18.x]
steps:
- name: "Git checkout"
uses: actions/checkout@v3
Expand All @@ -387,14 +391,14 @@ jobs:
skip-docker-setup: true
node-version: ${{ matrix.node-version }}
- name: "Run tests"
run: cd wrappers/node && npm run test
run: cd wrappers/node && RUST_LOG=vcx=trace npm run test

test-integration-node-wrapper:
needs: workflow-setup
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [12.x, 18.x, 19.x]
node-version: [12.x, 18.x]
steps:
- name: "Git checkout"
uses: actions/checkout@v3
Expand Down Expand Up @@ -635,10 +639,10 @@ jobs:
steps:
- name: "Git checkout"
uses: actions/checkout@v3
- name: Use Node.js 12
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 18.x
- name: "Run tests"
run: |
if [[ "$PUBLISH_VERSION" ]]
Expand Down Expand Up @@ -679,6 +683,85 @@ jobs:
echo "New version was not defined, skipping release."
fi
build-napi:
needs:
- workflow-setup
strategy:
fail-fast: false
matrix:
settings:
- host: ubuntu-20.04
target: x86_64-unknown-linux-gnu
build: |-
set -e
sudo apt-get update -y
sudo apt-get install -y libssl-dev libzmq3-dev
npm run build:napi -- --target x86_64-unknown-linux-gnu
strip *.node
- host: ubuntu-20.04
target: x86_64-unknown-linux-musl
docker: ghcr.io/hyperledger/aries-vcx/napi-rs-alpine
build: |-
set -e
cd wrappers/vcx-napi-rs
npm run build:napi
strip *.node
- host: macos-latest
target: x86_64-apple-darwin
build: |
brew install openssl zmq
npm run build:napi
strip -x *.node
- host: macos-latest
target: aarch64-apple-darwin
skip: ${{ needs.workflow-setup.outputs.SKIP_NAPI_M1 }}
build: |
wget https://github.com/macports/macports-base/releases/download/v2.8.0/MacPorts-2.8.0-12-Monterey.pkg
sudo installer -pkg ./MacPorts-2.8.0-12-Monterey.pkg -target /
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
sudo port install openssl +universal zmq +universal
export OPENSSL_DIR=/opt/local
export OPENSSL_INCLUDE_DIR=/opt/local/include/
export OPENSSL_LIB_DIR=/opt/local/lib/
export SODIUM_LIB_DIR=/opt/local/lib/
export SODIUM_INCLUDE_DIR=/opt/local/include
export LIBZMQ_LIB_DIR=/opt/local/lib/
export LIBZMQ_INCLUDE_DIR=/opt/local/include
export PKG_CONFIG_ALLOW_CROSS=1
export PKG_CONFIG_SYSROOT_DIR=/
export RUST_BACKTRACE=1
npm run build:napi -- --target aarch64-apple-darwin
strip -x *.node
name: ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/build-napi
if: ${{ matrix.settings.skip != 'true' }}
with:
docker: ${{ matrix.settings.docker }}
target: ${{ matrix.settings.target }}
build: ${{ matrix.settings.build }}
node-version: ${{ env.NODE_VERSION }}
rust-version: ${{ env.RUST_TOOLCHAIN_VERSON }}

publish-napi:
runs-on: ubuntu-20.04
needs:
- workflow-setup
- build-napi
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/publish-napi
with:
publish-version: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}
npmjs-token: ${{ secrets.NPMJS_TOKEN }}
node-version: ${{ env.NODE_VERSION }}

# ##########################################################################################
# ############################## RELEASE #########################################

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
**/target
**/.DS_Store
**/node_modules
**/*.node
wrappers/ios/vcx/vcx.framework/**
wrappers/ios/vcx/vcx.framework.dSYM/**
wrappers/ios_legacy/vcx/vcx.framework/**
Expand Down
Loading

0 comments on commit a2b777a

Please sign in to comment.