build(net): guard tests subdirectory when tests are absent #4
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: Net Strict CI | |
| on: | |
| push: | |
| branches: [main, master, dev] | |
| paths: | |
| - ".github/workflows/net-strict-ci.yml" | |
| - "CMakeLists.txt" | |
| - "include/**" | |
| - "src/**" | |
| - "tests/**" | |
| - "README.md" | |
| - "LICENSE" | |
| - "CHANGELOG.md" | |
| - "vix.json" | |
| pull_request: | |
| branches: [main, master, dev] | |
| paths: | |
| - ".github/workflows/net-strict-ci.yml" | |
| - "CMakeLists.txt" | |
| - "include/**" | |
| - "src/**" | |
| - "tests/**" | |
| - "README.md" | |
| - "LICENSE" | |
| - "CHANGELOG.md" | |
| - "vix.json" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| env: | |
| DEPS: > | |
| build-essential | |
| cmake | |
| ninja-build | |
| clang | |
| llvm | |
| lld | |
| g++ | |
| cppcheck | |
| clang-tidy | |
| valgrind | |
| pkg-config | |
| git | |
| BUILD_JOBS: 2 | |
| VIX_GIT_BRANCH: dev | |
| # ====================================================== | |
| # BUILD + TEST | |
| # ====================================================== | |
| jobs: | |
| build-test: | |
| name: Build and Tests (${{ matrix.compiler }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| compiler: [clang, gcc] | |
| steps: | |
| - name: Checkout net repository | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update -y | |
| sudo apt-get install -y $DEPS | |
| - name: Fetch sibling utils | |
| run: | | |
| rm -rf ../utils | |
| git clone --depth 1 --branch "${VIX_GIT_BRANCH}" https://github.com/vixcpp/utils.git ../utils | |
| test -f ../utils/CMakeLists.txt || (echo "::error::utils missing"; exit 1) | |
| - name: Select compiler | |
| run: | | |
| if [ "${{ matrix.compiler }}" = "clang" ]; then | |
| echo "CC=clang" >> $GITHUB_ENV | |
| echo "CXX=clang++" >> $GITHUB_ENV | |
| else | |
| echo "CC=gcc" >> $GITHUB_ENV | |
| echo "CXX=g++" >> $GITHUB_ENV | |
| fi | |
| - name: Configure | |
| run: | | |
| cmake -G Ninja -S . -B build \ | |
| -DCMAKE_BUILD_TYPE=Debug \ | |
| -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | |
| -DVIX_NET_BUILD_TESTS=ON \ | |
| -DVIX_NET_FETCH_UTILS=OFF | |
| - name: Build | |
| run: cmake --build build -j${BUILD_JOBS} | |
| - name: Run tests | |
| run: | | |
| cd build | |
| ctest --output-on-failure || true | |
| # ====================================================== | |
| # STATIC ANALYSIS | |
| # ====================================================== | |
| static-analysis: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: | | |
| sudo apt-get update -y | |
| sudo apt-get install -y $DEPS | |
| - run: | | |
| git clone --depth 1 --branch "${VIX_GIT_BRANCH}" https://github.com/vixcpp/utils.git ../utils | |
| - run: | | |
| cmake -G Ninja -S . -B build \ | |
| -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | |
| -DVIX_NET_FETCH_UTILS=OFF | |
| - run: | | |
| set +e | |
| find src tests -name '*.cpp' -print0 | xargs -0 -r -n1 -P2 clang-tidy -p build | |
| exit 0 | |
| - run: | | |
| cppcheck --enable=all --std=c++20 --quiet include/ src/ tests/ || true | |
| # ====================================================== | |
| # VALGRIND | |
| # ====================================================== | |
| valgrind: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: | | |
| sudo apt-get update -y | |
| sudo apt-get install -y $DEPS | |
| - run: | | |
| git clone --depth 1 --branch "${VIX_GIT_BRANCH}" https://github.com/vixcpp/utils.git ../utils | |
| - run: | | |
| cmake -G Ninja -S . -B build \ | |
| -DCMAKE_BUILD_TYPE=Debug \ | |
| -DVIX_NET_BUILD_TESTS=ON \ | |
| -DVIX_NET_FETCH_UTILS=OFF | |
| - run: cmake --build build -j${BUILD_JOBS} | |
| - run: | | |
| set +e | |
| for exe in $(find build -type f -executable); do | |
| timeout 10s valgrind "$exe" || true | |
| done | |
| # ====================================================== | |
| # PACKAGE EXPORT CHECK | |
| # ====================================================== | |
| standalone-package-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: | | |
| sudo apt-get update -y | |
| sudo apt-get install -y $DEPS | |
| - run: | | |
| git clone --depth 1 --branch "${VIX_GIT_BRANCH}" https://github.com/vixcpp/utils.git ../utils | |
| - run: | | |
| cmake -G Ninja -S . -B build-install \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DVIX_NET_BUILD_TESTS=OFF \ | |
| -DVIX_NET_FETCH_UTILS=OFF \ | |
| -DCMAKE_INSTALL_PREFIX="${PWD}/.ci-install" | |
| - run: cmake --build build-install -j${BUILD_JOBS} | |
| - run: cmake --install build-install | |
| - run: | | |
| echo "---- install tree ----" | |
| find .ci-install -type f | sort | |
| test -f .ci-install/include/vix/net/NetworkProbe.hpp || (echo "::error::header missing"; exit 1) | |
| if [ -f .ci-install/lib/libvix_net.a ]; then | |
| echo "STATIC lib OK" | |
| else | |
| echo "::error::libvix_net.a missing" | |
| exit 1 | |
| fi | |
| # ====================================================== | |
| # CONFIG COVERAGE | |
| # ====================================================== | |
| config-coverage: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: | | |
| sudo apt-get update -y | |
| sudo apt-get install -y $DEPS | |
| - run: | | |
| git clone --depth 1 --branch "${VIX_GIT_BRANCH}" https://github.com/vixcpp/utils.git ../utils | |
| - run: | | |
| cmake -S . -B build-release \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DVIX_NET_FETCH_UTILS=OFF | |
| - run: cmake --build build-release | |
| - run: | | |
| cmake -S . -B build-debug \ | |
| -DCMAKE_BUILD_TYPE=Debug \ | |
| -DVIX_NET_FETCH_UTILS=OFF | |
| - run: cmake --build build-debug | |
| # ====================================================== | |
| # SUMMARY | |
| # ====================================================== | |
| summary: | |
| runs-on: ubuntu-latest | |
| needs: | |
| [ | |
| build-test, | |
| static-analysis, | |
| valgrind, | |
| standalone-package-check, | |
| config-coverage, | |
| ] | |
| steps: | |
| - run: | | |
| echo "Net CI OK" |