drogon/.github/workflows/cmake.yml

242 lines
8.1 KiB
YAML

name: Build & Test
on:
push:
branches: [master]
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
windows:
name: windows/msvc - ${{ matrix.link }}
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
link: ["STATIC", "SHARED"]
steps:
- name: Checkout Drogon source code
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Install dependencies
run: pip install conan
- name: Create build directory
run: mkdir build
- name: Install conan packages
working-directory: ./build
run: |
conan profile detect
conan install .. -s compiler="msvc" -sbuild_type=Debug --build=missing -s compiler.cppstd=17
- name: Create Build Environment & Configure Cmake
shell: bash
working-directory: ./build
# For unknown reasons, we fail to create file in windows ci environment.
# So examples, drogon_ctl and integration tests can not be built in windows ci.
# We should try to enable them again in the future.
run: |
[[ ${{ matrix.link }} == "SHARED" ]] && shared="ON" || shared="OFF"
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_TESTING=on \
-DBUILD_SHARED_LIBS=$shared \
-DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" \
-DBUILD_CTL=OFF \
-DBUILD_EXAMPLES=OFF \
-DUSE_SPDLOG=ON \
-DCMAKE_INSTALL_PREFIX=../install \
-DCMAKE_POLICY_DEFAULT_CMP0091=NEW \
-DCMAKE_CXX_STANDARD=17
- name: Build
run: cmake --build build --target install --parallel
- name: Test
shell: bash
run: ./test.sh -w
macos:
runs-on: macos-${{ matrix.osver }}
strategy:
fail-fast: false
matrix:
osver: [12, 13]
steps:
- name: Checkout Drogon source code
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Install dependencies
# Already installed: brotli, zlib, lz4, sqlite3
run: brew install ninja jsoncpp mariadb hiredis redis spdlog postgresql@14
- name: Create Build Environment & Configure Cmake
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: |
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DBUILD_TESTING=on \
-DUSE_SPDLOG=ON \
-DBUILD_SHARED_LIBS=OFF
- name: Build
working-directory: ./build
# Execute the build. You can specify a specific target with "--target <NAME>"
run: ninja && sudo ninja install
- name: Prepare for testing
run: |
brew tap homebrew/services
brew services restart postgresql@14
brew services start mariadb
brew services start redis
sleep 4
mariadb -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('')"
mariadb -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'"
mariadb -e "FLUSH PRIVILEGES"
brew services restart mariadb
sleep 4
psql -c 'create user postgres superuser;' postgres
- name: Test
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ./test.sh -t
ubuntu:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
link: [SHARED, STATIC]
compiler:
- cxx: g++
ver: 9
- cxx: g++
ver: 10
- cxx: g++
ver: 11
- cxx: g++
ver: 12
- cxx: g++
ver: 13
- cxx: clang++
ver: 11
- cxx: clang++
ver: 12
- cxx: clang++
ver: 13
- cxx: clang++
ver: 14
- cxx: clang++
ver: 15
- cxx: clang++
ver: 16
- cxx: clang++
ver: 17
include:
- link: STATIC
compiler:
cxx: g++
ver: 13
feature: coroutines
env:
CXX: ${{ matrix.compiler.cxx }}-${{ matrix.compiler.ver }}
steps:
- name: Checkout Drogon source code
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Install dependencies
run: |
# Installing packages might fail as the github image becomes outdated
sudo apt update
# These aren't available or don't work well in vcpkg
sudo apt-get install -y libjsoncpp-dev uuid-dev libssl-dev zlib1g-dev libsqlite3-dev
sudo apt-get install -y ninja-build libbrotli-dev
sudo apt-get install -y libspdlog-dev
- name: Install postgresql
run: |
sudo apt-get --purge remove postgresql postgresql-doc postgresql-common postgresql-client-common
sudo apt-get -y install postgresql-all
- name: Install g++-13
if: startsWith(matrix.compiler.cxx, 'g++') && matrix.compiler.ver == 13
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get install g++-${{ matrix.compiler.ver }}
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 13
- name: Install Clang
if: startsWith(matrix.compiler.cxx, 'clang') && matrix.compiler.ver < 13
run: sudo apt-get install clang-${{ matrix.compiler.ver }}
- name: Install Clang
if: startsWith(matrix.compiler.cxx, 'clang') && matrix.compiler.ver >= 13
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x ./llvm.sh
sudo ./llvm.sh ${{ matrix.compiler.ver }}
- name: Export `shared`
run: |
[[ ${{ matrix.link }} == "SHARED" ]] && shared="ON" || shared="OFF"
echo "shared=$shared" >> $GITHUB_ENV
- name: Create Build Environment & Configure Cmake
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
if: matrix.compiler.feature != 'coroutines'
run: |
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DBUILD_TESTING=on \
-DUSE_SPDLOG=ON \
-DBUILD_SHARED_LIBS=$shared
- name: Create Build Environment & Configure Cmake (coroutines)
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
if: matrix.compiler.feature == 'coroutines'
run: |
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DBUILD_TESTING=on \
-DUSE_SPDLOG=ON \
-DCMAKE_CXX_FLAGS="-fcoroutines" \
-DBUILD_SHARED_LIBS=$shared \
- name: Build
working-directory: ./build
# Execute the build. You can specify a specific target with "--target <NAME>"
run: ninja && sudo ninja install
- name: Prepare for testing
run: |
sudo systemctl start postgresql
sleep 1
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '12345'" postgres
- name: Test
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ./test.sh -t