|
1 | 1 | # CI workflow for node-webcodecs |
2 | 2 | # Runs linting, building, and testing on all supported platforms |
3 | 3 | # |
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) |
9 | 10 | # |
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 |
11 | 16 |
|
12 | 17 | name: CI |
13 | 18 |
|
|
31 | 36 | - name: Setup Node.js |
32 | 37 | uses: actions/setup-node@v4 |
33 | 38 | with: |
34 | | - node-version: 22 |
| 39 | + node-version: 20 |
35 | 40 |
|
36 | 41 | - name: Setup Python |
37 | 42 | uses: actions/setup-python@v5 |
@@ -59,137 +64,169 @@ jobs: |
59 | 64 | - name: Lint markdown |
60 | 65 | run: npm run lint:md |
61 | 66 |
|
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 || '' }} |
66 | 71 | strategy: |
| 72 | + fail-fast: false |
67 | 73 | 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 | + |
69 | 101 | 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') |
71 | 116 | run: | |
72 | | - # Enable EPEL and CRB repositories for FFmpeg |
73 | 117 | dnf install -y epel-release |
74 | 118 | dnf config-manager --set-enabled crb |
75 | | - # Install RPMFusion for FFmpeg 6+ (EPEL has ffmpeg-free but missing some libs) |
76 | 119 | dnf install -y https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-9.noarch.rpm |
77 | | - # Install build tools (FFmpeg comes from npm packages) |
78 | 120 | dnf install -y gcc-c++ make python3 git pkgconfig |
79 | 121 |
|
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') |
106 | 125 | run: | |
107 | | - # Install build tools and Node.js |
108 | | - # zlib-dev and bzip2-dev required for linking FFmpeg |
109 | 126 | apk add --no-cache build-base python3 pkgconf git nodejs npm zlib-dev bzip2-dev |
110 | 127 |
|
111 | 128 | - name: Checkout |
112 | 129 | uses: actions/checkout@v4 |
113 | 130 |
|
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) |
136 | 132 | - name: Setup Node.js |
| 133 | + if: matrix.os == 'darwin' |
137 | 134 | uses: actions/setup-node@v4 |
138 | 135 | 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 |
169 | 137 |
|
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') |
174 | 141 | uses: actions/setup-node@v4 |
175 | 142 | with: |
176 | | - node-version: ${{ matrix.node }} |
| 143 | + node-version: 20 |
177 | 144 |
|
| 145 | + # Cache node-gyp for macOS |
178 | 146 | - name: Cache node-gyp |
| 147 | + if: matrix.os == 'darwin' |
179 | 148 | uses: actions/cache@v4 |
180 | 149 | with: |
181 | 150 | path: | |
182 | 151 | ~/.cache/node-gyp |
183 | 152 | ~/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') }} |
185 | 154 | restore-keys: | |
186 | | - node-gyp-macos-x64-node${{ matrix.node }}- |
| 155 | + node-gyp-${{ matrix.platform }}-node20- |
187 | 156 |
|
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' |
189 | 174 | run: npm install --omit=optional |
190 | 175 |
|
| 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 |
191 | 225 | - name: Build |
| 226 | + if: matrix.qemu != true |
192 | 227 | run: npm run build |
193 | 228 |
|
| 229 | + # Test for non-ARM64 platforms |
194 | 230 | - name: Test |
| 231 | + if: matrix.qemu != true |
195 | 232 | run: npm test |
0 commit comments