Skip to content
Merged
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
32 changes: 27 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ on:

jobs:
build-test:
name: Build & Test (${{ matrix.os }})
name: Build & Test (${{ matrix.os }}${{ matrix.cross && ' xarch' || '' }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-14, windows-2022]
cross: [false, true]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -22,19 +23,38 @@ jobs:
with:
node-version: '22.x'

- name: Set architecture
id: arch
shell: bash
run: |
if [ "${{ runner.os }}" = "macOS" ]; then
echo "arch=${{ matrix.cross && 'x64' || 'arm64' }}" >> $GITHUB_OUTPUT
else
echo "arch=${{ matrix.cross && 'arm64' || 'x64' }}" >> $GITHUB_OUTPUT
fi

- name: Install sysroot
if: runner.os == 'Linux'
run: |
sudo apt-get update -qq
sudo apt-get install -y gcc-10 g++-10
SYSROOT_PATH=$(node scripts/linux/install-sysroot.js x64 | grep "SYSROOT_PATH=" | cut -d= -f2)
if [ "${{ steps.arch.outputs.arch }}" = "arm64" ]; then
sudo apt-get install -y gcc-10-aarch64-linux-gnu g++-10-aarch64-linux-gnu
echo "CC=aarch64-linux-gnu-gcc-10" >> $GITHUB_ENV
echo "CXX=aarch64-linux-gnu-g++-10" >> $GITHUB_ENV
else
sudo apt-get install -y gcc-10 g++-10
echo "CC=gcc-10" >> $GITHUB_ENV
echo "CXX=g++-10" >> $GITHUB_ENV
fi
SYSROOT_PATH=$(node scripts/linux/install-sysroot.js ${{ steps.arch.outputs.arch }} | grep "SYSROOT_PATH=" | cut -d= -f2)
echo "SYSROOT_PATH=$SYSROOT_PATH" >> $GITHUB_ENV
echo "Sysroot path set to: $SYSROOT_PATH"
echo "CC=gcc-10" >> $GITHUB_ENV
echo "CXX=g++-10" >> $GITHUB_ENV

- name: Install dependencies and build
run: npm ci
env:
ARCH: ${{ steps.arch.outputs.arch }}
npm_config_arch: ${{ steps.arch.outputs.arch }}

- name: Verify GLIBC requirements
if: runner.os == 'Linux'
Expand All @@ -45,7 +65,9 @@ jobs:
./scripts/linux/verify-glibc-requirements.sh

- name: Test
if: ${{ !matrix.cross }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could testing and linting be re-enabled in this case, or would it be redundant?
Everything else LGTM.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linting would be redundant (already is redundant to lint on each OS)

testing wouldn't work since it's cross-compiling. I think in order to test it would either need to be done in a container or with emulation. Or if there were linux-arm, windows-arm, and macos-x64 runners available that would be easiest

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub Actions has Linux ARM and macOS x64 runners (but not Windows ARM):

https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#standard-github-hosted-runners-for-public-repositories

  • macos-15-intel
  • ubuntu-22.04-arm and ubuntu-24.04-arm

run: npm test

- name: Lint
if: ${{ !matrix.cross }}
run: npm run lint
12 changes: 9 additions & 3 deletions pipelines/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ steps:
- bash: |
if [ "$(uname)" = "Linux" ]; then
sudo apt-get update -qq
sudo apt-get install -y gcc-10 g++-10
if [ "${{ parameters.arch }}" = "arm64" ]; then
sudo apt-get install -y gcc-10-aarch64-linux-gnu g++-10-aarch64-linux-gnu
echo "##vso[task.setvariable variable=CC]aarch64-linux-gnu-gcc-10"
echo "##vso[task.setvariable variable=CXX]aarch64-linux-gnu-g++-10"
else
sudo apt-get install -y gcc-10 g++-10
echo "##vso[task.setvariable variable=CC]gcc-10"
echo "##vso[task.setvariable variable=CXX]g++-10"
fi
SYSROOT_PATH=$(node scripts/linux/install-sysroot.js ${{ parameters.arch }} | grep "SYSROOT_PATH=" | cut -d= -f2)
echo "##vso[task.setvariable variable=SYSROOT_PATH]$SYSROOT_PATH"
echo "##vso[task.setvariable variable=CC]gcc-10"
echo "##vso[task.setvariable variable=CXX]g++-10"
echo "Sysroot path set to: $SYSROOT_PATH"
elif [ "$(uname)" = "Darwin" ]; then
echo "##vso[task.setvariable variable=CC]clang"
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function loadNativeModule(name: string): {dir: string, module: any} {
let lastError: unknown;
for (const d of dirs) {
for (const r of relative) {
const dir = `${r}/${d}/`;
const dir = `${r}/${d}`;
try {
return { dir, module: require(`${dir}/${name}.node`) };
} catch (e) {
Expand Down