-
Notifications
You must be signed in to change notification settings - Fork 42
160 lines (149 loc) · 5.7 KB
/
Copy pathtest-windows-prebuilt.yaml
File metadata and controls
160 lines (149 loc) · 5.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: test-windows-prebuilt
#
# Answers: "do prebuilt Windows binaries let users `npm install node-gtk` and use
# it WITHOUT compiling?"
#
# build-prebuilt - build the addon under MSYS2/MinGW (as today), then bundle
# its full DLL closure + GI typelibs next to the .node and
# upload it as an artifact (this is the candidate prebuilt).
# consume-clean - a SEPARATE, clean Windows runner with NO MSYS2 and NO
# compiler. Installs node-gtk's JS deps with --ignore-scripts
# (so nothing is ever built), drops in the prebuilt, and runs
# a smoke test that loads GTK and exercises GObject-Introspection.
#
on:
push:
branches:
- test-windows-prebuilt
workflow_dispatch:
jobs:
build-prebuilt:
name: build prebuilt - nodejs ${{ matrix.node }}
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
node:
- 22
- 20
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
path-type: inherit
update: true
install: |
git
make
mingw-w64-x86_64-gcc
mingw-w64-x86_64-pkgconf
mingw-w64-x86_64-python
mingw-w64-x86_64-ntldd-git
mingw-w64-x86_64-gobject-introspection
mingw-w64-x86_64-cairo
mingw-w64-x86_64-gtk4
mingw-w64-x86_64-libadwaita
mingw-w64-x86_64-gtksourceview5
mingw-w64-x86_64-graphene
mingw-w64-x86_64-adwaita-icon-theme
- name: Build from source
env:
GYP_GENERATORS: make
CC: gcc
CXX: g++
run: |
./windows/mingw_include_extra.sh
export MINGW_WINDOWS_PATH=$(./windows/mingw_windows_path.sh)
export PATH="/mingw64/bin:/usr/bin:$PATH"
npm install -g pnpm@11
pnpm install --ignore-scripts
pnpm run build:full
- name: Bundle GTK4 runtime (DLLs + typelibs + data)
run: |
ABI=$(node -p "process.versions.modules")
BINDING="lib/binding/node-v${ABI}-win32-x64"
echo "ABI=$ABI BINDING=$BINDING"
ls -la "$BINDING"
./scripts/windows-bundle-runtime.sh "$BINDING"
- name: Report compressed download size (what users fetch)
run: |
npx node-pre-gyp package >/dev/null 2>&1 || true
TARBALL=$(find build/stage -name '*.tar.gz' 2>/dev/null | head -1)
if [ -n "$TARBALL" ]; then
echo "## node-pre-gyp tarball (gzip, the S3 download): $(du -h "$TARBALL" | cut -f1) -> $TARBALL"
else
echo "## (node-pre-gyp package produced no tarball; uncompressed size is in the bundle step)"
fi
- name: Upload prebuilt artifact
uses: actions/upload-artifact@v4
with:
name: prebuilt-node-${{ matrix.node }}
path: lib/binding/
if-no-files-found: error
consume-clean:
name: consume prebuilt (clean machine) - nodejs ${{ matrix.node }}
needs: build-prebuilt
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
node:
- 22
- 20
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
# Install ONLY the JS dependencies, never the native build hook.
# This is what a user gets when a prebuilt is available: no compiler runs.
- name: Install JS deps (no build)
shell: bash
run: |
npm install -g pnpm@11
pnpm install --ignore-scripts
- name: Download prebuilt
uses: actions/download-artifact@v4
with:
name: prebuilt-node-${{ matrix.node }}
path: lib/binding/
- name: Show what we got
shell: bash
run: |
echo "Tools available on this runner (expect NONE of these):"
(which gcc && echo "gcc FOUND") || echo "no gcc (good)"
(where.exe pacman && echo "pacman FOUND") || echo "no pacman (good)"
echo "---- bundled prebuilt ----"
ls -la lib/binding/*/ || true
# Negative control: move the bundled typelibs aside so native.js cannot
# auto-wire; the addon must then fail to load. Proves the pass below comes
# from the bundle (not the runner's GTK), then restores it. Allowed to fail.
- name: Negative control (no bundled runtime — expected to fail)
continue-on-error: true
shell: bash
run: |
export PATH=$(echo "$PATH" | tr ':' '\n' | grep -viE 'mingw|msys|chocolatey' | paste -sd ':' -)
DIR=$(echo lib/binding/node-v*-win32-x64)
mv "$DIR/girepository-1.0" "$DIR/girepository-1.0.off"
if node -e "require('.')"; then
echo "UNEXPECTED - loaded without the bundled GTK runtime"
else
echo "expected failure - addon needs the bundled GTK runtime/typelibs"
fi
mv "$DIR/girepository-1.0.off" "$DIR/girepository-1.0"
# The real test: NO env vars set here, and the runner's own MinGW/MSYS is
# stripped from PATH to simulate a clean user machine. A pass proves
# lib/native.js auto-wires the bundled runtime by itself.
- name: Smoke test (auto-wired, simulated clean machine)
shell: bash
run: |
export PATH=$(echo "$PATH" | tr ':' '\n' | grep -viE 'mingw|msys|chocolatey' | paste -sd ':' -)
echo "gcc on PATH? $(which gcc || echo no)"
node scripts/windows-smoke-test.js