mapnik/.github/workflows/build_and_test.yml

137 lines
4.1 KiB
YAML
Raw Permalink Normal View History

2022-11-21 22:56:50 +01:00
name: Build and Test
on:
push:
branches:
- "*"
pull_request:
branches-ignore:
- "no-ci-*"
env:
2024-06-22 20:59:01 +02:00
VCPKG_BINARY_SOURCES: clear;x-gha,readwrite
VCPKG_RELEASE: 2024.06.15
2022-11-21 22:56:50 +01:00
jobs:
checkSource:
name: Check Source Code
2024-06-14 10:41:49 +02:00
runs-on: ubuntu-22.04
2022-11-21 22:56:50 +01:00
steps:
2024-03-12 14:24:34 +01:00
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
2022-11-21 22:56:50 +01:00
with:
2024-06-22 20:59:01 +02:00
python-version: "3.10"
2024-03-12 14:28:14 +01:00
- uses: pre-commit/action@v3.0.1
2022-11-21 22:56:50 +01:00
buildAndTest:
name: >-
Build & Test
(${{ matrix.os }})
(C++ ${{ matrix.cxx-standard }})
${{ startsWith(matrix.os, 'macos-') && (matrix.os == 'macos-14' && '(ARM64)' || '(AMD64)') || '' }}
needs: checkSource
2024-06-22 20:59:01 +02:00
runs-on: ${{ matrix.os }}
2022-11-21 22:56:50 +01:00
strategy:
2022-11-26 16:40:16 +01:00
fail-fast: false
2022-11-21 22:56:50 +01:00
matrix:
os:
- macos-14
2024-06-14 10:41:49 +02:00
- ubuntu-22.04
- windows-2022
cxx-standard:
- 17
2022-11-21 22:56:50 +01:00
steps:
2024-06-22 20:59:01 +02:00
- name: Checkout Mapnik
uses: actions/checkout@v4
with:
submodules: recursive
2024-06-22 20:59:01 +02:00
- name: Checkout vcpkg
2024-03-12 14:24:34 +01:00
uses: actions/checkout@v4
2022-11-21 22:56:50 +01:00
with:
2024-06-22 20:59:01 +02:00
path: vcpkg
ref: ${{ env.VCPKG_RELEASE }}
repository: microsoft/vcpkg
2022-11-21 22:56:50 +01:00
2024-06-22 20:59:01 +02:00
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
2022-11-21 22:56:50 +01:00
with:
2024-06-22 20:59:01 +02:00
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
2022-11-21 22:56:50 +01:00
2024-06-22 20:59:01 +02:00
- name: Install required system packages
shell: bash
2022-11-21 22:56:50 +01:00
run: |
2024-06-22 20:59:01 +02:00
if [ "${RUNNER_OS}" == "Linux" ]; then
sudo apt-get update
sudo apt-get -y install \
autoconf \
autoconf-archive \
automake \
gperf \
lcov \
libxxf86vm-dev \
ninja-build \
postgresql-client
elif [ "${RUNNER_OS}" == "macOS" ]; then
brew install \
autoconf \
autoconf-archive \
automake \
lcov \
libtool \
ninja \
vcpkg
elif [ "${RUNNER_OS}" == "Windows" ]; then
choco install \
ninja \
OpenCppCoverage
echo "C:\Program Files\OpenCppCoverage" >> ${GITHUB_PATH}
2024-05-05 04:59:44 +02:00
fi
2022-11-21 22:56:50 +01:00
2024-06-22 20:59:01 +02:00
- name: Enable Developer Command Prompt (Windows)
uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'
- name: Set CMAKE_BUILD_PARALLEL_LEVEL, CTEST_PARALLEL_LEVEL & PRESET
shell: bash
2024-06-22 20:59:01 +02:00
run: |
PRESET=$(echo "${RUNNER_OS}" | perl -ne "print lc")-ci
if [ "${RUNNER_OS}" == "Linux" ]; then
echo "CMAKE_BUILD_PARALLEL_LEVEL=$(nproc)" >> ${GITHUB_ENV}
echo "CTEST_PARALLEL_LEVEL=$(nproc)" >> ${GITHUB_ENV}
elif [ "${RUNNER_OS}" == "macOS" ]; then
echo "CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu)" >> ${GITHUB_ENV}
echo "CTEST_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu)" >> ${GITHUB_ENV}
PRESET=${PRESET}-${{ matrix.os == 'macos-14' && 'arm64' || 'x64' }}
elif [ "${RUNNER_OS}" == "Windows" ]; then
echo "CMAKE_BUILD_PARALLEL_LEVEL=$(pwsh -Command '(Get-CimInstance -ClassName Win32_ComputerSystem).NumberOfLogicalProcessors')" >> ${GITHUB_ENV}
echo "CTEST_PARALLEL_LEVEL=$(pwsh -Command '(Get-CimInstance -ClassName Win32_ComputerSystem).NumberOfLogicalProcessors')" >> ${GITHUB_ENV}
fi
echo "PRESET=${PRESET}" >> ${GITHUB_ENV}
2022-11-21 22:56:50 +01:00
- name: Configure CMake
shell: bash
run: |
cmake \
2024-06-22 20:59:01 +02:00
-DBUILD_SHARED_LIBS:BOOL=ON \
-DCMAKE_CXX_STANDARD:STRING=${{ matrix.cxx-standard }} \
-DUSE_MEMORY_MAPPED_FILE:BOOL=ON \
-LA \
--preset ${PRESET}
2022-11-21 22:56:50 +01:00
- name: Build
2024-06-22 20:59:01 +02:00
shell: bash
run: |
cmake \
--build \
--preset ${PRESET}
2022-11-21 22:56:50 +01:00
- name: Run Tests
uses: ./.github/actions/run_tests
with:
cmake-preset: ${{ env.PRESET }}