Skip to content

Commit

Permalink
ci: add smoke-test for various node version and package managers
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Oct 25, 2024
1 parent bde7474 commit c518b02
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 6 deletions.
42 changes: 41 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ jobs:
pnpm install -g electron@latest
xvfb-run --auto-servernum pnpm run test.electron.main
continue-on-error: true
merge-build:

MergeBuild:
runs-on: ubuntu-latest
needs: Build
steps:
Expand All @@ -199,3 +200,42 @@ jobs:
name: build
pattern: build-*
delete-merged: true

SmokeTest:
runs-on: ${{ matrix.os }}
needs: MergeBuild
strategy:
fail-fast: false
matrix:
os:
- ubuntu-24.04
- windows-2022
- macos-14
- macos-13
node-version:
- 10
- 22
steps:
- uses: actions/setup-node@v4

- name: Place Builds
uses: actions/download-artifact@v4
with:
name: build
path: ./build

- name: Install Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Install Yarn
run: |
npm i -g yarn
yarn set version stable
- name: Smoke Test
run: npm run test.smoke
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ tsconfig.*.tsbuildinfo
!/lib/load-addon.js
!/lib/load-addon.js.map

compile_commands.json
compile_commands.json

/smoke-test-*
/*.tgz
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"build": "run-p build.js build.native",
"build.debug": "run-s build.js build.native.debug",
"test": "run-s clean.temp build && mocha",
"test.smoke": "bash ./script/smoke-test.bash",
"test.skip_gc_tests": "run-s clean.temp build.debug && cross-env SKIP_GC_TESTS=true mocha",
"test.electron.main": "run-s clean.temp build && electron-mocha",
"format": "run-s format.prettier format.clang-format",
Expand Down
37 changes: 37 additions & 0 deletions script/smoke-test.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/bash
set -ev
set -o pipefail

echo "Pack zeromq.js"
version=$(npm pkg get version | tr -d '"')
pack_name="zeromq-${version}.tgz"
rm -f "${pack_name}"
npm pack

init_smoke_test() {
local pm=$1
echo "Init Smoke Test Project ${pm}"

rm -rf "./smoke-test-${pm}"
mkdir "./smoke-test-${pm}"
cd "./smoke-test-${pm}"
npm init -q --init-module "smoke-test-${pm}" -y
npm pkg set dependencies.zeromq="file:../${pack_name}"
}

package_managers=(npm pnpm yarn)

for pm in "${package_managers[@]}"; do
init_smoke_test "${pm}"

echo "Install with ${pm}"
${pm} install

echo "Require zeromq"
node -e "console.log(require('zeromq'))"

cd ../
rm -rf "./smoke-test-${pm}"
done

rm -f "${pack_name}"
4 changes: 2 additions & 2 deletions src/module.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

#include <array>

#include "./module.h"

#include <array>

#include "./context.h"
#include "./observer.h"
#include "./outgoing_msg.h"
Expand Down
1 change: 1 addition & 0 deletions src/outgoing_msg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "./outgoing_msg.h"

#include <functional>

#include "./module.h"
#include "util/error.h"

Expand Down
4 changes: 2 additions & 2 deletions src/poller.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class Poller {
/* Initialize the poller with the given file descriptor. FD should be
ZMQ style edge-triggered, with READABLE state indicating that ANY
event may be present on the corresponding ZMQ socket. */
int32_t Initialize(
Napi::Env env, uv_os_sock_t& file_descriptor, std::function<void()> finalizer = nullptr) {
int32_t Initialize(Napi::Env env, uv_os_sock_t& file_descriptor,
std::function<void()> finalizer = nullptr) {
auto* loop = UvLoop(env);

poll->data = this;
Expand Down

0 comments on commit c518b02

Please sign in to comment.