From 79a9ab6819ddb508227d121913bbe3739cd9d788 Mon Sep 17 00:00:00 2001 From: Matheus Sampaio Queiroga Date: Sun, 18 Feb 2024 09:36:44 -0300 Subject: [PATCH] Update tests to gitlab and github --- .github/workflows/test.yml | 74 +++++++++++++++++++------------------- .gitlab-ci.yml | 20 +++++------ package.json | 3 +- 3 files changed, 47 insertions(+), 50 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 12da216..64dc26d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,16 +8,9 @@ on: - main jobs: - linux_test: + test_js: + name: Test Javascript code 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 name: Checkout @@ -30,7 +23,7 @@ jobs: - uses: actions/setup-node@v4 name: Setup Node.js with: - node-version: ${{ matrix.node_version }} + node-version: 20.x - name: Install dependencies run: | @@ -40,44 +33,49 @@ jobs: npm install --no-save --ignore-scripts - name: Build addon - run: npm run dev -- --target_zig=${{ 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/**" + run: npm run dev - - name: Test - run: node --require ts-node/register --loader ts-node/esm ./src/index_test.ts + - name: Run tests + env: + FORCE_COLOR: "true" + run: sudo node --no-warnings --loader ts-node/esm src/index_test.ts - pack_package: - needs: linux_test + build_addon: runs-on: ubuntu-latest - name: Pack npm package - env: - PACKAGE_VERSION: ${{ github.ref }} + strategy: + matrix: + node_version: [ 16.x, 18.x, 19.x, 20.x, 21.x ] + target_arch: [ "x86_64", "aarch64" ] + target_os: + - "linux" + - "macos" steps: - uses: actions/checkout@v4 - name: Code checkout + name: Checkout - - uses: actions/setup-node@v4 - name: Setup node.js + - name: "Setup zig" + uses: korandoru/setup-zig@v1 with: - node-version: 20.x - registry-url: https://registry.npmjs.org/ + zig-version: "master" - - name: Download all artefacts - uses: actions/download-artifact@v3 + - uses: actions/setup-node@v4 + name: Setup Node.js with: - path: ./prebuilds + node-version: ${{ matrix.node_version }} + + - 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 - - run: npm install --no-save --ignore-scripts - - run: npm pack + - name: Build addon + run: npm run dev -- --target ${{ matrix.target_arch }}-${{ matrix.target_os }} - - name: Upload npm package + - name: Upload prebuilds interface uses: actions/upload-artifact@v3 with: - name: Package_Pack - path: "*.tgz" + retention-days: 7 + name: prebuilds_${{ matrix.target_arch }}-${{ matrix.target_os }}_${{ matrix.node_version }} + path: "build/*" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 30e1217..6ea6c93 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/package.json b/package.json index 604cf54..72cfd8b 100644 --- a/package.json +++ b/package.json @@ -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" }, @@ -45,6 +46,6 @@ }, "dependencies": { "node-addon-api": "^7.1.0", - "rebory": "^0.1.10" + "rebory": "^0.1.11-2" } }