Merge pull request #4466 from hummeltech/GitHubActionsVCPkgCache

Speed up the GitHub Actions CI jobs
This commit is contained in:
Artem Pavlenko 2024-06-26 10:29:52 +01:00 committed by GitHub
commit eb99057a47
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 113 additions and 150 deletions

View file

@ -1,93 +1,85 @@
name: "Run tests with coverage" name: Run tests with coverage
description: "Runs all mapnik tests with coverage" description: Runs all mapnik tests with coverage
inputs: inputs:
cmake-preset: cmake-preset:
description: "the used cmake preset" description: The used CMake preset
required: true required: true
runs: runs:
using: "composite" using: composite
steps: steps:
- name: Set proj enviroment - name: Set PROJ_LIB
shell: "pwsh" shell: bash
run: | run: |
$out = cmake --preset ${{ inputs.cmake-preset }} -N -L cmake --preset ${{ inputs.cmake-preset }} -N -L | grep -o "PROJ_LIB=.*" >> ${GITHUB_ENV}
$proj_lib = $out -match "PROJ_LIB=*"
echo ("PROJ_LIB=" + $proj_lib.Substring(11)) >> $env:GITHUB_ENV - name: Set TEST_WRAPPER (Windows)
if: runner.os == 'Windows'
shell: bash
run: |-
echo "TEST_WRAPPER=OpenCppCoverage \
--cover_children \
--export_type binary \
--modules '*.input' \
--modules '*libmapnik*' \
--modules 'mapnik*.exe' \
--quiet \
--sources '${{ github.workspace }}' \
--" >> ${GITHUB_ENV}
- name: Test - name: Test
shell: "bash" shell: bash
env: env:
UPDATE: "1" UPDATE: 1
run: | run: |
if [ "$RUNNER_OS" == "Windows" ]; then ${TEST_WRAPPER:-} ctest --preset ${{ inputs.cmake-preset }}
OpenCppCoverage --modules *libmapnik* --modules mapnik*.exe --modules *.input --sources ${{ github.workspace }} --export_type binary --cover_children -- ctest --preset ${{ inputs.cmake-preset }}
else
ctest --preset ${{ inputs.cmake-preset }}
fi
- name: Test visuals (windows) - name: Test visuals
continue-on-error: true continue-on-error: true
working-directory: build/out working-directory: build/out
shell: "pwsh" shell: bash
if: runner.os == 'Windows'
run: OpenCppCoverage --modules *libmapnik* --modules mapnik*.exe --modules *.input --sources ${{ github.workspace }} --export_type binary --input_coverage=${{ github.workspace }}/ctest.cov --cover_children -- .\mapnik-test-visual.exe -j (Get-CimInstance -ClassName Win32_ComputerSystem).NumberOfLogicalProcessors --output-dir ./visual-test-result
- name: Test visuals (linux & mac)
continue-on-error: true
working-directory: build/out
shell: "bash"
if: runner.os != 'Windows'
run: | run: |
if [ "$RUNNER_OS" == "Linux" ]; then ${TEST_WRAPPER:-} ./mapnik-test-visual -j ${CTEST_PARALLEL_LEVEL} --output-dir visual-test-result
./mapnik-test-visual -j $(nproc) --output-dir ./visual-test-result
else
./mapnik-test-visual -j $(sysctl -n hw.logicalcpu) --output-dir ./visual-test-result
fi
- name: Pack visual test results - name: Pack visual test results
working-directory: build/out working-directory: build/out
shell: "pwsh" shell: bash
run: tar cfvz visual-test-results.tar.gz ./visual-test-result
- name: Generate run guid
id: run-guid
shell: "pwsh"
run: | run: |
$guid = New-Guid tar -vzcf visual-test-results.tar.gz visual-test-result
echo ("GUID=" + $guid.toString()) >> $env:GITHUB_OUTPUT
- name: Upload visual test results - name: Upload visual test results
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: ${{ inputs.cmake-preset }}-visual-tests-${{ steps.run-guid.outputs.GUID }} name: ${{ inputs.cmake-preset }}-visual-tests-${{ github.sha }}
path: build/out/visual-test-results.tar.gz path: build/out/visual-test-results.tar.gz
- name: Run Benchmarks - name: Run Benchmarks (Linux & macOS)
working-directory: build/out working-directory: build/out
if: runner.os != 'Windows' if: runner.os != 'Windows'
shell: "pwsh" shell: bash
run: ./run_benchmarks run: |
./run_benchmarks
- name: Collect coverage (linux & macos) - name: Collect coverage (Linux & macOS)
working-directory: build working-directory: build
if: runner.os != 'Windows' if: runner.os != 'Windows'
shell: "bash" shell: bash
run: | run: |
if [ "$RUNNER_OS" == "macOS" ]; then if [ "${RUNNER_OS}" == "macOS" ]; then
LCOV_EXTRA_OPTIONS="--ignore-errors count,gcov,inconsistent,range,unused --keep-going" LCOV_EXTRA_OPTIONS="--ignore-errors count,gcov,inconsistent,range,unused --keep-going"
fi fi
lcov ${LCOV_EXTRA_OPTIONS:-} --directory . --capture --output-file coverage.info lcov ${LCOV_EXTRA_OPTIONS:-} --directory . --capture --output-file coverage.info
lcov ${LCOV_EXTRA_OPTIONS:-} --remove coverage.info '/usr/*' '*/vcpkg_installed/*' '/.cache/*' '*/test/*' --output-file coverage.info lcov ${LCOV_EXTRA_OPTIONS:-} --remove coverage.info '/usr/*' '*/vcpkg_installed/*' '/.cache/*' '*/test/*' --output-file coverage.info
lcov ${LCOV_EXTRA_OPTIONS:-} --list coverage.info lcov ${LCOV_EXTRA_OPTIONS:-} --list coverage.info
- name: Upload coverage to Codecov (linux & macos) - name: Upload coverage to Codecov (Linux & macOS)
if: runner.os != 'Windows' if: runner.os != 'Windows'
uses: codecov/codecov-action@v4 uses: codecov/codecov-action@v4
with: with:
files: build/coverage.info files: build/coverage.info
- name: Upload coverage to Codecov (windows) - name: Upload coverage to Codecov (Windows)
if: runner.os == 'Windows' if: runner.os == 'Windows'
uses: codecov/codecov-action@v4 uses: codecov/codecov-action@v4
with: with:
files: build/out/mapnik-test-visual.cov files: ctest.cov,build/out/mapnik-test-visual.cov

View file

@ -1,50 +0,0 @@
name: "Setup vcpkg"
description: "Sets up vcpkg"
inputs:
vcpkg-sha:
description: "vcpkg git sha to use"
required: true
nuget-source:
description: "The nuget json"
required: true
nuget-username:
description: "The username for the nuget repository"
required: true
nuget-pat:
description: "The PAT for the nuget repository"
required: true
mono:
description: "mono exec"
required: true
runs:
using: "composite"
steps:
- name: checkout vcpkg
uses: actions/checkout@v4
with:
repository: "microsoft/vcpkg"
ref: ${{ inputs.vcpkg-sha }}
path: vcpkg
- name: "Setup vcpkg"
shell: bash
run: ./vcpkg/bootstrap-vcpkg.sh
- name: "Setup NuGet Credentials"
shell: "bash"
run: >
${{ inputs.mono }} `./vcpkg/vcpkg fetch nuget | tail -n 1`
sources add
-source "${{ inputs.nuget-source }}"
-storepasswordincleartext
-name "GitHub"
-username "${{ inputs.nuget-username }}"
-password "${{ inputs.nuget-pat }}"
- name: "Setup NuGet apikey"
shell: "bash"
run: >
${{ inputs.mono }} `./vcpkg/vcpkg fetch nuget | tail -n 1`
setapikey "${{ inputs.nuget-pat }}" -Source "${{ inputs.nuget-source }}"

View file

@ -9,8 +9,8 @@ on:
- "no-ci-*" - "no-ci-*"
env: env:
VCPKG_BINARY_SOURCES: "clear;nuget,GitHub,readwrite" VCPKG_BINARY_SOURCES: clear;x-gha,readwrite
VCPKG_NUGET_REPOSITORY: https://github.com/mathisloge/vcpkg-nuget.git VCPKG_RELEASE: 2024.06.15
jobs: jobs:
checkSource: checkSource:
@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
with: with:
python-version: '3.10' python-version: "3.10"
- uses: pre-commit/action@v3.0.1 - uses: pre-commit/action@v3.0.1
buildAndTest: buildAndTest:
@ -31,6 +31,7 @@ jobs:
(C++ ${{ matrix.cxx-standard }}) (C++ ${{ matrix.cxx-standard }})
${{ startsWith(matrix.os, 'macos-') && (matrix.os == 'macos-14' && '(ARM64)' || '(AMD64)') || '' }} ${{ startsWith(matrix.os, 'macos-') && (matrix.os == 'macos-14' && '(ARM64)' || '(AMD64)') || '' }}
needs: checkSource needs: checkSource
runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -40,74 +41,94 @@ jobs:
- windows-2022 - windows-2022
cxx-standard: cxx-standard:
- 17 - 17
include:
- os: macos-14
mono: mono
- os: ubuntu-22.04
mono: mono
- os: windows-2022
runs-on: ${{ matrix.os }}
steps: steps:
- name: "Install required system packages" - name: Checkout Mapnik
shell: bash
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
choco install ninja OpenCppCoverage
echo "C:\Program Files\OpenCppCoverage" >> ${GITHUB_PATH}
elif [ "$RUNNER_OS" == "Linux" ]; then
sudo apt update
sudo apt install -y gperf libxxf86vm-dev ninja-build postgresql-client lcov autoconf-archive
else
brew install automake ninja lcov autoconf-archive
fi
- uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'
- name: checkout mapnik
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
submodules: "recursive" submodules: recursive
- name: setup vcpkg - name: Checkout vcpkg
uses: ./.github/actions/setup_vcpkg uses: actions/checkout@v4
with: with:
vcpkg-sha: ad25766aefb5313b6bc4e2a4b78a2946f84fbf66 path: vcpkg
nuget-source: https://nuget.pkg.github.com/mapnik/index.json ref: ${{ env.VCPKG_RELEASE }}
nuget-username: ${{ github.actor }} repository: microsoft/vcpkg
nuget-pat: ${{ secrets.GITHUB_TOKEN }}
mono: ${{ matrix.mono }}
- name: Set PRESET environment variable to lower case runner OS - name: Export GitHub Actions cache environment variables
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: Install required system packages
shell: bash shell: bash
run: | run: |
LC_RUNNER_OS=$(echo "${RUNNER_OS}" | perl -ne "print lc") if [ "${RUNNER_OS}" == "Linux" ]; then
if [ "${RUNNER_OS}" == "macOS" ]; then sudo apt-get update
MACOS_ARCH=${{ matrix.os == 'macos-14' && 'arm64' || 'x64' }} sudo apt-get -y install \
echo "PRESET=${LC_RUNNER_OS}-ci-${MACOS_ARCH}" >> ${GITHUB_ENV} autoconf \
else autoconf-archive \
echo "PRESET=${LC_RUNNER_OS}-ci" >> ${GITHUB_ENV} 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}
fi fi
- name: Ensure libtool is installed on macOS - 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 shell: bash
run: brew install libtool run: |
if: runner.os == 'macOS' 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}
- name: Configure CMake - name: Configure CMake
shell: bash shell: bash
run: | run: |
cmake \ cmake \
-DBUILD_SHARED_LIBS:BOOL='ON' \ -DBUILD_SHARED_LIBS:BOOL=ON \
-DCMAKE_CXX_STANDARD=${{ matrix.cxx-standard }} \ -DCMAKE_CXX_STANDARD:STRING=${{ matrix.cxx-standard }} \
-DUSE_MEMORY_MAPPED_FILE:BOOL='ON' \ -DUSE_MEMORY_MAPPED_FILE:BOOL=ON \
-LA \ -LA \
--preset ${{ env.PRESET }} --preset ${PRESET}
- name: Build - name: Build
run: cmake --build --preset ${{ env.PRESET }} shell: bash
run: |
cmake \
--build \
--preset ${PRESET}
- name: Run Tests - name: Run Tests
uses: ./.github/actions/run_tests uses: ./.github/actions/run_tests