Skip to content

Commit f22a806

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 f934f22 commit f22a806

26 files changed

+272
-835
lines changed

.github/workflows/ci.yaml

Lines changed: 91 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,138 @@
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, 22 ]
11+
# container:
12+
# image: node:${{ matrix.node }}-slim
1713
steps:
1814
- uses: actions/setup-node@v4
1915
with:
2016
node-version: ${{ matrix.node }}
21-
- uses: actions/checkout@v4
17+
- name: Checkout
18+
uses: actions/checkout@v4
2219
- name: Install Dependencies
2320
run: |
2421
sudo apt update
25-
sudo apt install -y libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev librsvg2-dev
26-
- name: Install
22+
sudo apt install -y build-essential libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev librsvg2-dev libpixman-1-dev
23+
- name: Build
2724
run: npm install --build-from-source
2825
- name: Test
2926
run: npm test
3027

31-
Windows:
32-
name: Test on Windows
33-
runs-on: windows-2019
28+
Alpine:
29+
runs-on: ubuntu-latest
3430
strategy:
3531
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]
32+
# FIXME: there is no 22 node image yet
33+
node: [ 18, 20 ]
34+
container:
35+
image: node:${{ matrix.node }}-alpine
4136
steps:
42-
- uses: actions/setup-node@v4
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
- name: Install Dependencies
40+
run: apk --no-cache add build-base cairo-dev jpeg-dev pango-dev giflib-dev librsvg-dev pixman-dev
41+
- name: Build
42+
run: npm install --build-from-source
43+
- name: Test
44+
# some tests failed
45+
continue-on-error: true
46+
run: npm test
47+
48+
macOS:
49+
strategy:
50+
matrix:
51+
node: [ 18, 20, 22 ]
52+
os:
53+
- runner: macos-latest
54+
arch: x64
55+
# - runner: macos-latest-xlarge
56+
# arch: arm64
57+
runs-on: ${{ matrix.os.runner }}
58+
steps:
59+
- name: Install Node.JS
60+
uses: actions/setup-node@v4
4361
with:
4462
node-version: ${{ matrix.node }}
45-
- uses: actions/checkout@v4
63+
- name: Checkout
64+
uses: actions/checkout@v4
4665
- 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
66+
run: brew install pkg-config cairo pango libpng giflib librsvg pixman
67+
- name: Build
5568
run: npm install --build-from-source
5669
- name: Test
5770
run: npm test
5871

59-
macOS:
60-
name: Test on macOS
61-
runs-on: macos-latest
72+
Windows:
73+
runs-on: windows-latest
6274
strategy:
6375
matrix:
64-
node: [18.12.0, 20.9.0]
76+
node: [ 18, 20, 22 ]
6577
steps:
6678
- uses: actions/setup-node@v4
6779
with:
6880
node-version: ${{ matrix.node }}
6981
- uses: actions/checkout@v4
82+
- uses: msys2/setup-msys2@v2
83+
with:
84+
msystem: UCRT64
85+
path-type: inherit
7086
- name: Install Dependencies
87+
shell: msys2 {0}
7188
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
89+
prefix=${MSYSTEM,,}
90+
arch=${MSYSTEM_CARCH}
91+
92+
pacman --noconfirm --needed -S \
93+
${prefix}/mingw-w64-ucrt-${arch}-binutils \
94+
${prefix}/mingw-w64-ucrt-${arch}-tools \
95+
${prefix}/mingw-w64-ucrt-${arch}-libjpeg-turbo \
96+
${prefix}/mingw-w64-ucrt-${arch}-pango \
97+
${prefix}/mingw-w64-ucrt-${arch}-cairo \
98+
${prefix}/mingw-w64-ucrt-${arch}-giflib \
99+
${prefix}/mingw-w64-ucrt-${arch}-harfbuzz \
100+
${prefix}/mingw-w64-ucrt-${arch}-freetype \
101+
${prefix}/mingw-w64-ucrt-${arch}-fontconfig \
102+
${prefix}/mingw-w64-ucrt-${arch}-librsvg \
103+
${prefix}/mingw-w64-ucrt-${arch}-libxml2
104+
105+
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"
106+
for lib in $libs; do
107+
gendef /${prefix}/bin/lib$lib.dll > /dev/null 2>&1 || {
108+
echo "could not find lib$lib.dll, have to skip ";
109+
continue;
110+
}
111+
dlltool -d lib$lib.def -l /${prefix}/lib/lib$lib.lib > /dev/null 2>&1 || {
112+
echo "could not create dll for lib$lib.dll";
113+
continue;
114+
}
115+
echo "created lib$lib.lib from lib$lib.dll";
116+
rm lib$lib.def
117+
done
118+
- name: Build
119+
shell: msys2 {0}
77120
run: npm install --build-from-source
78121
- name: Test
122+
shell: msys2 {0}
79123
run: npm test
80124

81125
Lint:
82126
name: Lint
83127
runs-on: ubuntu-latest
128+
strategy:
129+
matrix:
130+
node: [ 20 ]
131+
container:
132+
image: node:${{ matrix.node }}-slim
84133
steps:
85-
- uses: actions/setup-node@v4
86-
with:
87-
node-version: 20.9.0
88-
- uses: actions/checkout@v4
134+
- name: Checkout
135+
uses: actions/checkout@v4
89136
- name: Install
90137
run: npm install --ignore-scripts
91138
- name: Lint

0 commit comments

Comments
 (0)