-
Notifications
You must be signed in to change notification settings - Fork 0
256 lines (223 loc) · 7.96 KB
/
ci.yml
File metadata and controls
256 lines (223 loc) · 7.96 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# CI workflow for node-webcodecs
# Runs linting, building, and testing on all supported platforms
#
# Platforms (matching @pproenca/webcodecs-ffmpeg packages):
# - darwin-arm64 (macos-14 runner)
# - darwin-x64 (macos-13 runner)
# - linux-x64-glibc (Rocky Linux 9 container)
# - linux-arm64 (QEMU + ARM64 container)
# - linux-x64-musl (Alpine 3.20 container)
#
# Variants:
# - free (LGPL FFmpeg)
# - non-free (GPL FFmpeg with x264/x265)
#
# Node.js version: 20
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
permissions:
contents: read
checks: write
pull-requests: write
jobs:
lint:
name: Lint
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install cpplint
run: pip install cpplint
- name: Install dependencies
run: npm install
- name: Build TypeScript
run: npm run build:ts
- name: Lint C++
run: cpplint --quiet src/*.h src/*.cc
- name: Lint TypeScript
run: npm run lint:ts
- name: Lint types
run: npm run lint:types
- name: Lint markdown
run: npm run lint:md
build:
name: ${{ matrix.platform }}-${{ matrix.variant }}
runs-on: ${{ matrix.runner }}
container: ${{ matrix.container || '' }}
strategy:
fail-fast: false
matrix:
platform: [darwin-arm64, darwin-x64, linux-x64-glibc, linux-arm64, linux-x64-musl]
variant: [free, non-free]
# Exclude linux-x64-musl-free: LGPL build lacks H.264/H.265 encoders (GPL)
# Tests requiring encoding will fail without libx264/libx265
exclude:
- platform: linux-x64-musl
variant: free
include:
- platform: darwin-arm64
runner: macos-14
os: darwin
ffmpeg_pkg: darwin-arm64
- platform: darwin-x64
runner: macos-13
os: darwin
ffmpeg_pkg: darwin-x64
- platform: linux-x64-glibc
runner: ubuntu-24.04
container: rockylinux:9
os: linux
ffmpeg_pkg: linux-x64
- platform: linux-arm64
runner: ubuntu-24.04
os: linux
ffmpeg_pkg: linux-arm64
qemu: true
- platform: linux-x64-musl
runner: ubuntu-24.04
container: alpine:3.20
os: linux
ffmpeg_pkg: linux-x64-musl
steps:
# QEMU setup for ARM64 cross-compilation
- name: Set up QEMU
if: matrix.qemu == true
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Set up Docker Buildx
if: matrix.qemu == true
uses: docker/setup-buildx-action@v3
# System dependencies for Rocky Linux container
- name: Install system dependencies (Rocky Linux)
if: contains(matrix.container, 'rockylinux')
run: |
dnf install -y epel-release
dnf config-manager --set-enabled crb
dnf install -y https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-9.noarch.rpm
dnf install -y gcc-c++ make python3 git pkgconfig zlib-devel bzip2-devel libatomic
# System dependencies for Alpine container
- name: Install system dependencies (Alpine)
if: contains(matrix.container, 'alpine')
run: |
apk add --no-cache build-base python3 pkgconf git nodejs npm zlib-dev bzip2-dev
- name: Checkout
uses: actions/checkout@v4
# Node.js setup for non-container jobs (macOS)
- name: Setup Node.js
if: matrix.os == 'darwin'
uses: actions/setup-node@v4
with:
node-version: 20
# Node.js setup for Rocky Linux container
- name: Install Node.js (Rocky Linux)
if: contains(matrix.container, 'rockylinux')
uses: actions/setup-node@v4
with:
node-version: 20
# Cache node-gyp for macOS
- name: Cache node-gyp
if: matrix.os == 'darwin'
uses: actions/cache@v4
with:
path: |
~/.cache/node-gyp
~/Library/Caches/node-gyp
key: node-gyp-${{ matrix.platform }}-node20-${{ hashFiles('binding.gyp') }}
restore-keys: |
node-gyp-${{ matrix.platform }}-node20-
# FFmpeg installation for macOS
# - free variant: npm LGPL package
# - non-free variant: Homebrew (includes x264/x265)
- name: Install FFmpeg (macOS npm - free)
if: matrix.os == 'darwin' && matrix.variant == 'free'
run: |
npm cache clean --force
PKG="@pproenca/webcodecs-ffmpeg-${{ matrix.ffmpeg_pkg }}"
echo "Installing FFmpeg package: $PKG"
npm install --no-save "$PKG"
- name: Install FFmpeg (macOS Homebrew - non-free)
if: matrix.os == 'darwin' && matrix.variant == 'non-free'
run: brew install ffmpeg
# Install dependencies (macOS - omit optional to avoid platform mismatch)
- name: Install dependencies (macOS)
if: matrix.os == 'darwin'
run: npm install --omit=optional
# Install FFmpeg npm package based on variant (Linux non-ARM64)
- name: Install FFmpeg (Linux npm)
if: matrix.os == 'linux' && matrix.qemu != true
run: |
npm cache clean --force
PKG="@pproenca/webcodecs-ffmpeg-${{ matrix.ffmpeg_pkg }}"
if [ "${{ matrix.variant }}" = "non-free" ]; then
PKG="${PKG}-non-free"
fi
echo "Installing FFmpeg package: $PKG"
npm install --no-save "$PKG"
# Install dependencies (Linux containers)
- name: Install dependencies (Linux)
if: matrix.os == 'linux' && matrix.qemu != true
run: npm install
# Linux ARM64 builds via Docker with QEMU
- name: Build and Test (linux-arm64)
if: matrix.qemu == true
env:
VARIANT: ${{ matrix.variant }}
run: |
# Determine FFmpeg package based on variant
if [ "$VARIANT" = "non-free" ]; then
FFMPEG_PKG="@pproenca/webcodecs-ffmpeg-linux-arm64-non-free"
else
FFMPEG_PKG="@pproenca/webcodecs-ffmpeg-linux-arm64"
fi
docker run --rm --platform linux/arm64 \
-v "${{ github.workspace }}:/workspace" \
-w /workspace \
-e FFMPEG_VARIANT="$VARIANT" \
arm64v8/rockylinux:9 \
bash -c "
set -e
dnf install -y epel-release
dnf config-manager --set-enabled crb
dnf install -y https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-9.noarch.rpm
dnf install -y gcc-c++ make python3 git pkgconfig zlib-devel bzip2-devel libatomic
curl -fsSL https://rpm.nodesource.com/setup_20.x | bash -
dnf install -y nodejs
npm cache clean --force
npm install --no-save \"$FFMPEG_PKG\"
npm install
npm run build
npm test
"
# Build for non-ARM64 platforms
- name: Build
if: matrix.qemu != true
run: npm run build
# Test for non-ARM64 platforms
- name: Test
if: matrix.qemu != true
run: npm run test:ci
# Run native C++ tests with JUnit output (macOS only for now)
- name: Native Tests
if: matrix.qemu != true && matrix.os == 'darwin'
continue-on-error: true
run: npm run test:native:ci
# Publish test results with annotations
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always() && matrix.qemu != true && matrix.os == 'darwin'
with:
files: test/native/build/native-results.xml
check_name: "Test Results (${{ matrix.platform }}-${{ matrix.variant }})"