Skip to content

Commit

Permalink
Update tests to gitlab and github
Browse files Browse the repository at this point in the history
  • Loading branch information
Sirherobrine23 committed Feb 18, 2024
1 parent 499cf79 commit 5bfd90a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 49 deletions.
72 changes: 35 additions & 37 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,46 @@ on:
- main

jobs:
linux_test:
test_js:
name: Test Javascript code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout

- name: "Setup zig"
uses: korandoru/setup-zig@v1
with:
zig-version: "master"

- uses: actions/setup-node@v4
name: Setup Node.js
with:
node-version: 20.x

- name: Install dependencies
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt update
sudo apt install -y "binutils-multiarch" "build-essential"
npm install --no-save --ignore-scripts
- name: Build addon
run: npm run dev

- name: Run tests
env:
FORCE_COLOR: "true"
run: sudo node --no-warnings --loader ts-node/esm src/index_test.ts

build_addon:
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [ 16.x, 18.x, 19.x, 20.x, 21.x ]
target_arch: [ "x86_64", "aarch64" ]
target_os:
- "linux"
# - "windows"
# - "macos"
steps:
- uses: actions/checkout@v4
Expand All @@ -40,44 +71,11 @@ jobs:
npm install --no-save --ignore-scripts
- name: Build addon
run: npm run dev -- --target_zig=${{ matrix.target_arch }}-${{ matrix.target_os }}
run: npm run dev -- --target ${{ matrix.target_arch }}-${{ matrix.target_os }}

- name: Upload prebuilds interface
uses: actions/upload-artifact@v3
with:
retention-days: 7
name: prebuilds_${{ matrix.target_arch }}-${{ matrix.target_os }}_${{ matrix.node_version }}
path: "prebuilds/**"

- name: Test
run: node --require ts-node/register --loader ts-node/esm ./src/index_test.ts

pack_package:
needs: linux_test
runs-on: ubuntu-latest
name: Pack npm package
env:
PACKAGE_VERSION: ${{ github.ref }}
steps:
- uses: actions/checkout@v4
name: Code checkout

- uses: actions/setup-node@v4
name: Setup node.js
with:
node-version: 20.x
registry-url: https://registry.npmjs.org/

- name: Download all artefacts
uses: actions/download-artifact@v3
with:
path: ./prebuilds

- run: npm install --no-save --ignore-scripts
- run: npm pack

- name: Upload npm package
uses: actions/upload-artifact@v3
with:
name: Package_Pack
path: "*.tgz"
path: "build/*"
20 changes: 9 additions & 11 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ test:
export DEBIAN_FRONTEND=noninteractive
sudo apt update
wget -qO- https://deb.nodesource.com/setup_current.x | sudo bash -
packages=( "binutils-multiarch" "wget" "curl" "nodejs" );
if [[ $(uname -m) == "x86_64" ]];then
packages+=( "gcc-*aarch64-linux-gnu" "gcc-*aarch64-linux-gnu-base" "g++-*aarch64-linux-gnu" "libc6-arm64-cross" )
else
packages+=( "libc6-amd64-cross" "g++-*x86-64-linux-gnu" "g++-*x86-64-linux-gnux32" "gcc-*x86-64-linux-gnu" "gcc-*x86-64-linux-gnux32" )
if [[ $(uname -m) != "aarch64" ]];then
packages+=( "gcc-*aarch64-linux-gnu" "gcc-*aarch64-linux-gnu-base" "g++-*aarch64-linux-gnu" "libc6-arm64-cross" )
fi
fi
packages=( "binutils-multiarch" "wget" "curl" "nodejs" "build-essential" );
sudo apt install -y ${packages[@]}
ZIGURL="https://ziglang.org/download/0.11.0/zig-linux-x86_64-0.11.0.tar.xz"
wget -qO- "${ZIGURL}" | sudo tar -xvJ -C /usr/local
sudo mv -v /usr/local/zig-linux /usr/local/zig
sudo ln -vs /usr/local/zig/bin/zig /usr/bin/zig
- npm install --no-save --ignore-scripts
- npm run prebuildify -- -v
- sudo node --require ts-node/register --loader ts-node/esm ./src/index_test.ts
- npm run dev
- sudo node --no-warnings --loader ts-node/esm ./src/index_test.ts
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"scripts": {
"install": "rebory prebuild",
"dev": "rebory build -DP",
"test": "rebory build -D && node --no-warnings --loader ts-node/esm src/index_test.js",
"prepack": "tsc --build --clean && tsc --build",
"postpack": "tsc --build --clean"
},
Expand All @@ -45,6 +46,6 @@
},
"dependencies": {
"node-addon-api": "^7.1.0",
"rebory": "^0.1.10"
"rebory": "^0.1.11-2"
}
}

0 comments on commit 5bfd90a

Please sign in to comment.