Skip to content

Commit fad5b2d

Browse files
committed
feat(prebuild): support of Alpine binaries
- update dependencies - rework binding.gyp - rework msys bundle for Windows - add bundle for MUSL (Alpine) - rework bundle scripts and ci moved to prebuild
1 parent 25fbac5 commit fad5b2d

26 files changed

+277
-839
lines changed

.github/workflows/ci.yaml

+96-48
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,139 @@
11
name: Test
2-
on:
3-
push:
4-
paths-ignore:
5-
- ".github/workflows/prebuild.yaml"
6-
pull_request:
7-
paths-ignore:
8-
- ".github/workflows/prebuild.yaml"
2+
3+
on: [ push ]
94

105
jobs:
11-
Linux:
12-
name: Test on Linux
6+
Debian:
137
runs-on: ubuntu-latest
148
strategy:
159
matrix:
16-
node: [18.12.0, 20.9.0]
10+
node: [ 18, 20 ]
11+
container:
12+
image: node:${{ matrix.node }}-slim
1713
steps:
18-
- uses: actions/setup-node@v4
19-
with:
20-
node-version: ${{ matrix.node }}
21-
- uses: actions/checkout@v4
14+
- name: Checkout
15+
uses: actions/checkout@v4
2216
- name: Install Dependencies
2317
run: |
24-
sudo apt update
25-
sudo apt install -y libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev librsvg2-dev
26-
- name: Install
18+
apt update
19+
apt install -y build-essential libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev librsvg2-dev libpixman-1-dev
20+
- name: Build
2721
run: npm install --build-from-source
2822
- name: Test
2923
run: npm test
3024

31-
Windows:
32-
name: Test on Windows
33-
runs-on: windows-2019
25+
Alpine:
26+
runs-on: ubuntu-latest
3427
strategy:
3528
matrix:
36-
# FIXME: Node.js 20.9.0 is currently broken on Windows, in the `registerFont` test:
37-
# ENOENT: no such file or directory, lstat 'D:\a\node-canvas\node-canvas\examples\pfennigFont\pfennigMultiByte🚀.ttf'
38-
# ref: https://github.com./nodejs/node/issues/48673
39-
# ref: https://github.com./nodejs/node/pull/50650
40-
node: [18.12.0]
29+
node: [ 18, 20 ]
30+
container:
31+
image: node:${{ matrix.node }}-alpine
4132
steps:
42-
- uses: actions/setup-node@v4
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
- name: Install Dependencies
36+
run: apk --no-cache add build-base cairo-dev jpeg-dev pango-dev giflib-dev librsvg-dev pixman-dev
37+
- name: Build
38+
run: npm install --build-from-source
39+
- name: Test
40+
# some tests failed
41+
continue-on-error: true
42+
run: npm test
43+
44+
macOS:
45+
strategy:
46+
matrix:
47+
node: [ 18, 20 ]
48+
os:
49+
- runner: macos-latest
50+
arch: x64
51+
# - runner: macos-latest-xlarge
52+
# arch: arm64
53+
runs-on: ${{ matrix.os.runner }}
54+
steps:
55+
- name: Install Node.JS
56+
uses: actions/setup-node@v4
4357
with:
4458
node-version: ${{ matrix.node }}
45-
- uses: actions/checkout@v4
59+
- name: Checkout
60+
uses: actions/checkout@v4
4661
- name: Install Dependencies
47-
run: |
48-
Invoke-WebRequest "https://ftp-osl.osuosl.org/pub/gnome/binaries/win64/gtk+/2.22/gtk+-bundle_2.22.1-20101229_win64.zip" -OutFile "gtk.zip"
49-
Expand-Archive gtk.zip -DestinationPath "C:\GTK"
50-
Invoke-WebRequest "https://downloads.sourceforge.net/project/libjpeg-turbo/2.0.4/libjpeg-turbo-2.0.4-vc64.exe" -OutFile "libjpeg.exe" -UserAgent NativeHost
51-
.\libjpeg.exe /S
52-
npm install -g node-gyp@8
53-
npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"}
54-
- name: Install
62+
run: brew install pkg-config cairo pango libpng giflib librsvg pixman
63+
- name: Build
5564
run: npm install --build-from-source
5665
- name: Test
5766
run: npm test
5867

59-
macOS:
60-
name: Test on macOS
61-
runs-on: macos-latest
68+
Windows:
69+
runs-on: windows-latest
6270
strategy:
6371
matrix:
64-
node: [18.12.0, 20.9.0]
72+
node: [ 18, 20 ]
6573
steps:
6674
- uses: actions/setup-node@v4
6775
with:
6876
node-version: ${{ matrix.node }}
6977
- uses: actions/checkout@v4
78+
- uses: msys2/setup-msys2@v2
79+
with:
80+
msystem: UCRT64
81+
path-type: inherit
7082
- name: Install Dependencies
83+
shell: msys2 {0}
7184
run: |
72-
brew update
73-
brew install python3 || : # python doesn't need to be linked
74-
brew install pkg-config cairo pango libpng jpeg giflib librsvg
75-
pip install setuptools
76-
- name: Install
85+
prefix=${MSYSTEM,,}
86+
arch=${MSYSTEM_CARCH}
87+
88+
pacman --noconfirm --needed -S \
89+
${prefix}/mingw-w64-ucrt-${arch}-binutils \
90+
${prefix}/mingw-w64-ucrt-${arch}-tools \
91+
${prefix}/mingw-w64-ucrt-${arch}-libjpeg-turbo \
92+
${prefix}/mingw-w64-ucrt-${arch}-pango \
93+
${prefix}/mingw-w64-ucrt-${arch}-cairo \
94+
${prefix}/mingw-w64-ucrt-${arch}-giflib \
95+
${prefix}/mingw-w64-ucrt-${arch}-harfbuzz \
96+
${prefix}/mingw-w64-ucrt-${arch}-freetype \
97+
${prefix}/mingw-w64-ucrt-${arch}-fontconfig \
98+
${prefix}/mingw-w64-ucrt-${arch}-librsvg \
99+
${prefix}/mingw-w64-ucrt-${arch}-libxml2
100+
101+
libs="cairo-2 png16-16 jpeg-8 pango-1.0-0 pangocairo-1.0-0 gobject-2.0-0 glib-2.0-0 turbojpeg gif-7 freetype-6 rsvg-2-2"
102+
for lib in $libs; do
103+
gendef /${prefix}/bin/lib$lib.dll > /dev/null 2>&1 || {
104+
echo "could not find lib$lib.dll, have to skip ";
105+
continue;
106+
}
107+
dlltool -d lib$lib.def -l /${prefix}/lib/lib$lib.lib > /dev/null 2>&1 || {
108+
echo "could not create dll for lib$lib.dll";
109+
continue;
110+
}
111+
echo "created lib$lib.lib from lib$lib.dll";
112+
rm lib$lib.def
113+
done
114+
- name: Build
115+
shell: msys2 {0}
77116
run: npm install --build-from-source
78117
- name: Test
118+
shell: msys2 {0}
119+
# FIXME: Node.js 20.x is currently broken on Windows, in the `registerFont` test:
120+
# ENOENT: no such file or directory, lstat 'node-canvas\examples\pfennigFont\pfennigMultiByte🚀.ttf'
121+
# ref: https://github.com./nodejs/node/issues/48673
122+
# ref: https://github.com./nodejs/node/pull/50650
123+
continue-on-error: true
79124
run: npm test
80125

81126
Lint:
82127
name: Lint
83128
runs-on: ubuntu-latest
129+
strategy:
130+
matrix:
131+
node: [ 20 ]
132+
container:
133+
image: node:${{ matrix.node }}-slim
84134
steps:
85-
- uses: actions/setup-node@v4
86-
with:
87-
node-version: 20.9.0
88-
- uses: actions/checkout@v4
135+
- name: Checkout
136+
uses: actions/checkout@v4
89137
- name: Install
90138
run: npm install --ignore-scripts
91139
- name: Lint

0 commit comments

Comments
 (0)