From 73ef2dcefbab2cbb99fc215e105529315d1cddb7 Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Thu, 13 Jun 2024 21:34:49 -0500 Subject: [PATCH 1/2] Build reliability improvements 1. Don't skip tsc on install script. Previously, if `script/build.js` exists, we would skip the C++ build. 2. Fix issue with github tags if ZMQ version provided as semver. (github seems to normalize tarballed directory name by stripping leading `v` from tag) 3. Build scripts before node-gyp. Build library wrappers after. --- package.json | 15 ++++++++------- script/build.ts | 10 ++++++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 960c0755..53ac0b63 100644 --- a/package.json +++ b/package.json @@ -79,8 +79,10 @@ "tsconfig.json" ], "scripts": { - "install": "(shx test -f ./script/build.js || run-s build.js) && cross-env npm_config_build_from_source=true aminya-node-gyp-build", - "clean": "shx rm -rf ./build ./lib/ ./prebuilds ./script/*.js ./script/*.js.map ./script/*.d.ts ./script/*.tsbuildinfo", + "preinstall": "run-s build.script", + "install": "node-gyp-build", + "prepare": "run-s build.library", + "clean": "shx rm -rf ./build ./lib/ ./prebuilds", "clean.temp": "shx rm -rf ./tmp && shx mkdir -p ./tmp && shx touch ./tmp/.gitkeep", "build.library.compat": "shx rm -rf ./lib/ts3.7 && downlevel-dts ./lib ./lib/ts3.7 --to=3.7", "build.library": "tsc -p ./src/tsconfig.json && run-s build.library.compat", @@ -88,11 +90,11 @@ "build.js": "run-p build.script build.library", "build.doc": "typedoc --options ./typedoc.json && minify-all -s docs-raw -d docs --jsCompressor terser", "deploy.doc": "run-s build.doc && gh-pages --dist \"./docs\"", - "prebuild": "run-s build.js && node ./script/prebuild.js", + "prebuild": "node ./script/prebuild.js", "build.native": "node-gyp configure --release && node-gyp configure --release -- -f compile_commands_json && node-gyp build --release", "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", - "build": "run-s build.js build.native", - "build.debug": "run-s build.js build.native.debug", + "build": "run-s build.native", + "build.debug": "run-s build.native.debug", "test.deps": "cd test && pnpm install && cd ..", "test": "run-s test.deps build && mocha --exit", "test.skip_gc_tests": "run-s test.deps build.debug && cross-env SKIP_GC_TESTS=true mocha --exit", @@ -104,8 +106,7 @@ "lint.eslint": "pnpm run lint-test.eslint --fix", "lint": "run-p lint.eslint lint.clang-format", "lint-test": "run-s lint-test.eslint", - "bench": "node --expose-gc test/bench", - "prepublishOnly": "pnpm run build.js" + "bench": "node --expose-gc test/bench" }, "keywords": [ "zeromq", diff --git a/script/build.ts b/script/build.ts index b342e18c..080fbb57 100644 --- a/script/build.ts +++ b/script/build.ts @@ -5,11 +5,13 @@ import {mkdir, cd, exec, find, mv} from "shelljs" const root = dirname(__dirname) function main() { - const zmq_rev = - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/strict-boolean-expressions - process.env.ZMQ_VERSION || "5657b4586f24ec433930e8ece02ddba7afcf0fe0" - const src_url = `https://github.com/zeromq/libzmq/archive/${zmq_rev}.tar.gz` + // Revision to use. Can be a version number like "4.3.5", a branch name, or a commit hash. + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/strict-boolean-expressions + const zmq_rev = process.env.ZMQ_VERSION || "4.3.5" + // if it looks like a dot-separated version number, prepend with "v" to match repo tagging convention + const gitref = zmq_rev.match(/^\d+\./) ? `v${zmq_rev}` : zmq_rev + const src_url = `https://github.com/zeromq/libzmq/archive/${gitref}.tar.gz` const libzmq_build_prefix = `${root}/build/libzmq-staging` const libzmq_install_prefix = `${root}/build/libzmq` From 6cd7d928e2bc1ee11eb4de46cdcb5e543558ac8a Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Fri, 14 Jun 2024 18:04:04 -0500 Subject: [PATCH 2/2] bump workflow versions --- package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/package.json b/package.json index 3b514bc0..12a5e274 100644 --- a/package.json +++ b/package.json @@ -79,18 +79,16 @@ "prebuilds", "tsconfig.json" ], - "scripts": + "scripts": { "preinstall": "run-s build.script", "prepare": "run-s build.library", "clean": "shx rm -rf ./build ./lib/ ./prebuilds", "clean.temp": "shx rm -rf ./tmp && shx mkdir -p ./tmp && shx touch ./tmp/.gitkeep", "deploy.doc": "run-s build.doc && gh-pages --dist \"./docs\"", "install": "aminya-node-gyp-build", - "clean": "shx rm -rf ./build ./lib/ ./prebuilds", "build.library": "tsc -p ./src/tsconfig.json", "build.script": "tsc -p ./script/tsconfig.json && tsc -p ./script/tsconfig.esm.json", "build.doc": "typedoc --options ./typedoc.json && minify-all -s docs-raw -d docs --jsCompressor terser", - "deploy.doc": "run-s build.doc && gh-pages --dist \"./docs\"", "build.prebuild": "node ./script/prebuild.mjs", "build.native": "node-gyp configure --release && node-gyp configure --release -- -f compile_commands_json && node-gyp build --release", "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",