Use sccache and vcpkg built-in GitHub Actions support in node-ci #5749
Workflow file for this run
This file contains 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
name: node-ci | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
- topic/drawable | |
- node-*.*.x | |
tags: | |
- "node-*" | |
paths: | |
- CMakeLists.txt | |
- "platform/linux/**" | |
- "platform/default/**" | |
- "platform/node/**" | |
- "platform/windows/**" | |
- "platform/darwin/**" | |
- "platform/macos/**" | |
- "platform/ios/platform/darwin/**" | |
- "platform/ios/platform/macos/**" | |
- ".github/workflows/node-ci.yml" | |
- "bin/**" | |
- "expression-test/**" | |
- "include/**" | |
- "metrics/**" | |
- "render-test/**" | |
- "scripts/**" | |
- "src/**" | |
- "test/**" | |
- "vendor/**" | |
- ".gitmodules" | |
- "!**/*.md" | |
- "package.json" | |
- "package-lock.json" | |
pull_request: | |
branches: | |
- "*" | |
paths: | |
- CMakeLists.txt | |
- "platform/linux/**" | |
- "platform/default/**" | |
- "platform/node/**" | |
- "platform/windows/**" | |
- "platform/darwin/**" | |
- "platform/macos/**" | |
- "platform/ios/platform/darwin/**" | |
- "platform/ios/platform/macos/**" | |
- ".github/workflows/node-ci.yml" | |
- "bin/**" | |
- "expression-test/**" | |
- "include/**" | |
- "metrics/**" | |
- "render-test/**" | |
- "scripts/**" | |
- "src/**" | |
- "test/**" | |
- "vendor/**" | |
- ".gitmodules" | |
- "!**/*.md" | |
- "package.json" | |
- "package-lock.json" | |
concurrency: | |
# cancel jobs on PRs only | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
env: | |
SCCACHE_GHA_ENABLED: "true" | |
jobs: | |
test: | |
runs-on: ${{ matrix.runs-on }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- runs-on: ubuntu-22.04 | |
arch: x86_64 | |
- runs-on: MapLibre_Native_Ubuntu_22_04_ARM_8_core | |
arch: arm64 | |
- runs-on: macos-14 | |
arch: arm64 | |
- runs-on: macos-14-large | |
arch: x86_64 | |
- runs-on: windows-2022 | |
arch: x86_64 | |
continue-on-error: true | |
env: | |
BUILDTYPE: "Release" | |
steps: | |
- name: Configure long filenames in Windows | |
if: runner.os == 'Windows' | |
run: | | |
git config --system core.longpaths true | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- name: Get OS Architecture | |
if: runner.os == 'MacOS' || runner.os == 'Linux' | |
run: uname -m | |
- name: Install dependencies (MacOS) | |
if: runner.os == 'MacOS' | |
env: | |
HOMEBREW_NO_AUTO_UPDATE: 1 | |
HOMEBREW_NO_INSTALL_CLEANUP: 1 | |
run: | | |
brew list ccache || brew install ccache | |
brew list ninja || brew install ninja | |
brew list pkg-config || brew install pkg-config | |
brew list glfw || brew install glfw | |
brew list libuv || brew install libuv | |
- name: Install dependencies (Linux) | |
if: runner.os == 'Linux' | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y \ | |
ccache \ | |
ninja-build \ | |
pkg-config \ | |
xvfb \ | |
libcurl4-openssl-dev \ | |
libglfw3-dev \ | |
libuv1-dev \ | |
g++-12 \ | |
libjpeg-dev \ | |
libpng-dev \ | |
libwebp-dev | |
/usr/sbin/update-ccache-symlinks | |
- name: Use Node.js from nvmrc | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
- name: npm ci | |
working-directory: platform/node | |
run: npm ci --ignore-scripts | |
- name: Set up msvc dev cmd (Windows) | |
if: runner.os == 'Windows' | |
uses: ilammy/msvc-dev-cmd@v1 | |
- name: Set up ccache (MacOS/Linux) | |
if: runner.os == 'MacOS' || runner.os == 'Linux' | |
uses: hendrikmuhs/ccache-action@v1 | |
with: | |
key: ${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}-${{ github.head_ref }} | |
restore-keys: | | |
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }} | |
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }} | |
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }} | |
- name: Export GitHub Actions cache environment variables for sccache and vcpkg (Windows) | |
if: runner.os == 'Windows' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); | |
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); | |
- name: Set up sccache (Windows) | |
if: runner.os == 'Windows' | |
uses: mozilla-actions/[email protected] | |
- name: Initialize sccache (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
${{ env.SCCACHE_PATH }} --start-server | |
${{ env.SCCACHE_PATH }} --zero-stats | |
- name: Cache cmake-node-module deps | |
uses: actions/cache@v4 | |
with: | |
# downloaded with platform/node/cmake/module.cmake | |
path: build/headers | |
key: ${{ runner.os }}-${{ runner.arch }}-cmake-node-module-deps | |
- name: Configure maplibre-native (MacOS) | |
if: runner.os == 'MacOS' | |
run: | | |
cmake . -B build \ | |
-G Ninja \ | |
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \ | |
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | |
-DMLN_WITH_NODE=ON \ | |
-DMLN_WITH_OPENGL=OFF \ | |
-DMLN_WITH_METAL=ON \ | |
-DMLN_LEGACY_RENDERER=OFF \ | |
-DMLN_DRAWABLE_RENDERER=ON \ | |
-DMLN_WITH_WERROR=OFF | |
- name: Configure maplibre-native (Linux) | |
if: runner.os == 'Linux' | |
run: | | |
cmake . -B build \ | |
-G Ninja \ | |
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \ | |
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | |
-DCMAKE_C_COMPILER=gcc-12 \ | |
-DCMAKE_CXX_COMPILER=g++-12 \ | |
-DMLN_WITH_NODE=ON | |
- name: Configure maplibre-native (Windows) | |
if: runner.os == 'Windows' | |
env: | |
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" | |
VCPKG_KEEP_ENV_VARS: "CMAKE_C_COMPILER_LAUNCHER;CMAKE_CXX_COMPILER_LAUNCHER" | |
CMAKE_C_COMPILER_LAUNCHER: "${{ env.SCCACHE_PATH }}" | |
CMAKE_CXX_COMPILER_LAUNCHER: "${{ env.SCCACHE_PATH }}" | |
run: | | |
cmake --version | |
# shellcheck disable=all | |
cmake . -B build ` | |
-G Ninja ` | |
-DCMAKE_POLICY_DEFAULT_CMP0141=NEW ` | |
-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded ` | |
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} ` | |
-DMLN_WITH_NODE=ON | |
- name: Build maplibre-native (MacOS/Linux) | |
if: runner.os == 'MacOS' || runner.os == 'Linux' | |
run: | | |
cmake --build build -j "$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null)" | |
- name: Build maplibre-native (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
cmake --build build | |
- name: Run render tests on macOS | |
id: render_tests | |
if: runner.os == 'macOS' | |
continue-on-error: ${{ runner.arch == 'X64' }} | |
run: ./build/mbgl-render-test-runner --manifestPath metrics/macos-xcode11-release-style.json | |
- name: Upload render test artifacts (MacOS) | |
if: runner.os == 'MacOS' && steps.render_tests.outcome == 'failure' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: render-query-test-results_${{ runner.os }}_${{ matrix.arch }} | |
path: metrics/macos-xcode11-release-style.html | |
- name: Test (Linux) | |
working-directory: platform/node | |
if: runner.os == 'Linux' | |
run: xvfb-run --auto-servernum npm test | |
- name: Test (MacOS) | |
if: runner.os == 'MacOS' | |
continue-on-error: true # flaky on CI | |
working-directory: platform/node | |
run: npm test | |
- name: Test (Windows) | |
if: runner.os == 'Windows' | |
working-directory: platform/node | |
env: | |
GALLIUM_DRIVER: "llvmpipe" | |
run: | | |
Invoke-WebRequest https://github.com/pal1000/mesa-dist-win/releases/download/24.2.5/mesa3d-24.2.5-release-msvc.7z -OutFile mesa3d.7z | |
& 'C:\Program Files\7-Zip\7z.exe' e -olib\node-v115 .\mesa3d.7z x64\opengl32.dll x64\libgallium_wgl.dll x64\libGLESv2.dll x64\libglapi.dll | |
npm test | |
# On PRs make sure that the npm package can be packaged. | |
- name: Pack | |
working-directory: platform/node | |
run: | | |
npm pack --dry-run |