Skip to content

Commit

Permalink
Merge pull request #446 from YOU54F/prebuildify
Browse files Browse the repository at this point in the history
Feat: Prebuildify pact.node for all FFI supported platform/architectures
  • Loading branch information
mefellows committed Jul 6, 2023
2 parents cc8a67a + e83f04b commit 4bbfc28
Show file tree
Hide file tree
Showing 29 changed files with 854 additions and 262 deletions.
90 changes: 40 additions & 50 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,48 @@
env:
PACT_BROKER_FEATURES: publish_pacts_using_old_api

BUILD_TEST_TASK_TEMPLATE: &BUILD_TEST_TASK_TEMPLATE
arch_check_script:
- uname -am
test_script:
- node --version
- script/ci/build-and-test.sh
INSTALL_GH_CLI: &INSTALL_GH_CLI
install_gh_cli_script: |
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& apt update \
&& apt install gh -y
# These are probably expected to fail in the post install script
# until we are packing v2.0.0 of pact-ruby-standalone that supports
# arm64 linux - as per https://github.com/pact-foundation/pact-js-core/issues/416
# Error: Error while locating pact binary: Cannot find binary for platform 'linux' with architecture 'arm64'.
# linux_arm64_task:
# skip: "changesInclude('.github/**')"
# env:
# matrix:
# - IMAGE: node:16-slim
# - IMAGE: node:18-slim
# - IMAGE: node:20-slim
# arm_container:
# image: $IMAGE
# install_script:
# - apt update --yes && apt install --yes curl python3 make build-essential g++ unzip zip
# << : *BUILD_TEST_TASK_TEMPLATE

linux_amd64_task:
RELEASE: &RELEASE
release_script: ./script/ci/release.sh
env:
matrix:
- IMAGE: node:16-slim
- IMAGE: node:18-slim
- IMAGE: node:20-slim
container:
image: $IMAGE
install_script:
- apt update --yes && apt install --yes curl python3 make build-essential g++ unzip zip
<< : *BUILD_TEST_TASK_TEMPLATE
GITHUB_TOKEN: ENCRYPTED[80f01174768fa2065635588baac761b8d7079ea3e06f4af861d3c5c6ada0a8fe93a19e45d33a64fccc24f94f6398593d]
GH_PRE_RELEASE_UPLOAD: true

PREBUILD_AND_TEST: &PREBUILD_AND_TEST
prebuild_script: NODE_VERSION=20 script/ci/prebuild.sh
<<: *RELEASE
test_20_script: NODE_VERSION=20 script/ci/build-and-test.sh && script/ci/clean.sh
test_18_script: NODE_VERSION=18 script/ci/build-and-test.sh && script/ci/clean.sh
test_16_script: NODE_VERSION=16 script/ci/build-and-test.sh && script/ci/clean.sh

linux_arm_task:
env:
SET_NVM: "true"
arm_container:
# container:
image: node:20-slim
cirrus_setup_script: chmod +x script/**/* && chmod +x script/**
setup_script: apt update --yes && apt install --yes curl python3 make build-essential g++ unzip zip git
pre_req_script: curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.39.3/install.sh | bash
<<: *INSTALL_GH_CLI
<<: *PREBUILD_AND_TEST
artifacts:
path: prebuilds/*.tar.gz

mac_task:
macos_arm_task:
macos_instance:
image: ghcr.io/cirruslabs/macos-ventura-base:latest
env:
PACT_BROKER_FEATURES: publish_pacts_using_old_api
NVS_HOME: ${HOME}/.nvs
PATH: ${NVS_HOME}:${PATH}
matrix:
- NODE_VERSION: 16
- NODE_VERSION: 18
- NODE_VERSION: 20
install_script: # we need to install rosetta as v1.x of pact-ruby-standalone doesn't support arm64
- softwareupdate --install-rosetta --agree-to-license
- brew install nvm
- source $(brew --prefix nvm)/nvm.sh
- nvm install $NODE_VERSION
- nvm use $NODE_VERSION
<< : *BUILD_TEST_TASK_TEMPLATE
SET_NVM: "true"
cirrus_setup_script: chmod +x script/**/* && chmod +x script/**
dry_run_check_script: |
npx --yes commit-and-tag-version --dry-run && git remote -v
pre_req_script: brew install nvm
<<: *PREBUILD_AND_TEST
artifacts:
path: prebuilds/*.tar.gz
102 changes: 89 additions & 13 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,107 @@ on:
workflow_dispatch:

jobs:
build-and-test-osx:

create_pre_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: GH_CREATE_PRE_RELEASE=true ./script/ci/release.sh
if: github.ref == 'refs/heads/master' && env.ACT != 'true' && runner.os == 'Linux'
env:
GITHUB_TOKEN: ${{ github.token }}

prebuild:
needs: [ create_pre_release ]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
node-version: [16,18,20]
node-version: [20]
os: [macos-latest,ubuntu-latest,windows-latest]

env:
NODE_VERSION: ${{ matrix.node-version }}

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}


- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: script/ci/build-and-test.sh
if: runner.os != 'Windows'
node-version: ${{ env.NODE_VERSION }}

- if: runner.os == 'Windows'
run: echo "ONLY_DOWNLOAD_PACT_FOR_WINDOWS=true" >> $GITHUB_ENV

- run: ./script/ci/prebuild.sh

- name: Upload prebuild for ${{ runner.os }}-${{ runner.arch }}
uses: actions/upload-artifact@v3
with:
path: prebuilds/*.tar.gz

- run: GH_PRE_RELEASE_UPLOAD=true ./script/ci/release.sh
if: github.ref == 'refs/heads/master' && env.ACT != 'true'
env:
NODE_VERSION: ${{ matrix.node-version }}
PACT_BROKER_FEATURES: publish_pacts_using_old_api
- run: script/ci/build-and-test.sh
if: runner.os == 'Windows'
GITHUB_TOKEN: ${{ github.token }}

test:
runs-on: ${{ matrix.os }}
needs: [prebuild]
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
node-version: [16,18,20]
os: [macos-latest,ubuntu-latest,windows-latest]

env:
NODE_VERSION: ${{ matrix.node-version }}

steps:
- uses: actions/checkout@v3

- name: Download prebuilds
uses: actions/download-artifact@v3

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- if: runner.os == 'Windows'
run: echo "ONLY_DOWNLOAD_PACT_FOR_WINDOWS=true" >> $GITHUB_ENV
- run: ./script/ci/unpack-and-test.sh

release_dry_run:
runs-on: ubuntu-latest
needs: [ create_pre_release, prebuild ]
if: github.ref == 'refs/heads/master'

env:
NODE_VERSION: 20

steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'

- name: "release - dry run: ${{ env.DRY_RUN }}"
id: publish
run: script/ci/release.sh
env:
NODE_VERSION: ${{ matrix.node-version }}
PACT_BROKER_FEATURES: publish_pacts_using_old_api
ONLY_DOWNLOAD_PACT_FOR_WINDOWS: true
GITHUB_TOKEN: ${{ github.token }}
DRY_RUN: true

- run: echo "New Release will be v${{ steps.publish.outputs.version }}"
30 changes: 13 additions & 17 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,22 @@ on:
jobs:
release:
runs-on: ubuntu-latest

env:
NODE_VERSION: 20

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v1
- uses: actions/checkout@v3

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: 16
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'
- id: publish
run: script/ci/release.sh
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTOMATION_TOKEN}}
- name: Create Release
id: create_release
uses: actions/create-release@v1
- name: "release"
id: publish
run: script/ci/release.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: v${{ steps.publish.outputs.version }}
release_name: Release v${{ steps.publish.outputs.version }}
body: ${{steps.publish.outputs.notes}}
draft: false
prerelease: false
GITHUB_TOKEN: ${{ github.token }}
44 changes: 25 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ coverage
# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build


# Redis database dump
dump.rdb
Expand All @@ -44,35 +43,42 @@ src/**/**.d.ts
test/**/**.d.ts
bin/**/**.d.ts
**/*.d.ts
*.js
!test.js
src/**/**.js
test/**/**.js
bin/**/**.js
# *.js
# !test.js

*.js.map

# ts-node cache
ts-node-*

# pact standalone binaries
standalone/*
!standalone/__fixtures__/.keep
!standalone/*.ts
# standalone/*
standalone/darwin*
standalone/linux*
standalone/windows*
standalone/*.d.ts
ffi/*
!ffi/README.md
standalone/*.js
standalone/*.checksum
standalone/*.gz
standalone/README.md
# FFI native bindings
*.so
*.dll*
*.dylib
pact.h
pact-cpp.h
ffi/README.md
# Compiled binary addons (http://nodejs.org/api/addons.html)
build
# Precompiled binary addons
prebuilds

# Folders created during testing
log
reports
tmp
.tmp
test/__testoutput__

# jest config
!jest.config.js

# mocha config
!.mocharc.js
!ts-node.js

# jest mocks
!__mocks__
12 changes: 12 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,15 @@ test

# release scripts
script

## these arent needed in the final bundle
binding.gyp
native

.cirrus
.gitattributes
DEVELOPER.md
RELEASING.md
test.js
tsconfig.build.json
tsconfig.json
Loading

0 comments on commit 4bbfc28

Please sign in to comment.