Include compiler in protobuf cache key #701
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: [push, pull_request] | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-24.04] | |
| compiler: [clang] | |
| protobuf_lib: [protobuf-cpp] | |
| valgrind: [valgrind] | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v4 | |
| - name: Cache protobuf library | |
| if: matrix.protobuf_lib == 'protobuf-cpp' | |
| id: cache-protobuf | |
| uses: actions/cache@v4 | |
| with: | |
| path: protobuf-25.1 | |
| key: ${{ runner.os }}-${{ matrix.compiler }}-protobuf-25.1 | |
| - name: Build protobuf library | |
| if: matrix.protobuf_lib == 'protobuf-cpp' && steps.cache-protobuf.outputs.cache-hit != 'true' | |
| run: | | |
| git clone --depth 1 --branch v25.1 https://github.com/protocolbuffers/protobuf.git protobuf-25.1 | |
| cd protobuf-25.1 | |
| git submodule update --init --recursive | |
| cmake . | |
| cmake --build . --parallel 10 | |
| - name: Install protobuf library | |
| if: matrix.protobuf_lib == 'protobuf-cpp' | |
| run: | | |
| cd protobuf-25.1 | |
| sudo make install | |
| sudo ldconfig | |
| - name: Install Valgrind | |
| if: matrix.valgrind == 'valgrind' | |
| run: sudo apt update && sudo apt install -y valgrind libstdc++-14-dev | |
| - name: Determine make flags | |
| id: make_flags | |
| run: | | |
| if [ "$PROTOBUF_LIB" = protobuf-cpp ] | |
| then | |
| echo "::set-output name=proto_flags::USE_PROTOBUF_CPP=1" | |
| else | |
| echo "::set-output name=proto_flags::" | |
| fi | |
| if [ "$COMPILER" = clang ] | |
| then | |
| echo "::set-output name=compiler_flags::CC=clang CXX=clang" | |
| elif [ "$COMPILER" = gcc ] | |
| then | |
| echo "::set-output name=compiler_flags::CC=gcc CXX=g++" | |
| else | |
| echo "::set-output name=compiler_flags::" | |
| fi | |
| if [ "$VALGRIND" = valgrind ] | |
| then | |
| echo "::set-output name=debug_flags::VALGRIND=1 DEBUG=1" | |
| else | |
| echo "::set-output name=debug_flags::" | |
| fi | |
| env: | |
| PROTOBUF_LIB: ${{ matrix.protobuf_lib }} | |
| COMPILER: ${{ matrix.compiler }} | |
| VALGRIND: ${{ matrix.valgrind }} | |
| - name: Build and run tests | |
| run: make $FLAGS | |
| env: | |
| FLAGS: ${{ format('{0} {1} {2}', steps.make_flags.outputs.proto_flags, steps.make_flags.outputs.compiler_flags, steps.make_flags.outputs.debug_flags) }} | |
| build_macos: | |
| runs-on: macos-latest | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v4 | |
| - name: Build and run tests | |
| run: make | |
| build_windows_msvc: | |
| runs-on: windows-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| arch: [x64, x86] | |
| steps: | |
| - name: Configure MSVC developer console | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: ${{ matrix.arch }} | |
| - name: Check out code | |
| uses: actions/checkout@v4 | |
| - name: Build and run tests | |
| run: nmake /F Makefile.msvc | |
| build_windows_msys2: | |
| runs-on: windows-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| sys: [mingw64, mingw32, ucrt64, clang64] | |
| steps: | |
| - name: Set up MSYS2 and compiler | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: ${{matrix.sys}} | |
| pacboy: >- | |
| toolchain:p | |
| install: >- | |
| make | |
| diffutils | |
| - name: Check out code | |
| uses: actions/checkout@v4 | |
| - name: Build and run tests | |
| shell: msys2 {0} | |
| run: | | |
| make |