Skip to content

Commit b675b0a

Browse files
authoredJun 14, 2024··
Merge pull request #618 from zeromq/spawn-windows
fix: fix the Windows prebuilds + fix some of the test failures
2 parents 8fdf3cb + 3701e9d commit b675b0a

10 files changed

+155
-46
lines changed
 

‎.github/workflows/CI.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
docker: node:18-alpine
6666
docker_cmd:
6767
apk add --no-cache pkgconfig curl tar python3 make gcc g++ cmake
68-
musl-dev && npm i -g pnpm && pnpm install && pnpm run prebuild
68+
musl-dev && npm i -g pnpm && pnpm install && pnpm run build.prebuild
6969
node_version: 18
7070
node_arch: x64
7171
ARCH: x64
@@ -133,7 +133,7 @@ jobs:
133133

134134
- name: Prebuild
135135
if: ${{ !matrix.docker }}
136-
run: pnpm run prebuild
136+
run: pnpm run build.prebuild
137137

138138
- name: Prebuild Docker
139139
if: ${{ matrix.docker }}

‎.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@ test.js
1414
.cache/
1515
test/typings-compatibility/
1616
/script/*.js
17+
/script/*.mjs
1718
/script/*.d.ts
19+
/script/*.d.mts
1820
/script/*.js.map
21+
/script/*.mjs.map
1922
/script/*/*.js
23+
/script/*/*.mjs
2024
/script/*/*.d.ts
2125
/script/*/*.js.map
2226
tsconfig.tsbuildinfo
27+
tsconfig.esm.tsbuildinfo
2328
/docs-raw
2429
.DS_Store
2530
.idea

‎package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@
4040
"eslint": "^8",
4141
"eslint-config-atomic": "^1.22.0",
4242
"eslint-plugin-prettier": "^4.2.1",
43+
"execa": "^9.2.0",
4344
"fs-extra": "^10.1.0",
4445
"gh-pages": "^4.0.0",
4546
"minify-all-cli": "^1.0.13",
4647
"mocha": "^10.4.0",
4748
"node-gyp": "^10.1.0",
4849
"npm-run-all2": "^6.2.0",
49-
"prebuildify": "^5.0.1",
50+
"prebuildify": "^6.0.1",
5051
"prettier": "^2.8.8",
5152
"rocha": "^2.5.10",
5253
"semver": "^7.6.2",
@@ -82,13 +83,12 @@
8283
"install": "(shx test -f ./script/build.js || run-s build.js) && cross-env npm_config_build_from_source=true aminya-node-gyp-build",
8384
"clean": "shx rm -rf ./build ./lib/ ./prebuilds ./script/*.js ./script/*.js.map ./script/*.d.ts ./script/*.tsbuildinfo",
8485
"clean.temp": "shx rm -rf ./tmp && shx mkdir -p ./tmp && shx touch ./tmp/.gitkeep",
85-
"build.library.compat": "shx rm -rf ./lib/ts3.7 && downlevel-dts ./lib ./lib/ts3.7 --to=3.7",
86-
"build.library": "tsc -p ./src/tsconfig.json && run-s build.library.compat",
87-
"build.script": "tsc -p ./script/tsconfig.json",
86+
"build.library": "tsc -p ./src/tsconfig.json",
87+
"build.script": "tsc -p ./script/tsconfig.json && tsc -p ./script/tsconfig.esm.json",
8888
"build.js": "run-p build.script build.library",
8989
"build.doc": "typedoc --options ./typedoc.json && minify-all -s docs-raw -d docs --jsCompressor terser",
9090
"deploy.doc": "run-s build.doc && gh-pages --dist \"./docs\"",
91-
"prebuild": "run-s build.js && node ./script/prebuild.js",
91+
"build.prebuild": "run-s build.js && node ./script/prebuild.mjs",
9292
"build.native": "node-gyp configure --release && node-gyp configure --release -- -f compile_commands_json && node-gyp build --release",
9393
"build.native.debug": "node-gyp configure --debug && node-gyp configure --debug -- -f compile_commands_json && cross-env CMAKE_BUILD_TYPE=Debug node-gyp build --debug",
9494
"build": "run-s build.js build.native",

‎pnpm-lock.yaml

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

‎script/prebuild.ts ‎script/prebuild.mts

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {spawnSync} from "child_process"
2-
3-
main().catch(e => {
4-
throw e
5-
})
1+
import {execaCommandSync} from "execa"
62

73
async function main() {
84
console.log("Building distribution binary...")
@@ -37,13 +33,18 @@ async function main() {
3733
prebuildScript = `/alpine/enter-chroot ${prebuildScript}`
3834
}
3935

40-
spawnSync(prebuildScript, {
36+
execaCommandSync(prebuildScript, {
4137
shell: true,
38+
windowsHide: true,
4239
stdio: "inherit",
4340
encoding: "utf8",
4441
})
4542
}
4643

44+
main().catch(e => {
45+
throw e
46+
})
47+
4748
function getNodearch(): string {
4849
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/strict-boolean-expressions
4950
const arch = process.env.ARCH || process.arch

‎script/tsconfig.esm.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "ESNext",
5+
"moduleResolution": "node",
6+
},
7+
"include": ["./**/*.mts"],
8+
"exclude": []
9+
}

‎test/unit/proxy-terminate-test.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
2828
await proxy.frontEnd.bind(uniqAddress(proto))
2929
await proxy.backEnd.bind(uniqAddress(proto))
3030

31-
setTimeout(() => proxy.terminate(), 50)
32-
await proxy.run()
33-
3431
try {
32+
const timer = setTimeout(() => proxy.terminate(), 50)
33+
await proxy.run()
34+
3535
await proxy.terminate()
36+
timer.unref()
3637
assert.ok(false)
3738
} catch (err) {
3839
if (!isFullError(err)) {

‎test/unit/socket-construction-test.ts

-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ describe("socket construction", function () {
8686
}
8787
const sock1 = new MySocket()
8888
const sock2 = new MySocket()
89-
assert.instanceOf(sock1, zmq.Socket)
9089
assert.equal(sock1.context, sock2.context)
9190
})
9291

@@ -98,7 +97,6 @@ describe("socket construction", function () {
9897
}
9998
const context = new zmq.Context()
10099
const socket = new MySocket({context})
101-
assert.instanceOf(socket, zmq.Socket)
102100
assert.equal(socket.context, context)
103101
})
104102
})
@@ -121,7 +119,6 @@ describe("socket construction", function () {
121119
it("should create socket with given context", function () {
122120
const ctxt = new zmq.Context()
123121
const sock = new zmq.Dealer({context: ctxt})
124-
assert.instanceOf(sock, zmq.Socket)
125122
assert.equal(sock.context, ctxt)
126123
})
127124

‎test/unit/socket-curve-send-receive-test.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import {testProtos, uniqAddress} from "./helpers"
55

66
for (const proto of testProtos("tcp", "ipc", "inproc")) {
77
describe(`socket with ${proto} curve send/receive`, function () {
8+
if (!zmq.capability.curve) {
9+
return
10+
}
11+
812
let sockA: zmq.Pair
913
let sockB: zmq.Pair
1014

1115
beforeEach(function () {
12-
if (!zmq.capability.curve) {
13-
this.skip()
14-
}
15-
1616
const serverKeypair = zmq.curveKeyPair()
1717
const clientKeypair = zmq.curveKeyPair()
1818

@@ -39,10 +39,6 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
3939

4040
describe("when connected", function () {
4141
beforeEach(async function () {
42-
if (!zmq.capability.curve) {
43-
this.skip()
44-
}
45-
4642
const address = uniqAddress(proto)
4743
await sockB.bind(address)
4844
await sockA.connect(address)

‎test/unit/typings-compatibility-test.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ import {assert} from "chai"
2323
type TestDef = {version: string; minTarget: string; requiredLibs?: string[]}
2424

2525
const tsVersions: TestDef[] = [
26-
// the oldest supported version
27-
{version: "3.7.x", minTarget: "es3"},
28-
2926
// 4.x
3027
{version: "4.x", minTarget: "es3"},
3128
]
@@ -170,7 +167,9 @@ async function prepareTestPackage(
170167
async function getPackageManager() {
171168
const packageManagers = ["pnpm", "yarn", "npm"]
172169

173-
const versionResults = await Promise.all(packageManagers.map(pm => which(pm)))
170+
const versionResults: Array<string | null> = await Promise.all(
171+
packageManagers.map(pm => which(pm, {nothrow: true})),
172+
)
174173

175174
const packageManagerIndex = versionResults.findIndex(
176175
versionResult => typeof versionResult === "string",

0 commit comments

Comments
 (0)
Please sign in to comment.