Ubuntu #363
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: Ubuntu | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| - master | |
| - release/* | |
| tags: | |
| - '*' | |
| pull_request: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '18 0 1 * *' | |
| jobs: | |
| clang-format-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - uses: DoozyX/clang-format-lint-action@v0.18 | |
| with: | |
| source: '.' | |
| exclude: './third_party' | |
| clangFormatVersion: 18 | |
| build: | |
| name: ${{ matrix.os_compiler.name }} ${{ matrix.build_type }} (${{ matrix.os_compiler.os }}) | |
| runs-on: ${{ matrix.os_compiler.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| build_type: [Release, Debug] | |
| os_compiler: [ | |
| # ubuntu 22 | |
| {os: ubuntu-22.04, name: GCC 10, cc: gcc-10, cxx: g++-10}, | |
| {os: ubuntu-22.04, name: GCC 11, cc: gcc-11, cxx: g++-11}, | |
| {os: ubuntu-22.04, name: GCC 12, cc: gcc-12, cxx: g++-12}, | |
| {os: ubuntu-22.04, name: Clang 13, cc: clang-13, cxx: clang++-13, tidy: clang-tidy-13}, | |
| {os: ubuntu-22.04, name: Clang 14, cc: clang-14, cxx: clang++-14, tidy: clang-tidy-14}, | |
| {os: ubuntu-22.04, name: Clang 15, cc: clang-15, cxx: clang++-15, tidy: clang-tidy-15}, | |
| # ubuntu 24 | |
| {os: ubuntu-24.04, name: GCC 12, cc: gcc-12, cxx: g++-12}, | |
| {os: ubuntu-24.04, name: GCC 13, cc: gcc-13, cxx: g++-13}, | |
| {os: ubuntu-24.04, name: GCC 14, cc: gcc-14, cxx: g++-14, package: true}, | |
| {os: ubuntu-24.04, name: Clang 16, cc: clang-16, cxx: clang++-16, tidy: clang-tidy-16}, | |
| {os: ubuntu-24.04, name: Clang 17, cc: clang-17, cxx: clang++-17, tidy: clang-tidy-17}, | |
| {os: ubuntu-24.04, name: Clang 18, cc: clang-18, cxx: clang++-18, tidy: clang-tidy-18, package: true}, | |
| ] | |
| include: | |
| # Optional module builds | |
| - os_compiler: {os: ubuntu-24.04, name: Clang 18 (wxWidgets integration), cc: clang-18, cxx: clang++-18, tidy: clang-tidy-18 } | |
| build_type: Release | |
| cmake_args: "-DLIBBASE_BUILD_MODULE_WX=ON" | |
| package_deps: "autoconf automake libtool pkg-config libx11-dev libxft-dev libxext-dev libxi-dev libxtst-dev libltdl-dev bison gperf libxinerama-dev libxdamage-dev libxcursor-dev libxi-dev libxrandr-dev libgles2-mesa-dev" | |
| # ASAN/TSAN builds | |
| - os_compiler: {os: ubuntu-24.04, name: Clang 18 (ASAN), cc: clang-18, cxx: clang++-18, tidy: clang-tidy-18 } | |
| build_type: Debug | |
| cmake_args: "-DLIBBASE_BUILD_ASAN=ON" | |
| run_all: true | |
| - os_compiler: {os: ubuntu-24.04, name: Clang 18 (TSAN), cc: clang-18, cxx: clang++-18, tidy: clang-tidy-18 } | |
| build_type: Debug | |
| cmake_args: "-DLIBBASE_BUILD_TSAN=ON" | |
| run_all: true | |
| # Code coverage builds | |
| - os_compiler: {os: ubuntu-24.04, name: CodeCoverage (gcov), cc: gcc-13, cxx: g++-13} | |
| build_type: Debug | |
| cmake_args: "-DLIBBASE_CODE_COVERAGE=ON" | |
| code_coverage: true | |
| - os_compiler: {os: ubuntu-24.04, name: CodeCoverage (llvm-cov), cc: clang-18, cxx: clang++-18, tidy: clang-tidy-18, llvm-cov: llvm-cov-18, llvm-profdata: llvm-profdata-18 } | |
| build_type: Debug | |
| cmake_args: "-DLIBBASE_CODE_COVERAGE=ON" | |
| code_coverage: true | |
| env: | |
| CC: ${{ matrix.os_compiler.cc }} | |
| CXX: ${{ matrix.os_compiler.cxx }} | |
| steps: | |
| # Checkout repository | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # Setup vcpkg | |
| - name: Setup vcpkg | |
| uses: lukka/run-vcpkg@v11 | |
| with: | |
| vcpkgDirectory: ${{ runner.workspace }}/vcpkg | |
| # (Optional) Ensure required software is installed | |
| - name: (Optional) Compiler instalation | |
| run: | | |
| if ! command -v ${{ matrix.os_compiler.cc }} &> /dev/null | |
| then | |
| sudo apt install ${{ matrix.os_compiler.cc }} ${{ matrix.os_compiler.cxx }} | |
| fi | |
| - name: (Optional) System packages | |
| if: ${{ matrix.package_deps }} | |
| run: sudo apt install ${{ matrix.package_deps }} | |
| - name: (Optional) Clang-tidy installation | |
| if: ${{ startsWith(matrix.os_compiler.cc, 'clang') }} | |
| run: if ! command -v ${{ matrix.os_compiler.tidy }} &> /dev/null; then sudo apt install ${{ matrix.os_compiler.tidy }}; fi | |
| - name: (Optional) Lcov installation | |
| if: ${{ matrix.code_coverage && startsWith(matrix.os_compiler.cc, 'gcc') }} | |
| run: if ! command -v lcov &> /dev/null; then sudo apt install lcov; fi | |
| - name: (Optional) llvm-cov & llvm-profdata installation | |
| if: ${{ matrix.code_coverage && startsWith(matrix.os_compiler.cc, 'clang') }} | |
| run: | | |
| if ! command -v ${{ matrix.os_compiler.llvm-cov }} &> /dev/null; then sudo apt install ${{ matrix.os_compiler.llvm-cov }}; fi | |
| if ! command -v ${{ matrix.os_compiler.llvm-profdata }} &> /dev/null; then sudo apt install ${{ matrix.os_compiler.llvm-profdata }}; fi | |
| # Build and test | |
| - name: CMake configuration | |
| run: cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ${{ matrix.cmake_args }} -DCMAKE_TOOLCHAIN_FILE=${{ runner.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake | |
| - name: Building | |
| run: cmake --build build --config ${{ matrix.build_type }} -j 8 | |
| - name: Testing | |
| run: ctest --test-dir build --output-on-failure --timeout 15 | |
| # (Optional) Run other tests and examples | |
| - name: (Optional) Run performance tests | |
| if: ${{ matrix.run_all }} | |
| run: ./build/tests/perf/libbase_perf_tests | |
| - name: (Optional) Run examples (simple) | |
| if: ${{ matrix.run_all }} | |
| run: ./build/examples/simple/simple | |
| - name: (Optional) Run examples (networking) | |
| if: ${{ matrix.run_all }} | |
| run: ./build/examples/networking/networking | |
| # (Optional) Generate code coverage report and upload it | |
| # - 'gcov'-based is used with CI | |
| # - 'llvm-cov'-based is uploaded as an artifact | |
| - name: (Optional) Generate code coverage | |
| if: ${{ matrix.code_coverage }} | |
| run: cmake --build build --target coverage | |
| - name: (Optional) Upload code coverage to CI | |
| if: ${{ matrix.code_coverage && startsWith(matrix.os_compiler.cc, 'gcc') }} | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: true | |
| verbose: true | |
| - name: (Optional) Upload code coverage as artifact | |
| if: ${{ matrix.code_coverage && startsWith(matrix.os_compiler.cc, 'clang') }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: llvm-cov-code-coverage-report | |
| path: build/coverage/ | |
| # Prepare & upload binaries | |
| - name: Prepare binaries | |
| if: matrix.os_compiler.package && github.event_name != 'pull_request' | |
| run: cmake --install build --prefix install --config ${{ matrix.build_type }} | |
| continue-on-error: true | |
| - name: Upload binaries as artifact | |
| if: matrix.os_compiler.package && github.event_name != 'pull_request' && success() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: libbase-${{ github.ref_name }}-${{ matrix.os_compiler.cc }}-${{ matrix.build_type }}-${{ matrix.os_compiler.os }}-x64.zip | |
| path: install | |
| retention-days: 7 | |
| continue-on-error: true | |
| # Verify release (tag push) | |
| release-tests: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Verify versions | |
| run: | | |
| TAG_VERSION="${GITHUB_REF#refs/tags/v}" | |
| CMAKE_VERSION=$(tr -d '\n' < CMakeLists.txt | grep -oP 'project\([^()]*VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' | head -n 1) | |
| VCPKG_VERSION=$(jq -r '.version' vcpkg.json) | |
| if [[ "$TAG_VERSION" != "$CMAKE_VERSION" ]]; then | |
| echo "::error::Git tag version ($TAG_VERSION) does not match CMakeLists.txt version ($CMAKE_VERSION)" | |
| EXIT_CODE=1 | |
| fi | |
| if [[ "$TAG_VERSION" != "$VCPKG_VERSION" ]]; then | |
| echo "::error::Git tag version ($TAG_VERSION) does not match vcpkg.json version ($VCPKG_VERSION)" | |
| EXIT_CODE=1 | |
| fi | |
| exit $EXIT_CODE |