Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

chore: Add note about profiling-node move (#241) #816

chore: Add note about profiling-node move (#241)

chore: Add note about profiling-node move (#241) #816

Workflow file for this run

name: Precompile binaries
on:
push:
branches:
- main
- release/**
- "**/*"
workflow_dispatch:
inputs:
commit:
description: If the commit you want to test isn't the head of a branch, provide its SHA here
required: false
jobs:
precompile-bindings:
name: ${{ matrix.os }} (${{ matrix.target_platform }} node=${{ matrix.node || matrix.container }}, arch=${{ matrix.arch || matrix.container }}, compiler=${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
fail-fast: false
matrix:
include:
# We will prebuild binaries for node v18 on linux
# with different versions of glibc to ensure that
# the binaries are compatible with a wide range of
# distributions and container images.
# linux x64 glibc
- os: ubuntu-20.04
node: 16
- os: ubuntu-20.04
node: 18
- os: ubuntu-20.04
node: 20
# linux x64 musl
- os: ubuntu-20.04
container: node:16-alpine3.16
node: 16
- os: ubuntu-20.04
container: node:18-alpine3.17
node: 18
- os: ubuntu-20.04
container: node:20-alpine3.17
node: 20
# linux arm64 glibc
- os: ubuntu-20.04
arch: arm64
node: 16
- os: ubuntu-20.04
arch: arm64
node: 18
- os: ubuntu-20.04
arch: arm64
node: 20
# linux arm64 musl
- os: ubuntu-20.04
container: node:16-alpine3.16
arch: arm64
node: 16
- os: ubuntu-20.04
arch: arm64
container: node:18-alpine3.17
node: 18
- os: ubuntu-20.04
arch: arm64
container: node:20-alpine3.17
node: 20
# macos x64
- os: macos-11
node: 16
arch: x64
- os: macos-11
node: 18
arch: x64
- os: macos-11
node: 20
arch: x64
# macos cross compile for darwin
- os: macos-12
arch: arm64
node: 16
target_platform: darwin
- os: macos-12
arch: arm64
node: 18
target_platform: darwin
- os: macos-12
arch: arm64
node: 20
target_platform: darwin
# windows x64
- os: windows-2019
node: 16
arch: x64
- os: windows-2019
node: 18
arch: x64
- os: windows-2019
node: 20
arch: x64
# For some reason it seems like it takes forever for
# the macos-m1 runners to start up, so we'll just skip it
# - os: macos-m1
# node: 18
# arch: arm64
# Build artifacts are only needed for releasing workflow.
# if: startsWith(github.ref, 'refs/heads/release/')
# alpine build dependencies
steps:
- name: setup (alpine)
if: contains(matrix.container, 'alpine')
run: |
apk add --no-cache build-base python3 g++ make curl
- name: Check out current commit
uses: actions/checkout@v3
with:
ref: ${{ env.HEAD_COMMIT }}
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- uses: actions/setup-python@v4
name: Setup python
- name: Install dependencies
run: yarn install --ignore-scripts --frozen-lockfile
# configure build test copy x64
- name: Configure gyp
if: matrix.arch != 'arm64'
run: yarn build:configure
- name: Build bindings
if: matrix.arch != 'arm64'
run: yarn build:bindings
- name: Test
if: matrix.arch != 'arm64'
run: yarn test --silent
# configure build test copy arm64
- name: setup (arm64, ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})
if: matrix.arch == 'arm64' && !contains(matrix.container, 'alpine') && matrix.target_platform != 'darwin'
run: |
sudo apt-get update
sudo apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
# linux arm64
- name: "Configure gyp (arm64, ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})"
if: matrix.arch == 'arm64' && matrix.target_platform != 'darwin'
run: yarn build:configure:arm64
- name: Setup musl cross compiler
if: contains(matrix.container, 'alpine')
run: |
curl -OL https://musl.cc/aarch64-linux-musl-cross.tgz
tar -xzvf aarch64-linux-musl-cross.tgz
$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc --version
- name: "Build bindings (arm64, ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})"
if: matrix.arch == 'arm64' && contains(matrix.container, 'alpine') && matrix.target_platform != 'darwin'
run: |
CC=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc \
CXX=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-g++ \
BUILD_ARCH=arm64 yarn build:bindings
- name: "Build bindings (arm64, ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})"
if: matrix.arch == 'arm64' && !contains(matrix.container, 'alpine') && matrix.target_platform != 'darwin'
run: |
CC=aarch64-linux-gnu-gcc \
CXX=aarch64-linux-gnu-g++ \
BUILD_ARCH=arm64 yarn build:bindings:arm64
# linux arm64 target darwin
- name: "Configure gyp (arm64, darwin)"
if: matrix.arch == 'arm64' && matrix.target_platform == 'darwin'
run: yarn build:configure:arm64
- name: "Build bindings (arm64, darwin)"
if: matrix.arch == 'arm64' && matrix.target_platform == 'darwin'
run: |
BUILD_PLATFORM=darwin BUILD_ARCH=arm64 yarn build:bindings:arm64
# continue with common steps
- name: Log binary
run: du -sh lib/*
- name: Archive binary
uses: actions/upload-artifact@v3
with:
name: binaries-${{ github.sha }}
path: |
${{ github.workspace }}/lib/*.node
test-bundle:
runs-on: ubuntu-latest
needs: [precompile-bindings]
# if: startsWith(github.ref, 'refs/heads/release/')
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- run: yarn install --frozen-lockfile
- run: yarn build:lib
- uses: actions/download-artifact@v3
with:
name: binaries-${{ github.sha }}
path: lib/
- run: yarn test:bundle
build-and-pack:
runs-on: ubuntu-latest
needs: [precompile-bindings, test-bundle]
# Build artifacts are only needed for releasing workflow.
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- run: yarn install --frozen-lockfile
- run: yarn build:lib
- uses: actions/download-artifact@v3
with:
name: binaries-${{ github.sha }}
path: lib/
- run: yarn pack
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}
path: |
${{ github.workspace }}/*.tgz
test-app-build-run:
name: bundler tests
runs-on: ubuntu-20.04
needs: [precompile-bindings, test-bundle, build-and-pack]
# Build artifacts are only needed for releasing workflow.
strategy:
fail-fast: false
matrix:
# The matrix should really be ["webpack", "esbuild", "rollup"],
# however both rollup and webpack currently crash at runtime.
# The webpack generated bundle crashes at runtime with
# TypeError: profiling.ProfilingIntegration is not a constructor
# ^^ Seems like a generic import syntax erro, however when I log the bundle,
# it actually contains {LRUMap: [Function LRUMap]} which is incorrect.
# It seems like webpack either mangles the import, or pulls it from some
# unknown source? I currently dont have the bandwidth to debug why, but contributions
# are welcome.
# similarly to webpack, rollup build succeeds, but fails at runtime because
# rollup hoist and evaluate binary module imports. This means that all possible
# binaries are imported, which obviously causes a crash due to platform incompatibility.
# I have attempted the different options like strictRequires:true indicated by rollup's maintainer in
# https://twitter.com/lukastaegert/status/1680233261639892993?s=20, but I could not get it to
# build properly. Similarly to webpack, if someone wants to give this a spin, your contributions
# would be more than welcome.
# The general workflow for testing a bundler workflow
# is to build our library, download the generated binaries and
# use yarn link to link the what will be our final published library
# into the demo_app folder. From there, we run the different bundler
# build commands and attempt to run the demo app.
bundler: ["esbuild"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- run: yarn install --frozen-lockfile
- run: yarn build:lib
- uses: actions/download-artifact@v3
with:
name: binaries-${{ github.sha }}
path: lib/
- run: ls -l lib/
- run: yarn link
- run: yarn test:setup:bundle
- run: yarn test:${{matrix.bundler}}:build
- run: yarn test:${{matrix.bundler}}:run
- run: rm -rf ./node_modules/ && yarn install && node scripts/check-build.mjs