ci: add GitHub Actions workflow for multi-platform testing #352
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 | |
| 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] | |
| 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 | |
| # 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 | |
| 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 test |