Skip to content

Commit 85dc955

Browse files
committed
feat(ci): align build matrix with ffmpeg-prebuilds packages
Expand CI from 4 builds to 10 builds matching @pproenca/webcodecs-ffmpeg: - 5 platforms: darwin-arm64, darwin-x64, linux-x64-glibc, linux-arm64, linux-x64-musl - 2 variants: free (LGPL), non-free (GPL) Changes: - Refactor to unified matrix strategy (replaces 4 separate jobs) - Add linux-arm64 support via QEMU emulation - Add variant-aware FFmpeg package installation - macOS free variant uses npm packages, non-free uses Homebrew - Linux builds explicitly install correct FFmpeg package per variant - Update ffmpeg-prebuilds to 0.1.6 - Add linux-arm64 to optionalDependencies - Simplify to Node.js 20 only
1 parent 0b966c9 commit 85dc955

2 files changed

Lines changed: 147 additions & 109 deletions

File tree

.github/workflows/ci.yml

Lines changed: 141 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
# CI workflow for node-webcodecs
22
# Runs linting, building, and testing on all supported platforms
33
#
4-
# Platforms:
5-
# - Linux x64 glibc (Rocky Linux 9 container - FFmpeg 6+, glibc 2.34)
6-
# - Linux x64 musl (Alpine 3.20 container - FFmpeg 6+, musl libc)
7-
# - macOS ARM64 (macos-14 runner)
8-
# - macOS x64 (macos-13 runner)
4+
# Platforms (matching @pproenca/webcodecs-ffmpeg packages):
5+
# - darwin-arm64 (macos-14 runner)
6+
# - darwin-x64 (macos-13 runner)
7+
# - linux-x64-glibc (Rocky Linux 9 container)
8+
# - linux-arm64 (QEMU + ARM64 container)
9+
# - linux-x64-musl (Alpine 3.20 container)
910
#
10-
# Node.js versions: 20, 22 (matching engines field)
11+
# Variants:
12+
# - free (LGPL FFmpeg)
13+
# - non-free (GPL FFmpeg with x264/x265)
14+
#
15+
# Node.js version: 20
1116

1217
name: CI
1318

@@ -31,7 +36,7 @@ jobs:
3136
- name: Setup Node.js
3237
uses: actions/setup-node@v4
3338
with:
34-
node-version: 22
39+
node-version: 20
3540

3641
- name: Setup Python
3742
uses: actions/setup-python@v5
@@ -59,137 +64,169 @@ jobs:
5964
- name: Lint markdown
6065
run: npm run lint:md
6166

62-
build-linux-glibc:
63-
name: Linux glibc (Node ${{ matrix.node }})
64-
runs-on: ubuntu-24.04
65-
container: rockylinux:9
67+
build:
68+
name: ${{ matrix.platform }}-${{ matrix.variant }}
69+
runs-on: ${{ matrix.runner }}
70+
container: ${{ matrix.container || '' }}
6671
strategy:
72+
fail-fast: false
6773
matrix:
68-
node: [20, 22]
74+
platform: [darwin-arm64, darwin-x64, linux-x64-glibc, linux-arm64, linux-x64-musl]
75+
variant: [free, non-free]
76+
include:
77+
- platform: darwin-arm64
78+
runner: macos-14
79+
os: darwin
80+
ffmpeg_pkg: darwin-arm64
81+
- platform: darwin-x64
82+
runner: macos-13
83+
os: darwin
84+
ffmpeg_pkg: darwin-x64
85+
- platform: linux-x64-glibc
86+
runner: ubuntu-24.04
87+
container: rockylinux:9
88+
os: linux
89+
ffmpeg_pkg: linux-x64
90+
- platform: linux-arm64
91+
runner: ubuntu-24.04
92+
os: linux
93+
ffmpeg_pkg: linux-arm64
94+
qemu: true
95+
- platform: linux-x64-musl
96+
runner: ubuntu-24.04
97+
container: alpine:3.20
98+
os: linux
99+
ffmpeg_pkg: linux-x64-musl
100+
69101
steps:
70-
- name: Install system dependencies
102+
# QEMU setup for ARM64 cross-compilation
103+
- name: Set up QEMU
104+
if: matrix.qemu == true
105+
uses: docker/setup-qemu-action@v3
106+
with:
107+
platforms: arm64
108+
109+
- name: Set up Docker Buildx
110+
if: matrix.qemu == true
111+
uses: docker/setup-buildx-action@v3
112+
113+
# System dependencies for Rocky Linux container
114+
- name: Install system dependencies (Rocky Linux)
115+
if: contains(matrix.container, 'rockylinux')
71116
run: |
72-
# Enable EPEL and CRB repositories for FFmpeg
73117
dnf install -y epel-release
74118
dnf config-manager --set-enabled crb
75-
# Install RPMFusion for FFmpeg 6+ (EPEL has ffmpeg-free but missing some libs)
76119
dnf install -y https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-9.noarch.rpm
77-
# Install build tools (FFmpeg comes from npm packages)
78120
dnf install -y gcc-c++ make python3 git pkgconfig
79121
80-
- name: Checkout
81-
uses: actions/checkout@v4
82-
83-
- name: Install Node.js
84-
uses: actions/setup-node@v4
85-
with:
86-
node-version: ${{ matrix.node }}
87-
88-
- name: Install dependencies
89-
run: npm install
90-
91-
- name: Build
92-
run: npm run build
93-
94-
- name: Test
95-
run: npm test
96-
97-
build-linux-musl:
98-
name: Linux musl (Node ${{ matrix.node }})
99-
runs-on: ubuntu-24.04
100-
container: alpine:3.20
101-
strategy:
102-
matrix:
103-
node: [20, 22]
104-
steps:
105-
- name: Install system dependencies
122+
# System dependencies for Alpine container
123+
- name: Install system dependencies (Alpine)
124+
if: contains(matrix.container, 'alpine')
106125
run: |
107-
# Install build tools and Node.js
108-
# zlib-dev and bzip2-dev required for linking FFmpeg
109126
apk add --no-cache build-base python3 pkgconf git nodejs npm zlib-dev bzip2-dev
110127
111128
- name: Checkout
112129
uses: actions/checkout@v4
113130

114-
- name: Install dependencies
115-
run: npm install
116-
117-
- name: Build
118-
run: npm run build
119-
120-
- name: Test
121-
run: npm test
122-
123-
build-macos-arm64:
124-
name: macOS ARM64 (Node ${{ matrix.node }})
125-
runs-on: macos-14
126-
strategy:
127-
matrix:
128-
node: [20, 22]
129-
steps:
130-
- name: Checkout
131-
uses: actions/checkout@v4
132-
133-
- name: Install FFmpeg
134-
run: brew install ffmpeg
135-
131+
# Node.js setup for non-container jobs (macOS)
136132
- name: Setup Node.js
133+
if: matrix.os == 'darwin'
137134
uses: actions/setup-node@v4
138135
with:
139-
node-version: ${{ matrix.node }}
140-
141-
- name: Cache node-gyp
142-
uses: actions/cache@v4
143-
with:
144-
path: |
145-
~/.cache/node-gyp
146-
~/Library/Caches/node-gyp
147-
key: node-gyp-macos-arm64-node${{ matrix.node }}-${{ hashFiles('binding.gyp') }}
148-
restore-keys: |
149-
node-gyp-macos-arm64-node${{ matrix.node }}-
150-
151-
- name: Install dependencies
152-
run: npm install --omit=optional
153-
154-
- name: Build
155-
run: npm run build
156-
157-
- name: Test
158-
run: npm test
159-
160-
build-macos-x64:
161-
name: macOS x64 (Node ${{ matrix.node }})
162-
runs-on: macos-13
163-
strategy:
164-
matrix:
165-
node: [20, 22]
166-
steps:
167-
- name: Checkout
168-
uses: actions/checkout@v4
136+
node-version: 20
169137

170-
- name: Install FFmpeg
171-
run: brew install ffmpeg
172-
173-
- name: Setup Node.js
138+
# Node.js setup for Rocky Linux container
139+
- name: Install Node.js (Rocky Linux)
140+
if: contains(matrix.container, 'rockylinux')
174141
uses: actions/setup-node@v4
175142
with:
176-
node-version: ${{ matrix.node }}
143+
node-version: 20
177144

145+
# Cache node-gyp for macOS
178146
- name: Cache node-gyp
147+
if: matrix.os == 'darwin'
179148
uses: actions/cache@v4
180149
with:
181150
path: |
182151
~/.cache/node-gyp
183152
~/Library/Caches/node-gyp
184-
key: node-gyp-macos-x64-node${{ matrix.node }}-${{ hashFiles('binding.gyp') }}
153+
key: node-gyp-${{ matrix.platform }}-node20-${{ hashFiles('binding.gyp') }}
185154
restore-keys: |
186-
node-gyp-macos-x64-node${{ matrix.node }}-
155+
node-gyp-${{ matrix.platform }}-node20-
187156
188-
- name: Install dependencies
157+
# FFmpeg installation for macOS
158+
# - free variant: npm LGPL package
159+
# - non-free variant: Homebrew (includes x264/x265)
160+
- name: Install FFmpeg (macOS npm - free)
161+
if: matrix.os == 'darwin' && matrix.variant == 'free'
162+
run: |
163+
PKG="@pproenca/webcodecs-ffmpeg-${{ matrix.ffmpeg_pkg }}"
164+
echo "Installing FFmpeg package: $PKG"
165+
npm install --no-save "$PKG"
166+
167+
- name: Install FFmpeg (macOS Homebrew - non-free)
168+
if: matrix.os == 'darwin' && matrix.variant == 'non-free'
169+
run: brew install ffmpeg
170+
171+
# Install dependencies (macOS - omit optional to avoid platform mismatch)
172+
- name: Install dependencies (macOS)
173+
if: matrix.os == 'darwin'
189174
run: npm install --omit=optional
190175

176+
# Install FFmpeg npm package based on variant (Linux non-ARM64)
177+
- name: Install FFmpeg (Linux npm)
178+
if: matrix.os == 'linux' && matrix.qemu != true
179+
run: |
180+
PKG="@pproenca/webcodecs-ffmpeg-${{ matrix.ffmpeg_pkg }}"
181+
if [ "${{ matrix.variant }}" = "non-free" ]; then
182+
PKG="${PKG}-non-free"
183+
fi
184+
echo "Installing FFmpeg package: $PKG"
185+
npm install --no-save "$PKG"
186+
187+
# Install dependencies (Linux containers)
188+
- name: Install dependencies (Linux)
189+
if: matrix.os == 'linux' && matrix.qemu != true
190+
run: npm install
191+
192+
# Linux ARM64 builds via Docker with QEMU
193+
- name: Build and Test (linux-arm64)
194+
if: matrix.qemu == true
195+
env:
196+
VARIANT: ${{ matrix.variant }}
197+
run: |
198+
# Determine FFmpeg package based on variant
199+
if [ "$VARIANT" = "non-free" ]; then
200+
FFMPEG_PKG="@pproenca/webcodecs-ffmpeg-linux-arm64-non-free"
201+
else
202+
FFMPEG_PKG="@pproenca/webcodecs-ffmpeg-linux-arm64"
203+
fi
204+
205+
docker run --rm --platform linux/arm64 \
206+
-v "${{ github.workspace }}:/workspace" \
207+
-w /workspace \
208+
-e FFMPEG_VARIANT="$VARIANT" \
209+
arm64v8/rockylinux:9 \
210+
bash -c "
211+
set -e
212+
dnf install -y epel-release
213+
dnf config-manager --set-enabled crb
214+
dnf install -y https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-9.noarch.rpm
215+
dnf install -y gcc-c++ make python3 git pkgconfig
216+
curl -fsSL https://rpm.nodesource.com/setup_20.x | bash -
217+
dnf install -y nodejs
218+
npm install --no-save \"$FFMPEG_PKG\"
219+
npm install
220+
npm run build
221+
npm test
222+
"
223+
224+
# Build for non-ARM64 platforms
191225
- name: Build
226+
if: matrix.qemu != true
192227
run: npm run build
193228

229+
# Test for non-ARM64 platforms
194230
- name: Test
231+
if: matrix.qemu != true
195232
run: npm test

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,11 @@
8080
"@pproenca/node-webcodecs-darwin-x64": "0.1.1-alpha.8",
8181
"@pproenca/node-webcodecs-linux-x64-glibc": "0.1.1-alpha.8",
8282
"@pproenca/node-webcodecs-linux-x64-musl": "0.1.1-alpha.8",
83-
"@pproenca/webcodecs-ffmpeg-darwin-arm64": "^0.1.4",
84-
"@pproenca/webcodecs-ffmpeg-darwin-x64": "^0.1.4",
85-
"@pproenca/webcodecs-ffmpeg-linux-x64": "^0.1.4",
86-
"@pproenca/webcodecs-ffmpeg-linux-x64-musl": "^0.1.4"
83+
"@pproenca/webcodecs-ffmpeg-darwin-arm64": "^0.1.6",
84+
"@pproenca/webcodecs-ffmpeg-darwin-x64": "^0.1.6",
85+
"@pproenca/webcodecs-ffmpeg-linux-arm64": "^0.1.6",
86+
"@pproenca/webcodecs-ffmpeg-linux-x64": "^0.1.6",
87+
"@pproenca/webcodecs-ffmpeg-linux-x64-musl": "^0.1.6"
8788
},
8889
"dependencies": {
8990
"detect-libc": "^2.1.2",
@@ -92,7 +93,7 @@
9293
"devDependencies": {
9394
"@biomejs/biome": "^2.3.10",
9495
"@cpplint/cli": "^0.1.0",
95-
"@pproenca/webcodecs-ffmpeg-dev": "^0.1.4",
96+
"@pproenca/webcodecs-ffmpeg-dev": "^0.1.6",
9697
"@types/node": "^25.0.3",
9798
"@types/turndown": "^5.0.6",
9899
"c8": "^10.1.3",

0 commit comments

Comments
 (0)