Skip to content

Base implementation #12

Base implementation

Base implementation #12

Workflow file for this run

name: Build
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
env:
CMAKE_BUILD_TYPE: Release
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}\vcpkg-cache
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}\vcpkg-cache,readwrite
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
arch: x64
triplet: x64-windows
generator: "Visual Studio 17 2022"
cmake-arch: "-A x64"
artifact: windows-x64
lib-path: build/bin/Release/CesiumNativeC.*
skip-tests: false
- os: windows-latest
arch: arm64
triplet: arm64-windows
generator: "Visual Studio 17 2022"
cmake-arch: "-A ARM64"
artifact: windows-arm64
lib-path: build/bin/Release/CesiumNativeC.*
skip-tests: true # cross-compiled, can't run on x64
- os: ubuntu-latest
arch: x64
triplet: x64-linux
generator: Ninja
cmake-arch: ""
artifact: linux-x64
lib-path: build/bin/libCesiumNativeC.*
skip-tests: false
- os: ubuntu-24.04-arm
arch: arm64
triplet: arm64-linux
generator: Ninja
cmake-arch: ""
artifact: linux-arm64
lib-path: build/bin/libCesiumNativeC.*
skip-tests: false
- os: macos-14
arch: arm64
triplet: arm64-osx
generator: Ninja
cmake-arch: ""
artifact: osx-arm64
lib-path: build/bin/libCesiumNativeC.*
skip-tests: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.artifact }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: recursive
# ---- vcpkg binary caching ----
- name: Export GitHub Actions cache variables
uses: actions/github-script@v8
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
# ---- Install platform tools ----
- name: Install tools (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y ninja-build nasm pkg-config
- name: Install tools (macOS)
if: runner.os == 'macOS'
run: brew install ninja nasm
# ---- vcpkg ----
- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: 62159a45e18f3a9ac0548628dcaf74fcb60c6ff9
# ---- Cache vcpkg artifacts ----
- name: Set up binary cache
uses: actions/cache@v5.0.3
with:
path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
key: ${{ runner.os }}-vcpkg-binary-cache-${{ hashFiles('vcpkg*.json') }}
restore-keys: |
${{ runner.os }}-vcpkg-binary-cache-
# ---- Build ----
- name: CMake configure
run: >
cmake -S . -B build
-G "${{ matrix.generator }}" ${{ matrix.cmake-arch }}
-DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }}
-DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }}
- name: CMake build
run: cmake --build build --config ${{ env.CMAKE_BUILD_TYPE }} --parallel
# ---- Test ----
- name: Run tests
if: ${{ !matrix.skip-tests }}
run: cmake --build build --config ${{ env.CMAKE_BUILD_TYPE }} --target CesiumNativeCTests --parallel && ctest --test-dir build --build-config ${{ env.CMAKE_BUILD_TYPE }} --output-on-failure --no-tests=error
env:
# Offline tests only in CI — no Ion token
CESIUM_ION_TOKEN: ""
# ---- Upload ----
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: CesiumNativeC-${{ matrix.artifact }}
path: |
${{ matrix.lib-path }}
build/lib/*CesiumNativeC*
if-no-files-found: error