Skip to content

Commit

Permalink
feat: Prebuildify pact.node for multi-arch
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed May 12, 2023
1 parent ea9f86f commit d3baebf
Show file tree
Hide file tree
Showing 9 changed files with 267 additions and 88 deletions.
182 changes: 148 additions & 34 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,70 +4,184 @@ env:
BUILD_TEST_TASK_TEMPLATE: &BUILD_TEST_TASK_TEMPLATE
arch_check_script:
- uname -am
test_script:
prebuild_script:
- node --version
- chmod +x script/**/* && chmod +x script/**
- script/download-libs.sh
- npm ci --ignore-scripts
- npx prebuildify --napi
- tar -czf prebuilds.tar.gz prebuilds
- ls
- rm -rf ffi build
test_20_script:
- ls
- node --version
- script/ci/build-and-test.sh
- ls
- npm run clean
- rm -rf node_modules
- ls
test_18_script:
- . $NVM_DIR/nvm.sh
- nvm install 18
- nvm use 18
- node --version
- script/ci/build-and-test.sh
- ls
- npm run clean
- rm -rf node_modules
- ls
test_16_script:
- . $NVM_DIR/nvm.sh
- nvm install 18
- nvm use 18
- node --version
- script/ci/build-and-test.sh
- ls
- npm run clean
- rm -rf node_modules
- ls

linux_arm64_task:
env:
matrix:
- IMAGE: node:16-slim
- IMAGE: node:18-slim
- IMAGE: node:20-slim
NVM_DIR: /usr/local/nvm
arm_container:
image: $IMAGE
image: node:20-slim
install_script:
- apt update --yes && apt install --yes curl python3 make build-essential g++ unzip zip
- curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh | bash
<< : *BUILD_TEST_TASK_TEMPLATE
artifacts:
path: "prebuilds.tar.gz"

linux_amd64_task:
env:
matrix:
- IMAGE: node:16-slim
- IMAGE: node:18-slim
- IMAGE: node:20-slim
NVM_DIR: /usr/local/nvm
container:
image: $IMAGE
image: node:20-slim
install_script:
- apt update --yes && apt install --yes curl python3 make build-essential g++ unzip zip
- apt update --yes && apt install --yes curl python3 make build-essential g++ unzip zip
- curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh | bash
<< : *BUILD_TEST_TASK_TEMPLATE
artifacts:
path: "prebuilds.tar.gz"

mac_arm64_task:
macos_arm_prebuilder_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:
NVM_DIR: ${HOME}/.nvm
PATH: ${NVM_DIR}:${PATH}
install_node_script:
- brew install nvm
- source $(brew --prefix nvm)/nvm.sh
- nvm install $NODE_VERSION
- nvm use $NODE_VERSION
<< : *BUILD_TEST_TASK_TEMPLATE
- . $(brew --prefix nvm)/nvm.sh
- nvm install 20
- nvm install 18
- nvm install 16
prebuild_script:
- . $(brew --prefix nvm)/nvm.sh
- nvm use 20
- node --version
- chmod +x script/**/* && chmod +x script/**
- script/download-libs.sh
- npm ci --ignore-scripts
- npx prebuildify --napi
- tar -czf prebuilds.tar.gz prebuilds
- ls
- rm -rf ffi build
test_20_script:
- . $(brew --prefix nvm)/nvm.sh
- nvm use 20
- node --version
- script/ci/build-and-test.sh
- ls
- npm run clean
- rm -rf node_modules
- ls
test_18_script:
- . $(brew --prefix nvm)/nvm.sh
- nvm use 18
- node --version
- script/ci/build-and-test.sh
- ls
- npm run clean
- rm -rf node_modules
- ls
test_16_script:
- . $(brew --prefix nvm)/nvm.sh
- nvm use 16
- node --version
- script/ci/build-and-test.sh
- ls
- npm run clean
- rm -rf node_modules
- ls
artifacts:
path: "prebuilds.tar.gz"

mac_rosetta_task:
macos_x64_prebuilder_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 nvs_script: |
install_nvs_script: |
git clone https://github.com/jasongin/nvs "$NVS_HOME"
. "$NVS_HOME/nvs.sh" install
install_rosetta_script: softwareupdate --install-rosetta --agree-to-license
install_x64_script: |
install_node_x64_script: |
. "$NVS_HOME/nvs.sh"
nvs add $NODE_VERSION/x64
nvs use $NODE_VERSION/x64
nvs add 20/x64
nvs add 18/x64
nvs add 16/x64
nvs use 20/x64
file $(which node) | grep -e 'x64'
node --version
<< : *BUILD_TEST_TASK_TEMPLATE
prebuild_script:
- ls
- . "$NVS_HOME/nvs.sh"
- nvs use 20/x64
- file $(which node) | grep -e 'x64'
- node --version
- chmod +x script/**/* && chmod +x script/**
- script/download-libs.sh
- npm ci --ignore-scripts
- npx prebuildify --napi
- tar -czf prebuilds.tar.gz prebuilds
- ls
- rm -rf ffi build
test_20_script:
- . "$NVS_HOME/nvs.sh"
- nvs use 20/x64
- file $(which node) | grep -e 'x64'
- node --version
- ls
- script/ci/build-and-test.sh
- ls
- npm run clean
- rm -rf node_modules
- ls
test_18_script:
- . "$NVS_HOME/nvs.sh"
- nvs use 18/x64
- file $(which node) | grep -e 'x64'
- node --version
- script/ci/build-and-test.sh
- ls
- npm run clean
- rm -rf node_modules
- ls
test_16_script:
- . "$NVS_HOME/nvs.sh"
- nvs use 16/x64
- file $(which node) | grep -e 'x64'
- node --version
- script/ci/build-and-test.sh
- ls
- npm run clean
- rm -rf node_modules
- ls
artifacts:
path: "prebuilds.tar.gz"
53 changes: 52 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,45 @@ on:
workflow_dispatch:

jobs:
build-and-test-osx:
build:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
node-version: [20]
os: [macos-latest,ubuntu-latest,windows-latest]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: download-libs
if: runner.os != 'Windows'
run: script/download-libs.sh
- name: download-libs
if: runner.os == 'Windows'
run: script/download-libs.sh
env:
ONLY_DOWNLOAD_PACT_FOR_WINDOWS: true
- name: generate prebuild
run: |
npm ci --ignore-scripts
npx prebuildify --napi
tar -czf prebuilds-${{ runner.os }}.tar.gz prebuilds
ls
- name: Upload standalone packages
uses: actions/upload-artifact@v3
with:
name: prebuilds-${{ runner.os }}.tar.gz
path: prebuilds-${{ runner.os }}.tar.gz
test:
runs-on: ${{ matrix.os }}
needs: [build]
defaults:
run:
shell: bash
Expand All @@ -20,10 +57,24 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Download all workflow run artifacts
uses: actions/download-artifact@v3
with:
name: prebuilds-${{ runner.os }}.tar.gz
- name: process packaged artifact
run: tar xvf prebuilds-${{ runner.os }}.tar.gz
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: download-libs
if: runner.os != 'Windows'
run: script/download-libs.sh
- name: download-libs
if: runner.os == 'Windows'
run: script/download-libs.sh
env:
ONLY_DOWNLOAD_PACT_FOR_WINDOWS: true
- run: script/ci/build-and-test.sh
if: runner.os != 'Windows'
env:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ standalone/*
!standalone/*.ts
standalone/*.d.ts
ffi/*
!src/ffi
!ffi/README.md
prebuilds

# Folders created during testing
log
Expand Down
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,7 @@ test

# release scripts
script

# FFI binaries
ffi
!prebuilds
Loading

0 comments on commit d3baebf

Please sign in to comment.