Repository navigation
207 lines (185 loc) · 6.85 KB
/
Copy pathtest.yml
File metadata and controls
207 lines (185 loc) · 6.85 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
name: Test
defaults:
run:
shell: bash
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
package:
name: Pack npm Candidate
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-node@v6
with:
node-version: 24.13.0
cache: npm
- run: npm ci --ignore-scripts
- name: Store npm Candidate
uses: node-3d/addon-tools/actions/npm-candidate-upload@1073c0a6403f6c20df2135f03950a568e865aa16
unit-tests:
name: Unit Tests (${{ matrix.target }})
strategy:
fail-fast: false
matrix: &consumer-matrix
include:
- target: windows-x64
os: windows-2022
node_arch: x64
- target: linux-x64
os: ubuntu-22.04
node_arch: x64
- target: linux-arm64
os: ubuntu-24.04-arm
node_arch: arm64
- target: darwin-x64
os: macos-26-intel
node_arch: x64
- target: darwin-arm64
os: macos-26
node_arch: arm64
runs-on: ${{ matrix.os }}
steps:
- name: Fetch Repository
uses: actions/checkout@v7
with:
persist-credentials: false
- name: Install Node.js
uses: actions/setup-node@v6
with:
node-version: 24.13.0
architecture: ${{ matrix.node_arch }}
cache: 'npm'
- name: Print Native Target
run: |
echo "runner=$(uname -s)-$(uname -m)"
node -p "'node=' + process.version + ' platform=' + process.platform + ' arch=' + process.arch"
npm config get arch
- name: Install Modules
run: npm ci
- name: Verify Runtime Binaries
run: |
node --input-type=module <<'JS'
import fs from 'node:fs';
const platformNames = {
'win32-x64': 'windows',
'linux-x64': 'linux',
'darwin-x64': 'osx',
'linux-arm64': 'aarch64',
};
const platform = platformNames[`${process.platform}-${process.arch}`] ?? `${process.platform}-${process.arch}`;
const qmluiLib = process.platform === 'win32' ? 'qmlui.dll' : `libqmlui.${process.platform === 'darwin' ? 'dylib' : 'so'}`;
const required = [
`node_modules/@node-3d/qml/bin-${platform}/qml.node`,
`node_modules/@node-3d/deps-qmlui/bin-${platform}/${qmluiLib}`,
];
const missing = required.filter((path) => !fs.existsSync(path));
if (missing.length > 0) {
console.error(`Missing runtime binaries for ${platform}:`);
for (const path of missing) {
console.error(`- ${path}`);
}
process.exit(1);
}
JS
- name: Verify Package Loads - Mac
if: matrix.target == 'darwin-x64' || matrix.target == 'darwin-arm64'
run: |
node --input-type=module <<'JS'
const qml = await import('@node-3d/qml');
const plugin = await import('./ts/index.ts');
const required = [
['@node-3d/qml View', qml.View],
['@node-3d/qml Property', qml.Property],
['@node-3d/qml Method', qml.Method],
['@node-3d/plugin-qml init', plugin.init],
];
for (const [name, value] of required) {
if (typeof value !== 'function') {
throw new TypeError(`${name} did not load as a function.`);
}
}
JS
- name: Run Unit Tests - Linux
if: matrix.target == 'linux-x64' || matrix.target == 'linux-arm64'
run: |
mkdir -p test/__diff__
touch test/__diff__/.empty
sudo apt-get update -qq
sudo apt-get install -qq libgles2-mesa-dev libxcb-cursor0 libxcb-icccm4 libxcb-keysyms1 libxcb-shape0 libxcb-xkb1 libxkbcommon-x11-0
sudo apt-get install -qq libdbus-1-3 libxcb-image0 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0
if [ '${{ matrix.target }}' = 'linux-arm64' ]; then
export QT_XCB_GL_INTEGRATION=xcb_egl
export NODE_3D_SKIP_QML_SCREENSHOT=1
fi
QT_QPA_PLATFORM=xcb xvfb-run --auto-servernum npm run test:ci
- uses: ssciwr/setup-mesa-dist-win@v3
if: matrix.target == 'windows-x64'
- name: Run Unit Tests - Windows
if: matrix.target == 'windows-x64'
run: npm run test:ci
- name: Check Diff Artifacts
id: diff-artifacts
if: always()
run: |
if [ -d test/__diff__ ] && find test/__diff__ -type f | read -r _; then
echo "present=true" >> "$GITHUB_OUTPUT"
else
echo "present=false" >> "$GITHUB_OUTPUT"
fi
- uses: actions/upload-artifact@v7
if: always() && steps.diff-artifacts.outputs.present == 'true'
with:
name: __diff__-${{ matrix.target }}
path: test/__diff__
retention-days: 1
compression-level: 0
overwrite: true
consumer-tests:
name: Packed Consumer (${{ matrix.target }})
needs: [package, unit-tests]
strategy:
fail-fast: false
matrix: *consumer-matrix
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-node@v6
with:
node-version: 24.13.0
architecture: ${{ matrix.node_arch }}
- name: Install Qt Runtime Libraries - Linux
if: startsWith(matrix.target, 'linux-')
run: |
sudo apt-get update -qq
sudo apt-get install -qq libgles2-mesa-dev libxcb-cursor0 libxcb-icccm4 libxcb-keysyms1 libxcb-shape0 libxcb-xkb1 libxkbcommon-x11-0
sudo apt-get install -qq libdbus-1-3 libxcb-image0 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0
- uses: ssciwr/setup-mesa-dist-win@v3
if: matrix.target == 'windows-x64'
- name: Install Packed Consumer Candidate
id: consumer
uses: node-3d/addon-tools/actions/consumer-install@1073c0a6403f6c20df2135f03950a568e865aa16
with:
package-name: '@node-3d/plugin-qml'
fixture: test-consumer
- name: Run Packed Consumer Tests - Linux
if: startsWith(matrix.target, 'linux-')
working-directory: ${{ steps.consumer.outputs.directory }}
run: |
if [ '${{ matrix.target }}' = 'linux-arm64' ]; then
export QT_XCB_GL_INTEGRATION=xcb_egl
fi
QT_QPA_PLATFORM=xcb xvfb-run --auto-servernum npm test
- name: Run Packed Consumer Tests - Windows and macOS
if: startsWith(matrix.target, 'windows-') || startsWith(matrix.target, 'darwin-')
working-directory: ${{ steps.consumer.outputs.directory }}
run: npm test