Pact-Js-Core uses FFI bindings from the pact-reference project, which are prebuilt for end users, the following steps will show some of the steps required to build and test locally on your machine.
Do this and you should be 👌👌👌:
bash script/ci/prebuild.sh
supported_platforms=$(./script/ci/build-opt-dependencies.sh determine_platform)
./script/ci/build-opt-dependencies.sh build
./script/ci/build-opt-dependencies.sh link
npm run build
npm run testset supported platform to one of these values
linux-x64-glibclinux-arm64-glibclinux-x64-musllinux-arm64-musldarwin-x64darwin-arm64windows-x64
notes -
As a developer, you need to run bash script/ci/prebuild.sh to
- download the FFI libraries to
ffifolder - prebuilds the binaries and outputs to
prebuilds - cleans up
ffiandbuild
For end users, the following is provided as part of the packaging and release step in CI.
- the
prebuildsfolder containing builtffibindings - the
binding.gypfile is removed from the npm package, sonpm installdoesn't attempt to build theffibuildings, that are prebuilt.
If you have a binding.gyp file, and have created prebuilds you will want to perform npm ci or npm install with --ignore-scripts set, to avoid building the ffi which is prebuilt.
Alternatively you can run the following, which will not create a prebuild, but instead use node-gyp to output the built ffi libraries to the build folder. This was the previous method, which meant that end users would also perform.
bash script/download-libs.sh
npm ci
npm run build
npm run test
We create cross-platform and architecture binaries which are published individually to NPM, and consumed in this project.
./script/ci/build_opt_dependencies.sh libs v15.2.1Tag is optional and defaults to latest
This will run the following script, which will grab the latest prebuilt binaries from GitHub.
FETCH_ASSETS=true ./script/ci/check-release-libs.sh --fetch-assets -t v15.2.1./script/ci/build_opt_dependencies.sh buildSupported platforms are
- linux-x64-glibc
- linux-arm64-glibc
- linux-x64-musl
- linux-arm64-musl
- darwin-x64
- darwin-arm64
- windows-x64
You can detect your platform with
./script/ci/build-opt-dependencies.sh determine_platformYou can build with one
supported_platforms=$(./script/ci/build-opt-dependencies.sh determine_platform) ./script/ci/build-opt-dependencies.sh buildor all
./script/ci/build-opt-dependencies.sh buildMake link will try to link all available packages, for all available platforms, and will link any that apply
./script/ci/build-opt-dependencies.shYou can scope it with supported_platforms
supported_platforms=$(./script/ci/build-opt-dependencies.sh determine_platform) ./script/ci/build-opt-dependencies.sh linkDry run publishing optional packages, (default)
./script/ci/build-opt-dependencies.sh publishPublishing packages with --dry-run option removed.
PUBLISH=true ./script/ci/build-opt-dependencies.sh publishFor speed, CI runs use prebuilds from master for test runs. If you wish to force a rebuild of the ffi package because
- the ffi library has been updated
- the ffi binding code has been updated
Raise a pull request and add (rebuild), anywhere in the title'
#### Pre Reqs
- x86_64 Machine
- ARM64 Mac - If you have Rosetta (MacOS)
- Docker/Podman
- Act
act --container-architecture linux/amd64 -W .github/workflows/build-and-test.yml --artifact-server-path tmp- Finish the steps listed in the beginning to create prebuilds binaries specific to your platform
You can test this library with pact-js by doing the following steps:-
- run
npm run download-libsto download all prebuild binaries - run
npm link @pact-foundation/pact-core - from pact-js repository
- add an entry manually or by running npm install to point to the local pact-js-core repo