maplibre_native 0.9.0

Rust bindings to the MapLibre Native map rendering engine
Documentation
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  workflow_dispatch:

# Cancel superseded runs on the same PR
concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

defaults:
  run:
    shell: bash

env:
  # Headless OpenGL EGL: render without an X server / display surface, and force
  # the llvmpipe software rasterizer (CI runners have no GPU). Harmless for the
  # other backends.
  EGL_PLATFORM: surfaceless
  LIBGL_ALWAYS_SOFTWARE: "1"

jobs:
  lint:
    name: Lint
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          persist-credentials: false
          submodules: true
      - if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
        uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
      - if: github.event_name == 'pull_request'
        uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23
        with:
          max-size: 2G
      - if: github.event_name == 'pull_request'
        run: echo "MLN_CMAKE_CXX_LAUNCHER=ccache" >> $GITHUB_ENV
      - run: echo "MLN_PRECOMPILE=0" >> $GITHUB_ENV
      - run: echo "MLN_CORE_LIBRARY_USE_AMALGAM=0" >> $GITHUB_ENV
      - run: rustup update stable && rustup default stable && rustup component add rustfmt && rustup component add clippy
      - uses: taiki-e/install-action@07b4745e0c39a41822af610387492e3e53aa222b # v2.83.4
        with: { tool: "just" }
      - run: just env-info install-dependencies 'vulkan'
      - run: just ci-lint

  slint-example:
    name: Build slint example ${{ matrix.runs-on }} - ${{ matrix.backend }} - Precompiled ${{ matrix.precompiled }}
    runs-on: ${{ matrix.runs-on }}
    permissions:
      contents: read
    strategy:
      fail-fast: false
      matrix:
        include:
          # Linux x86
          - runs-on: ubuntu-latest
            precompiled: 0
            amalgam: 0
          # Linux ARM
          - runs-on: ubuntu-24.04-arm
            precompiled: 0
            amalgam: 0
          # macOS ARM
          - runs-on: macos-latest
            precompiled: 0
            amalgam: 0
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          persist-credentials: false
          submodules: true
      - if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
        uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
      - uses: taiki-e/install-action@07b4745e0c39a41822af610387492e3e53aa222b # v2.83.4
        with: { tool: "just" }
      - run: echo "MLN_PRECOMPILE=${{ matrix.precompiled }}" >> $GITHUB_ENV
      - run: echo "MLN_CORE_LIBRARY_USE_AMALGAM=${{ matrix.amalgam }}" >> $GITHUB_ENV
      - run: just env-info install-dependencies 'wgpu'
      - run: rustup update stable && rustup default stable
      - name: Build Slint example
        run: just build-example_slint

  test:
    name: Test ${{ matrix.runs-on }} - ${{ matrix.backend }} - Precompiled ${{ matrix.precompiled }}
    runs-on: ${{ matrix.runs-on }}
    permissions:
      contents: read
    strategy:
      fail-fast: false
      matrix:
        include:
          # Linux x86
          - runs-on: ubuntu-latest
            backend: vulkan
            precompiled: 0
            amalgam: 0
          - runs-on: ubuntu-latest
            backend: glx
            precompiled: 0
            amalgam: 0
          - runs-on: ubuntu-latest
            backend: vulkan
            precompiled: 1 # also cover the prebuilt amalgam path
            amalgam: 1
          - runs-on: ubuntu-latest
            backend: opengl
            precompiled: 0
            amalgam: 0
          # Linux ARM
          - runs-on: ubuntu-24.04-arm
            backend: vulkan
            precompiled: 0
            amalgam: 0
          # macOS ARM
          - runs-on: macos-latest
            backend: metal
            precompiled: 0
            amalgam: 0
          - runs-on: macos-latest
            backend: vulkan
            precompiled: 0
            amalgam: 0
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          persist-credentials: false
          submodules: true
      - if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
        uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
      - if: github.event_name == 'pull_request'
        uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23
        with:
          max-size: 2G
      - if: github.event_name == 'pull_request'
        run: echo "MLN_CMAKE_CXX_LAUNCHER=ccache" >> $GITHUB_ENV
      - uses: taiki-e/install-action@07b4745e0c39a41822af610387492e3e53aa222b # v2.83.4
        with: { tool: "just" }
      - run: echo "MLN_PRECOMPILE=${{ matrix.precompiled }}" >> $GITHUB_ENV
      - run: echo "MLN_CORE_LIBRARY_USE_AMALGAM=${{ matrix.amalgam }}" >> $GITHUB_ENV
      - run: just env-info install-dependencies '${{ matrix.backend }}'
      - if: startsWith(matrix.runs-on, 'macos') && matrix.backend == 'vulkan'
        run: |
          echo "VK_ICD_FILENAMES=$(brew --prefix molten-vk)/etc/vulkan/icd.d/MoltenVK_icd.json" >> $GITHUB_ENV
          echo "DYLD_LIBRARY_PATH=$(brew --prefix vulkan-loader)/lib" >> $GITHUB_ENV
      - run: rustup update stable && rustup default stable
      - name: Run CI tests (Linux OpenGL GLX via Xvfb)
        if: startsWith(matrix.runs-on, 'ubuntu') && matrix.backend == 'glx'
        run: xvfb-run -a --server-args="-screen 0 1280x1024x24" just ci-test ${{ matrix.backend }}
      - name: Run CI tests
        if: ${{ !(startsWith(matrix.runs-on, 'ubuntu') && matrix.backend == 'glx') }}
        run: just ci-test ${{ matrix.backend }}

  build-msrv:
    name: Build MSRV ${{ matrix.runs-on }} - ${{ matrix.backend }}
    runs-on: ${{ matrix.runs-on }}
    permissions:
      contents: read
    strategy:
      fail-fast: false
      matrix:
        include:
          # MSRV mainly checks Rust/toolchain compatibility.
          # Backend-specific behavior is covered by the stable jobs above, so
          # one Linux leg and one macOS leg are enough to cover build.rs target_os branches.
          - runs-on: ubuntu-latest
            backend: vulkan
            precompiled: 0
            amalgam: 0
          - runs-on: macos-latest
            backend: metal
            precompiled: 0
            amalgam: 0
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          persist-credentials: false
          submodules: true
      - if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
        uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
      - if: github.event_name == 'pull_request'
        uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23
        with:
          max-size: 2G
      - if: github.event_name == 'pull_request'
        run: echo "MLN_CMAKE_CXX_LAUNCHER=ccache" >> $GITHUB_ENV
      - uses: taiki-e/install-action@07b4745e0c39a41822af610387492e3e53aa222b # v2.83.4
        with: { tool: "just" }
      - run: echo "MLN_PRECOMPILE=${{ matrix.precompiled }}" >> $GITHUB_ENV
      - run: echo "MLN_CORE_LIBRARY_USE_AMALGAM=${{ matrix.amalgam }}" >> $GITHUB_ENV
      - run: just env-info install-dependencies '${{ matrix.backend }}'
      - name: Read MSRV
        id: msrv
        run: echo "value=$(just get-msrv)" >> $GITHUB_OUTPUT
      - name: Install MSRV Rust ${{ steps.msrv.outputs.value }}
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: ${{ steps.msrv.outputs.value }}
      - name: Build with MSRV
        run: just ci_mode=0 build-msrv ${{ matrix.backend }} # Ignore warnings in MSRV

  # This final step is needed to mark the whole workflow as successful
  # Don't change its name - it is used by the merge protection rules
  ci-passed:
    needs: [lint, test, build-msrv, slint-example]
    if: always()
    runs-on: ubuntu-latest
    permissions: {}
    steps:
      - name: Result of the needed steps
        run: echo "${{ toJSON(needs) }}"
      - if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
        run: exit 1

  # Release unpublished packages or create a PR with changes
  release-plz:
    needs: [ci-passed]
    if: |
      always()
      && needs.ci-passed.result == 'success'
      && github.event_name == 'push'
      && github.ref == 'refs/heads/main'
      && github.repository_owner == 'maplibre'
    runs-on: ubuntu-latest
    permissions:
      contents: write
      id-token: write
    concurrency:
      group: release-plz-${{ github.ref }}
      cancel-in-progress: false
    env:
      MLN_PRECOMPILE: 1
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          fetch-depth: 0
          persist-credentials: false
          submodules: true
      - uses: dtolnay/rust-toolchain@stable
      - name: Publish to crates.io if crate's version is newer
        uses: release-plz/action@2eb1d8bcb770b4c48ccfaad919734b38b51958c9 # v0.5.131
        id: release
        with: { command: release }
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - if: ${{ steps.release.outputs.releases_created == 'false' }}
        name: If version is the same, create a PR proposing new version and changelog for the next release
        uses: release-plz/action@2eb1d8bcb770b4c48ccfaad919734b38b51958c9 # v0.5.131
        with: { command: release-pr }
        env:
          GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}