Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/actions/build-native/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build and test fontnik
description: Install system deps, build the native module, and run tests
inputs:
build_type:
description: CMake build type (Release or Debug)
required: false
default: Release
upload_artifact:
description: Upload prebuilds directory as a workflow artifact
required: false
default: 'false'
artifact_retention_days:
description: Artifact retention in days
required: false
default: '14'
platform:
description: Platform label for artifact naming (darwin, linux)
required: false
default: ''
arch:
description: Arch label for artifact naming (arm64, x64)
required: false
default: ''
runs:
using: composite
steps:
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
shell: bash
run: brew install cmake ninja freetype boost zlib

- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
shell: bash
run: sudo apt-get update && sudo apt-get install -y cmake ninja-build libfreetype6-dev zlib1g-dev libboost-dev clang

- name: Cache FetchContent downloads
uses: actions/cache@v6
with:
path: build/_deps
key: fetchcontent-${{ runner.os }}-${{ hashFiles('CMakeLists.txt') }}
restore-keys: |
fetchcontent-${{ runner.os }}-

- name: Install npm dependencies
shell: bash
run: npm ci --ignore-scripts

- name: Build and test
shell: bash
env:
CC: clang
CXX: clang++
run: |
BUILD_TYPE=${{ inputs.build_type }} npm run rebuild
npm test

- name: Upload prebuilds
if: inputs.upload_artifact == 'true'
uses: actions/upload-artifact@v7
with:
name: prebuilds-${{ inputs.platform }}-${{ inputs.arch }}
path: prebuilds
retention-days: ${{ inputs.artifact_retention_days }}
164 changes: 51 additions & 113 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,140 +7,78 @@ on:
branches: [master]

env:
NODE_VERSION: 20
CC: clang
CXX: clang++
MASON_LLVM_RELEASE: system
PYTHON_VERSION: 3.11
NODE_VERSION: 16

jobs:
test:
runs-on: ${{ matrix.os.host }}
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node: [16, 18]
build_type: ["debug", "release"]
build_type: [Release, Debug]
os:
- name: darwin
architecture: x86-64
host: macos-13

- name: linux
architecture: x86-64
host: ubuntu-22.04

name: ${{ matrix.os.name }}-${{ matrix.os.architecture }}-node${{ matrix.node }}-${{ matrix.build_type }} test
- macos-15
- ubuntu-22.04
- ubuntu-22.04-arm
include:
- os: macos-15
platform: darwin
arch: arm64
- os: ubuntu-22.04
platform: linux
arch: x64
- os: ubuntu-22.04-arm
platform: linux
arch: arm64

name: ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.build_type }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- uses: actions/checkout@v7

- uses: actions/setup-python@v4
if: matrix.os.name == 'darwin'
- uses: actions/setup-node@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Gyp
if: matrix.os.name == 'darwin'
run: npm install node-gyp@latest
node-version: ${{ env.NODE_VERSION }}

- name: Test
run: |
npm ci
npm install node-gyp@latest
./scripts/setup.sh --config local.env
source local.env
make ${{ matrix.build_type }}
npm test
- uses: ./.github/actions/build-native
with:
build_type: ${{ matrix.build_type }}
upload_artifact: ${{ matrix.build_type == 'Release' && 'true' || 'false' }}
artifact_retention_days: '14'
platform: ${{ matrix.platform }}
arch: ${{ matrix.arch }}

asan-build-test:
sanitize:
runs-on: ubuntu-22.04
name: ASAN toolset test
env:
BUILDTYPE: debug
TOOLSET: asan
name: ASAN+UBSan test
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}

- name: Test
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build libfreetype6-dev zlib1g-dev libboost-dev clang
- name: Test with ASan and UBSan
run: |
npm ci
./scripts/setup.sh --config local.env
source local.env
export CXXFLAGS="${MASON_SANITIZE_CXXFLAGS} -fno-sanitize-recover=all"
export LDFLAGS="${MASON_SANITIZE_LDFLAGS}"
make ${BUILDTYPE}
export LD_PRELOAD=${MASON_LLVM_RT_PRELOAD}
export ASAN_OPTIONS=fast_unwind_on_malloc=0:${ASAN_OPTIONS}
npm test
unset LD_PRELOAD
npm ci --ignore-scripts
make sanitize

g-build-test:
coverage:
runs-on: ubuntu-22.04
name: G++ build test
env:
BUILDTYPE: debug
CXX: g++-9
CC: gcc-9
CXXFLAGS: -fext-numeric-literals
name: Coverage
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}

- name: Test
- name: Install dependencies
run: |
npm ci
./scripts/setup.sh --config local.env
source local.env
make ${BUILDTYPE}
npm test

build:
needs: [test, asan-build-test, g-build-test]
runs-on: ${{ matrix.os.host }}
strategy:
matrix:
os:
- name: darwin
architecture: x86-64
host: macos-13

- name: linux
architecture: x86-64
host: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- uses: actions/setup-python@v4
if: matrix.os.name == 'darwin'
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Gyp
if: matrix.os.name == 'darwin'
run: npm install node-gyp@latest

- name: Build
sudo apt-get update
sudo apt-get install -y cmake ninja-build libfreetype6-dev zlib1g-dev libboost-dev clang llvm
- name: Coverage report
run: |
npm ci
./scripts/setup.sh --config local.env
source local.env
make release

- name: Prebuildify ${{ matrix.os.name }}-${{ matrix.os.architecture }}
run: npm run prebuildify -- --platform=${{ matrix.os.name }} --arch=x64

# Upload the end-user binary artifact
- uses: actions/upload-artifact@v4
with:
name: prebuilds-${{ matrix.os.name }}-${{ matrix.os.architecture }}
path: prebuilds
retention-days: 14
npm ci --ignore-scripts
make coverage
Loading
Loading