Harden server network exposure defaults #116
Workflow file for this run
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: CMake on macOS & Ubuntu | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| build_type: [Debug, Release] | |
| c_compiler: [gcc, clang] | |
| include: | |
| # Ubuntu combos | |
| - os: ubuntu-latest | |
| c_compiler: gcc | |
| cpp_compiler: g++ | |
| # macOS uses Apple Clang | |
| - os: macos-latest | |
| c_compiler: clang | |
| cpp_compiler: clang++ | |
| exclude: | |
| # Prevent gcc on macOS (Apple Clang presents as gcc, but we want explicit clang) | |
| - os: macos-latest | |
| c_compiler: gcc | |
| - os: ubuntu-latest | |
| c_compiler: clang | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| # Ensure toolchain availability per-OS | |
| - name: Install toolchain (Ubuntu/clang only) | |
| if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'clang' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang | |
| - name: Ensure CMake on macOS | |
| if: matrix.os == 'macos-latest' | |
| run: | | |
| if ! command -v cmake >/dev/null 2>&1; then | |
| brew update | |
| brew install cmake | |
| brew install pipx | |
| fi | |
| - name: Show tool versions | |
| run: | | |
| echo "CMake: $(cmake --version | head -n1)" | |
| echo "CC: ${{ matrix.c_compiler }} -> $(which ${{ matrix.c_compiler }})" | |
| echo "CXX: ${{ matrix.cpp_compiler }} -> $(which ${{ matrix.cpp_compiler }})" | |
| ${{ matrix.c_compiler }} --version | |
| ${{ matrix.cpp_compiler }} --version | |
| - name: Set reusable strings | |
| id: strings | |
| shell: bash | |
| run: | | |
| echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | |
| - name: Configure CMake | |
| run: > | |
| cmake -B ${{ steps.strings.outputs.build-output-dir }} | |
| -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} | |
| -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} | |
| -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | |
| -DCMAKE_EXPORT_COMPILE_COMMANDS=on | |
| -DFKVS_ENABLE_WARNINGS=ON | |
| -DFKVS_WARNINGS_AS_ERRORS=ON | |
| -S ${{ github.workspace }} | |
| - name: Build | |
| run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} | |
| - name: Generate compile commands json database | |
| run: > | |
| cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=on | |
| -B ${{ steps.strings.outputs.build-output-dir }} | |
| - name: Install CodeChecker dependencies | |
| if: matrix.build_type == 'Debug' | |
| run: | | |
| if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then | |
| sudo apt-get update | |
| sudo apt-get install -y clang clang-tidy clang-tools python3-pip | |
| pip3 install codechecker | |
| elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then | |
| if ! command -v pipx >/dev/null 2>&1; then | |
| brew update | |
| brew install pipx | |
| fi | |
| python3 -m venv path/to/venv | |
| source path/to/venv/bin/activate | |
| pipx install codechecker | |
| fi | |
| - name: Run CodeChecker analysis | |
| if: matrix.build_type == 'Debug' | |
| id: codechecker | |
| run: | | |
| CodeChecker analyze ${{ steps.strings.outputs.build-output-dir }}/compile_commands.json --output ${{ github.workspace }}/${{ matrix.os }}/reports | |
| CodeChecker parse ${{ github.workspace }}/${{ matrix.os }}/reports --export html --output ${{ github.workspace }}/html_reports || true | |
| echo "result-html-dir=${{ github.workspace }}/html_reports" >> $GITHUB_OUTPUT | |
| - uses: actions/upload-artifact@v4 | |
| if: matrix.build_type == 'Debug' | |
| with: | |
| name: "CodeChecker Bug Reports (${{ matrix.os }})" | |
| path: ${{ steps.codechecker.outputs.result-html-dir }} | |
| - name: Test | |
| working-directory: ${{ steps.strings.outputs.build-output-dir }} | |
| run: ctest -C ${{ matrix.build_type }} --output-on-failure | |
| sanitizers: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Install sanitizer toolchain | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang | |
| - name: Configure CMake with sanitizers | |
| run: > | |
| cmake -B ${{ github.workspace }}/build-sanitize | |
| -DCMAKE_C_COMPILER=clang | |
| -DCMAKE_BUILD_TYPE=Debug | |
| -DCMAKE_EXPORT_COMPILE_COMMANDS=on | |
| -DFKVS_ENABLE_WARNINGS=ON | |
| -DFKVS_WARNINGS_AS_ERRORS=ON | |
| -DFKVS_ENABLE_SANITIZERS=ON | |
| -S ${{ github.workspace }} | |
| - name: Build sanitizer target | |
| run: cmake --build ${{ github.workspace }}/build-sanitize --config Debug | |
| - name: Test with sanitizers | |
| working-directory: ${{ github.workspace }}/build-sanitize | |
| run: ctest -C Debug --output-on-failure |