Build - Linux #131
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build - Linux | |
on: | |
workflow_dispatch: | |
# push: | |
# tags: | |
# - v* | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
jobs: | |
build-linux: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
node-version: [16] | |
arch: [amd64, arm64, arm] | |
platform: [debian, alpine] | |
include: | |
# Set baselines per platform | |
- triple: "alpine-linux-musl" | |
platform: alpine | |
version: 3.16 | |
libc: musl | |
gcc_install: clang lld | |
gcc: clang | |
gxx: clang++ | |
# libc is intentionally not set here, as prebuild-install requires libc to not be set for glibc builds | |
- triple: "linux-gnu" | |
platform: debian | |
version: bullseye | |
# Set baselines per architecture | |
- triple_arch: x86_64 | |
node_arch: x64 | |
arch: amd64 | |
- triple_arch: armv7 | |
node_arch: arm | |
triple_postfix: eabihf | |
arch: arm | |
flags: -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard -fPIC | |
- triple_arch: aarch64 | |
node_arch: arm64 | |
arch: arm64 | |
flags: -march=armv8-a -fPIC | |
# Set edge case overrides for specific platform + architecture | |
# also define gcc commands for each architecture | |
- arch: amd64 | |
platform: debian | |
gcc_install: gcc g++ | |
gcc: gcc | |
gxx: g++ | |
- arch: arm64 | |
platform: debian | |
gcc_install: gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
gcc: aarch64-linux-gnu-gcc | |
gxx: aarch64-linux-gnu-g++ | |
# debian uses the triple `arm-linux-gnueabihf` instead of alpine's `armv7-alpine-linux-musleabihf` | |
# because of this, we explicitly override triple_arch for debian arm | |
- triple_arch: arm | |
arch: arm | |
platform: debian | |
gcc_install: gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf | |
gcc: arm-linux-gnueabihf-gcc | |
gxx: arm-linux-gnueabihf-g++ | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install node dependencies | |
run: npm install --ignore-scripts | |
env: | |
CI: true | |
- if: matrix.arch != 'amd64' | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: ${{ matrix.arch }} | |
- name: Install system dependencies | |
run: | | |
sudo apt update | |
sudo apt install -y podman ninja-build ${{ matrix.gcc_install }} | |
- name: List installed libc | |
run: apt list --installed | grep libc6-dev | |
- name: Build sysroot | |
run: sudo podman build --isolation=chroot -t ndc-buildroot:${{ matrix.platform }}-${{ matrix.arch }} ./build-containers --file Dockerfile.${{ matrix.platform }} --platform linux/${{ matrix.arch }} --build-arg="version=${{ matrix.version }}" --build-arg="node_version=${{ matrix.node-version }}" | |
- name: Mount sysroot | |
id: sysroot | |
run: echo "sysroot=$(sudo podman image mount ndc-buildroot:${{ matrix.platform }}-${{ matrix.arch }})" >> $GITHUB_OUTPUT | |
- name: Build | |
run: sudo --preserve-env=SYSROOT,TRIPLE,COMPILER_FLAGS,LIBC,GCC,GXX,CI,PATH node_modules/.bin/prebuild --arch ${{ matrix.node_arch }} -r napi --backend cmake-js -- --CDCMAKE_TOOLCHAIN_FILE:FILEPATH=./cmake/toolchain/ci.cmake | |
env: | |
SYSROOT: ${{ steps.sysroot.outputs.sysroot }} | |
TRIPLE: ${{ matrix.triple_arch }}-${{ matrix.triple }}${{ matrix.triple_postfix }} | |
COMPILER_FLAGS: ${{ matrix.flags }} | |
LIBC: ${{ matrix.libc }} | |
GCC: ${{ matrix.gcc }} | |
GXX: ${{ matrix.gxx }} | |
CI: true | |
- name: Test | |
run: sudo podman run --rm -v $(pwd):/usr/app/ -e CI=true --platform linux/${{ matrix.arch }} -t ndc-buildroot:${{ matrix.platform }}-${{ matrix.arch }} npm run test | |
- name: Upload | |
run: sudo --preserve-env=CI,LIBC node_modules/.bin/prebuild --arch ${{ matrix.node_arch }} -r napi --upload -u ${{ secrets.GITHUB_TOKEN }} | |
env: | |
LIBC: ${{ matrix.libc }} | |
CI: true |