Skip to content

Commit

Permalink
feat: Prebuild pact_ffi pact.node + publish in npm pkg - (win-32|linu…
Browse files Browse the repository at this point in the history
…x|darwin)-x64 (linux|darwin)-arm64
  • Loading branch information
YOU54F committed May 27, 2023
1 parent d3baebf commit 2cd224d
Show file tree
Hide file tree
Showing 25 changed files with 731 additions and 340 deletions.
212 changes: 37 additions & 175 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,187 +1,49 @@
env:
PACT_BROKER_FEATURES: publish_pacts_using_old_api

BUILD_TEST_TASK_TEMPLATE: &BUILD_TEST_TASK_TEMPLATE
arch_check_script:
- uname -am
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
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
linux_arm64_task:
RELEASE: &RELEASE
release_script: ./script/ci/release.sh
env:
NVM_DIR: /usr/local/nvm
arm_container:
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"
GITHUB_TOKEN: ENCRYPTED[636f316600928de28b5c36027cc39d9796bc0d0eca2a181368f255ad61540f13bb38cdce09b6428774f315bbf45e0ada]
GH_PRE_RELEASE_UPLOAD: true

linux_amd64_task:
env:
NVM_DIR: /usr/local/nvm
container:
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"
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

macos_arm_prebuilder_task:
macos_instance:
image: ghcr.io/cirruslabs/macos-ventura-base:latest
linux_arm_task:
env:
PACT_BROKER_FEATURES: publish_pacts_using_old_api
NVM_DIR: ${HOME}/.nvm
PATH: ${NVM_DIR}:${PATH}
install_node_script:
- brew install nvm
- . $(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
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 libyaml-dev git
dry_run_check_script: npx --yes commit-and-tag-version --dry-run && git remote -v
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"
path: prebuilds/*.tar.gz

macos_x64_prebuilder_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}
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_node_x64_script: |
. "$NVS_HOME/nvs.sh"
nvs add 20/x64
nvs add 18/x64
nvs add 16/x64
nvs use 20/x64
file $(which node) | grep -e 'x64'
node --version
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
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"
path: prebuilds/*.tar.gz
115 changes: 70 additions & 45 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@ on:
workflow_dispatch:

jobs:
build:

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:
Expand All @@ -18,34 +29,36 @@ jobs:
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 }}
- 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
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:
name: prebuilds-${{ runner.os }}.tar.gz
path: prebuilds-${{ runner.os }}.tar.gz
path: prebuilds/*.tar.gz

- run: GH_PRE_RELEASE_UPLOAD=true ./script/ci/release.sh
if: github.ref == 'refs/heads/master' && env.ACT != 'true'
env:
GITHUB_TOKEN: ${{ github.token }}

test:
runs-on: ${{ matrix.os }}
needs: [build]
needs: [prebuild]
defaults:
run:
shell: bash
Expand All @@ -55,34 +68,46 @@ jobs:
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 all workflow run artifacts

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

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@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 }}
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: ${{ 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:
NODE_VERSION: ${{ matrix.node-version }}
PACT_BROKER_FEATURES: publish_pacts_using_old_api
- run: script/ci/build-and-test.sh
if: runner.os == 'Windows'
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 }}"
Loading

0 comments on commit 2cd224d

Please sign in to comment.