|
| 1 | +# |
| 2 | +# Copyright (c) 2025 Gennaro Prota |
| 3 | +# |
| 4 | +# Distributed under the Boost Software License, Version 1.0. |
| 5 | +# (See accompanying file LICENSE_1_0.txt or copy at |
| 6 | +# https://www.boost.org/LICENSE_1_0.txt) |
| 7 | +# |
| 8 | +# Official repository: https://github.com/cppalliance/handlebars |
| 9 | +# |
| 10 | + |
| 11 | +name: Continuous integration |
| 12 | + |
| 13 | +on: |
| 14 | + push: |
| 15 | + branches: [master, develop, '*'] |
| 16 | + tags: ["v*.*.*"] |
| 17 | + pull_request: |
| 18 | + branches: [master, develop] |
| 19 | + |
| 20 | +concurrency: |
| 21 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 22 | + cancel-in-progress: true |
| 23 | + |
| 24 | +jobs: |
| 25 | + matrix: |
| 26 | + name: Generate test matrix |
| 27 | + runs-on: ubuntu-24.04 |
| 28 | + outputs: |
| 29 | + matrix: ${{ steps.cpp-matrix.outputs.matrix }} |
| 30 | + steps: |
| 31 | + - name: Checkout |
| 32 | + uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: Generate test matrix |
| 35 | + id: cpp-matrix |
| 36 | + uses: alandefreitas/cpp-actions/[email protected] |
| 37 | + with: |
| 38 | + compilers: | |
| 39 | + gcc >=15 |
| 40 | + clang >=19 |
| 41 | + msvc >=14.40 |
| 42 | + apple-clang * |
| 43 | + standards: '23' |
| 44 | + build-types: | |
| 45 | + gcc: Release |
| 46 | + gcc Coverage: Release |
| 47 | + clang: Release |
| 48 | + apple-clang: Release |
| 49 | + msvc: RelWithDebInfo |
| 50 | + msvc Optimized-Debug: Debug |
| 51 | + ccflags: | |
| 52 | + msvc Optimized-Debug: /Ob1 /O2 /Zi |
| 53 | + cxxflags: | |
| 54 | + msvc Optimized-Debug: /Ob1 /O2 /Zi |
| 55 | + containers: | |
| 56 | + clang: ubuntu:24.04 |
| 57 | + runs-on: | |
| 58 | + msvc: windows-2022 |
| 59 | + clang: ubuntu-24.04 |
| 60 | + apple-clang: macos-15 |
| 61 | + install: | |
| 62 | + gcc: git build-essential libc++-dev libc++abi-dev pkg-config ninja-build curl zip unzip tar |
| 63 | + clang: git build-essential libc++-dev libc++abi-dev pkg-config ninja-build curl zip unzip tar g++-14=14.2.0-4ubuntu2~24.04 clang libclang-dev libclang-cpp-dev libc++-dev libc++abi-dev libc6-dev |
| 64 | + extra-values: | |
| 65 | + use-libcxx: {{#if (ieq compiler 'clang')}}true{{else}}false{{/if}} |
| 66 | + libcxx-runtimes: libcxx{{#if (ne compiler 'msvc')}};libcxxabi{{/if}} |
| 67 | + warning-flags: {{#if (eq compiler 'msvc') }}/WX /W4 {{else}}-Werror -Wall {{/if}} |
| 68 | + common-flags-base: {{#if (ieq compiler 'clang')}}-m64 -pthread {{/if}} |
| 69 | + common-flags: {{{ common-flags-base }}}{{#if msan }}-fsanitize-memory-track-origins {{/if}} |
| 70 | + common-ccflags: {{{ ccflags }}} {{{ common-flags }}} |
| 71 | + output-file: matrix.json |
| 72 | + |
| 73 | + build: |
| 74 | + name: ${{ matrix.name }} |
| 75 | + needs: matrix |
| 76 | + runs-on: ${{ matrix.runs-on }} |
| 77 | + container: ${{ matrix.container }} |
| 78 | + strategy: |
| 79 | + fail-fast: false |
| 80 | + matrix: |
| 81 | + include: ${{ fromJSON(needs.matrix.outputs.matrix) }} |
| 82 | + defaults: |
| 83 | + run: |
| 84 | + shell: bash |
| 85 | + steps: |
| 86 | + - name: Checkout |
| 87 | + uses: actions/checkout@v4 |
| 88 | + |
| 89 | + - name: Setup C++ |
| 90 | + id: setup-cpp |
| 91 | + uses: alandefreitas/cpp-actions/[email protected] |
| 92 | + with: |
| 93 | + compiler: ${{ matrix.compiler }} |
| 94 | + version: ${{ matrix.version }} |
| 95 | + |
| 96 | + - name: Install dependencies |
| 97 | + if: matrix.install != '' |
| 98 | + uses: alandefreitas/cpp-actions/[email protected] |
| 99 | + with: |
| 100 | + apt-get: ${{ matrix.install }} |
| 101 | + |
| 102 | + - name: Install Boost.JSON with vcpkg |
| 103 | + run: | |
| 104 | + git clone https://github.com/microsoft/vcpkg.git |
| 105 | + ./vcpkg/bootstrap-vcpkg.sh || ./vcpkg/bootstrap-vcpkg.bat |
| 106 | + ./vcpkg/vcpkg install boost-json |
| 107 | +
|
| 108 | + - name: Resolved Matrix |
| 109 | + id: rmatrix |
| 110 | + run: | |
| 111 | + set -euvx |
| 112 | +
|
| 113 | + common_cxxflags_base="" |
| 114 | + if [[ "${{ matrix.use-libcxx }}" == 'true' ]]; then |
| 115 | + common_cxxflags_base="-stdlib=libc++" |
| 116 | + fi |
| 117 | + echo "common-cxxflags-base=$common_cxxflags_base" >> $GITHUB_OUTPUT |
| 118 | +
|
| 119 | + common_cxxflags="$common_cxxflags_base ${{ matrix.cxxflags }} ${{ matrix.common-flags }}" |
| 120 | + echo "common-cxxflags=$common_cxxflags" >> $GITHUB_OUTPUT |
| 121 | +
|
| 122 | + common_ldflags="${{ matrix.ldflags }}" |
| 123 | + if [[ "${{ matrix.use-libcxx }}" == 'true' ]]; then |
| 124 | + common_ldflags="$common_ldflags -stdlib=libc++" |
| 125 | + fi |
| 126 | + if [[ "${{ matrix.ubsan }}" == 'true' ]]; then |
| 127 | + common_ldflags="$common_ldflags -fsanitize=undefined" |
| 128 | + fi |
| 129 | + if [[ "${{ matrix.asan }}" == 'true' ]]; then |
| 130 | + common_ldflags="$common_ldflags -fsanitize=address" |
| 131 | + fi |
| 132 | + if [[ "${{ matrix.msan }}" == 'true' ]]; then |
| 133 | + common_ldflags="$common_ldflags -fsanitize=memory" |
| 134 | + fi |
| 135 | + echo "common-ldflags=$common_ldflags" >> $GITHUB_OUTPUT |
| 136 | +
|
| 137 | + - name: Configure & build |
| 138 | + uses: alandefreitas/cpp-actions/[email protected] |
| 139 | + with: |
| 140 | + cmake-version: '>=3.26' |
| 141 | + source-dir: . |
| 142 | + build-dir: build |
| 143 | + generator: Ninja |
| 144 | + build-type: ${{ matrix.build-type }} |
| 145 | + cxxstd: ${{ matrix.cxxstd }} |
| 146 | + cc: ${{ steps.setup-cpp.outputs.cc }} |
| 147 | + cxx: ${{ steps.setup-cpp.outputs.cxx }} |
| 148 | + run-tests: true |
| 149 | + install: false |
| 150 | + trace-commands: true |
| 151 | + extra-args: > |
| 152 | + -D CMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake |
| 153 | + -D BOOST_HANDLEBARS_BUILD_TESTS=ON |
| 154 | + -D CMAKE_C_COMPILER="${{ steps.setup-cpp.outputs.cc }}" |
| 155 | + -D CMAKE_CXX_COMPILER="${{ steps.setup-cpp.outputs.cxx }}" |
| 156 | + -D CMAKE_C_FLAGS="${{ steps.rmatrix.outputs.common-cxxflags }}" |
| 157 | + -D CMAKE_CXX_FLAGS="${{ steps.rmatrix.outputs.common-cxxflags }}" |
| 158 | + -D CMAKE_SHARED_LINKER_FLAGS="${{ steps.rmatrix.outputs.common-ldflags }}" |
| 159 | + -D CMAKE_EXE_LINKER_FLAGS="${{ steps.rmatrix.outputs.common-ldflags }}" |
| 160 | +
|
| 161 | + - name: Upload artifacts |
| 162 | + if: ${{ matrix.is-main }} |
| 163 | + uses: actions/upload-artifact@v4 |
| 164 | + with: |
| 165 | + name: handlebars-${{ matrix.compiler }} |
| 166 | + path: build |
0 commit comments