GitHub
05/12/2023, 2:52 PMnpm install @pact-foundation/pact --ignore-scripts on any major platform/architecture, and I am on a supported version of node, I should be able to install Pact
ποΈ Design
β
Acceptance Criteria
GIVEN I have node version 16, 18 or 20 installed
AND I am on one of the following platforms
WHEN I run npm install @pact-foundation/pact --ignore-scripts
THEN I should be able to use pact
β
= installs without build hooks, pre-built native library
β = not supported
π« Out of Scope
β’ Alpine Linux
β’ Requires .so file building - will come later
β’ Arm64 Windows
β’ Requires .dll file building - will come later
π Summary of Changes
Changes proposed in this pull request:
1. use prebuilidfy npx prebuildify --napi to generate bindings for each targeted platform/arch combination
β―tree prebuilds
prebuilds
βββ darwin-arm64
βββ libpact_ffi.dylib
βββ node.napi.node
2. Use combination of cirrus-ci / github-actions to test generated napi build against supported LTS versions of node
β οΈ Items of Note
Ruby arm64 runtimes
β’ Currently using #445 which relies on my pact-ruby-standalone fork release
β’ https://github.com/YOU54F/pact-ruby-standalone/releases/tag/v2.2.1
β’ PR raised here - pact-foundation/pact-ruby-standalone#105
node-addon-api compatability
ABI Matrix
Screenshot 2023-04-21 at 12 43 10βΎ
Screenshot 2023-04-21 at 12 42 50βΎ
NAPI_VERSION=3 here
https://github.com/YOU54F/pact-js-core/blob/master/native/ffi.cc#L1
anything lower and it fails to build.
Looking at the ABI compat matrix, version 8 supports v12 which is EOL, v14 which is going EOL end of the month, but raises minimum compat up to v15.12.0 (for v15 users)
I'm not sure what the implications are of leaving it at the lowest version it will compile with (which is NAPI_VERSION=3).
I also don't understand why that chart isn't updated, to include v17->v20, especially as that matrix for the node-api version matrix is on the node v20 ref docs
This PR seeks to address those concerns, by allowing maintainers to easily add or remove different versions of node for testing, and ensuring the latest LTS versions are tested and covered.
A combination of nvm and nvs is used to manage node versions in .cirrus.yml, as nvs offers a nicer interface for getting x64 builds which you are on arm hardware (testing rosetta on MacOS)
π¨ How To Test
π» Local Machine
1. Checkout the branch prebuildify.
2. Run bash script/download-libs.sh
β’ This downloads the FFI libraries for building, end users wont do this
4. Run npm ci --ignore-scripts
β’ This installs our node_modules we only need node-addon-api for now
5. Run npx prebuildify --napi
β’ This run node-gyp-build and outputs a platform specific pact.node in the prebuilds directory
β’ This step used to be performed by end users, and required a full python build chain amongst other things with node-gyp
6. Run rm -rf build ffi
β’ This deletes folders we wont distribute in the end binary, and makes sure you are using the prebuilds
β’ It would read the prebuild anyway, but I just like to be sure
7. Run npm run build
β’ This transpiles the typescript into javascript
8. Run npm run test
β’ Hopefully all green!
π±βπ» Local Machine - GitHub Actions
1. Download Act
2. Download Docker (or Podman)
Linux workflows
act --container-architecture linux/amd64 -W .github/workflows/build-and-test.yml --artifact-server-path pkgs
π±βπ» Local Machine - Cirrus CLI
1. Download Cirrus CLI
2. Download Docker (or Podman)
3. If on an arm64 mac, download tart.run
Linux workflows
cirrus run --output github-actions "linux_amd64" --artifacts-dir pkgs
MacOS workflows
cirrus run --output github-actions "macos_arm_prebuilder" --artifacts-dir pkgs
cirrus run --output github-actions "macos_x64_prebuilder" --artifacts-dir pkg
pact-foundation/pact-js-core
GitHub Actions: release_dry_run
β
16 other checks have passed
16/17 successful checksGitHub
05/30/2023, 1:08 PM