Skip to content

Commit f07714d

Browse files
authored
Merge pull request #670 from zeromq/smoke-test [skip ci]
2 parents bde7474 + d448f41 commit f07714d

15 files changed

+175
-22
lines changed

.github/workflows/CI.yml

+88-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ jobs:
157157
docker tag ${{ matrix.docker }} builder
158158
docker run --volume ${{ github.workspace }}:/app --workdir /app --privileged builder sh -c "${{ matrix.docker_cmd }}"
159159
160-
- name: Upload artifacts
160+
- name: Upload build
161161
uses: actions/upload-artifact@v4
162162
with:
163163
path: ./build
@@ -189,7 +189,8 @@ jobs:
189189
pnpm install -g electron@latest
190190
xvfb-run --auto-servernum pnpm run test.electron.main
191191
continue-on-error: true
192-
merge-build:
192+
193+
Package:
193194
runs-on: ubuntu-latest
194195
needs: Build
195196
steps:
@@ -199,3 +200,88 @@ jobs:
199200
name: build
200201
pattern: build-*
201202
delete-merged: true
203+
204+
- uses: actions/checkout@v4
205+
206+
- name: Place build
207+
uses: actions/download-artifact@v4
208+
with:
209+
name: build
210+
path: ./build
211+
212+
- name: Install Node
213+
uses: actions/setup-node@v4
214+
with:
215+
node-version-file: "./.nvmrc"
216+
217+
- name: Install Pnpm
218+
uses: pnpm/action-setup@v4
219+
with:
220+
version: 9
221+
222+
- name: Pack Zeromq
223+
run: |
224+
pnpm install
225+
pnpm pack
226+
227+
- name: Upload Pack
228+
uses: actions/upload-artifact@v4
229+
with:
230+
path: ./*.tgz
231+
name: pack
232+
overwrite: true
233+
234+
SmokeTest:
235+
runs-on: ${{ matrix.os }}
236+
needs: Package
237+
strategy:
238+
fail-fast: false
239+
matrix:
240+
os:
241+
- ubuntu-24.04
242+
- windows-2022
243+
- macos-13
244+
node-version:
245+
- 10
246+
- 22
247+
248+
include:
249+
- os: macos-14
250+
node-version: 22
251+
steps:
252+
- name: Install Node
253+
uses: actions/setup-node@v4
254+
with:
255+
node-version: ${{ matrix.node-version }}
256+
257+
- name: Install Yarn 1
258+
if: matrix.node-version == 10
259+
run: |
260+
npm i -g yarn@^1
261+
262+
- name: Install Yarn Latest
263+
if: matrix.node-version == 22
264+
run: |
265+
npm i -g yarn@latest
266+
267+
- name: Install Pnpm 5
268+
if: matrix.node-version == 10
269+
uses: pnpm/action-setup@v4
270+
with:
271+
version: 5
272+
273+
- name: Install Pnpm 9
274+
if: matrix.node-version == 22
275+
uses: pnpm/action-setup@v4
276+
with:
277+
version: 9
278+
279+
- uses: actions/checkout@v4
280+
281+
- name: Download Pack
282+
uses: actions/download-artifact@v4
283+
with:
284+
name: pack
285+
286+
- name: Smoke Test
287+
run: bash ./script/smoke-test.bash

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@ tsconfig.*.tsbuildinfo
2525
!/lib/load-addon.js
2626
!/lib/load-addon.js.map
2727

28-
compile_commands.json
28+
compile_commands.json
29+
30+
/smoke-test-*
31+
/*.tgz

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22.10.0

.vscode/settings.json

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
{
2+
"[typescript]": {
3+
"editor.defaultFormatter": "esbenp.prettier-vscode"
4+
},
5+
"[javascript]": {
6+
"editor.defaultFormatter": "esbenp.prettier-vscode"
7+
},
8+
"[json]": {
9+
"editor.defaultFormatter": "esbenp.prettier-vscode"
10+
},
11+
"[jsonc]": {
12+
"editor.defaultFormatter": "esbenp.prettier-vscode"
13+
},
214
"mochaExplorer.parallel": true,
315
"mochaExplorer.globImplementation": "vscode",
4-
"mochaExplorer.nodeArgv": ["--expose-gc"],
16+
"mochaExplorer.nodeArgv": [
17+
"--expose-gc"
18+
],
519
"mochaExplorer.debuggerConfig": "JS-Attach",
620
"files.exclude": {
721
"**/.DS_Store": true,

lib/load-addon.js

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/load-addon.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
],
8686
"scripts": {
8787
"install": "node ./script/install.js",
88-
"prepare": "pnpm run build.js",
8988
"clean": "shx rm -rf ./build ./prebuilds && run-p clean.lib clean.temp",
9089
"clean.lib": "shx rm -rf ./lib/",
9190
"clean.release": "shx rm -rf ./build/Release",
@@ -99,19 +98,22 @@
9998
"build": "run-p build.js build.native",
10099
"build.debug": "run-s build.js build.native.debug",
101100
"test": "run-s clean.temp build && mocha",
101+
"test.smoke": "bash ./script/smoke-test.bash",
102102
"test.skip_gc_tests": "run-s clean.temp build.debug && cross-env SKIP_GC_TESTS=true mocha",
103103
"test.electron.main": "run-s clean.temp build && electron-mocha",
104104
"format": "run-s format.prettier format.clang-format",
105-
"format.prettier": "prettier --write .",
105+
"format.prettier": "prettier -l --cache --cache-location ./.cache/prettier --write .",
106106
"format.clang-format": "clang-format -i -style=file ./src/*.cc ./src/*.h ./src/util/*.h",
107107
"test.electron.renderer": "run-s build && electron-mocha --renderer",
108108
"lint-test.eslint": "eslint ./**/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/",
109109
"lint.eslint": "pnpm run lint-test.eslint --fix",
110+
"lint.tsc": "tsc --noEmit -p ./src/tsconfig.json",
111+
"lint.tsc-test": "tsc --noEmit -p ./test/tsconfig.json",
110112
"lint.clang-tidy": "git ls-files --exclude-standard | grep -E '\\.(cpp|hpp|c|cc|cxx|hxx|h|ixx)$' | xargs -n 1 -P $(nproc) clang-tidy",
111-
"lint": "run-p format lint.eslint format",
113+
"lint": "run-p lint.tsc-test lint.tsc lint.eslint format",
112114
"lint-test": "run-s lint-test.eslint",
113115
"bench": "node --expose-gc test/bench",
114-
"prepublishOnly": "pnpm run build.js",
116+
"prepare": "pnpm run build.js",
115117
"bump": "pnpx npm-check-updates -u -x typescript,eslint,chai && pnpx typesync && pnpm update"
116118
},
117119
"cmake-ts": {

script/smoke-test.bash

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/bash
2+
set -ev
3+
set -o pipefail
4+
5+
root="${PWD}"
6+
7+
echo "Pack zeromq.js if needed"
8+
version=$(node -e 'console.log(require("./package.json").version)')
9+
pack_name="zeromq-${version}.tgz"
10+
test -f "./${pack_name}" || npm pack
11+
12+
package_managers=(npm pnpm yarn)
13+
14+
for pm in "${package_managers[@]}"; do
15+
dir="../zeromq-smoke-test-${pm}"
16+
17+
echo "Init Smoke Test Project ${pm}"
18+
rm -rf "${dir}"
19+
mkdir "${dir}"
20+
cp "./${pack_name}" "${dir}"
21+
cd "${dir}"
22+
npm init -y
23+
npm pkg set dependencies.zeromq="file:./${pack_name}" || (jq ".dependencies.zeromq = \"file:./${pack_name}\"" package.json >temp.json && mv temp.json package.json)
24+
25+
echo "Install with ${pm}"
26+
if [[ "${pm}" == "yarn" ]]; then
27+
yarn install --ignore-engines
28+
else
29+
${pm} install
30+
fi
31+
32+
echo "Require zeromq"
33+
node -e "console.log(require('zeromq'))"
34+
35+
cd "${root}"
36+
rm -rf "../zeromq-smoke-test-${pm}"
37+
done
38+
39+
rm -f "${pack_name}"

src/load-addon.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ function findAddon(): any | undefined {
5757
return addon
5858
}
5959

60-
module.exports = findAddon()
60+
const addon = findAddon()
61+
export default addon

src/module.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

2-
#include <array>
3-
42
#include "./module.h"
53

4+
#include <array>
5+
66
#include "./context.h"
77
#include "./observer.h"
88
#include "./outgoing_msg.h"

src/native.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
22

33
/* Declare all native C++ classes and methods in this file. */
4-
module.exports = require("./load-addon")
4+
import addon from "./load-addon"
5+
module.exports = addon
56

67
/**
78
* The version of the ØMQ library the bindings were built with. Formatted as

src/outgoing_msg.cc

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "./outgoing_msg.h"
33

44
#include <functional>
5+
56
#include "./module.h"
67
#include "util/error.h"
78

src/poller.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class Poller {
2323
/* Initialize the poller with the given file descriptor. FD should be
2424
ZMQ style edge-triggered, with READABLE state indicating that ANY
2525
event may be present on the corresponding ZMQ socket. */
26-
int32_t Initialize(
27-
Napi::Env env, uv_os_sock_t& file_descriptor, std::function<void()> finalizer = nullptr) {
26+
int32_t Initialize(Napi::Env env, uv_os_sock_t& file_descriptor,
27+
std::function<void()> finalizer = nullptr) {
2828
auto* loop = UvLoop(env);
2929

3030
poll->data = this;

test/tsconfig.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
{
22
"extends": "../tsconfig.json",
3-
"include": ["**/*.ts"]
3+
"include": ["**/*.ts"],
4+
"compilerOptions": {
5+
"skipLibCheck": true,
6+
"lib": [
7+
"ES2020",
8+
// only used in tests
9+
"ES2021.WeakRef"
10+
]
11+
}
412
}

tsconfig.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
"incremental": true,
2020
"sourceMap": true,
2121
"esModuleInterop": true,
22-
"lib": [
23-
"ES2020",
24-
// only used in tests
25-
"ES2021.WeakRef"
26-
]
22+
"lib": ["ES2020"]
2723
}
2824
}

0 commit comments

Comments
 (0)