mirror of
https://gitee.com/an-tao/drogon.git
synced 2024-12-02 03:38:03 +08:00
Remove redundancies from the CMake action (#1322)
This commit is contained in:
parent
474db0dd9a
commit
5373e51f92
117
.github/workflows/cmake.yml
vendored
117
.github/workflows/cmake.yml
vendored
@ -2,7 +2,7 @@ name: Build Drogon
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [master]
|
branches: [ master ]
|
||||||
pull_request:
|
pull_request:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
windows:
|
windows:
|
||||||
name: 'windows/msvc - ${{matrix.link}}'
|
name: windows/msvc - ${{ matrix.link }}
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
@ -26,41 +26,39 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: pip install conan
|
||||||
pip install conan
|
|
||||||
|
|
||||||
- name: Create build directory
|
- name: Create build directory
|
||||||
run: |
|
run: mkdir build
|
||||||
mkdir build
|
|
||||||
|
|
||||||
- name: Install conan packages
|
- name: Install conan packages
|
||||||
shell: pwsh
|
|
||||||
working-directory: ./build
|
working-directory: ./build
|
||||||
run: |
|
run: conan install .. -s compiler="Visual Studio" -s compiler.version=16 -sbuild_type=Debug -g cmake_paths
|
||||||
conan install .. -s compiler="Visual Studio" -s compiler.version=16 -sbuild_type=Debug -g cmake_paths
|
|
||||||
|
|
||||||
- name: Create Build Environment & Configure Cmake
|
- name: Create Build Environment & Configure Cmake
|
||||||
shell: bash
|
shell: bash
|
||||||
working-directory: ./build
|
working-directory: ./build
|
||||||
run: |
|
run: |
|
||||||
[[ ${{ matrix.link }} == "SHARED" ]] && shared="ON" || shared="OFF"
|
[[ ${{ matrix.link }} == "SHARED" ]] && shared="ON" || shared="OFF"
|
||||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=on -DBUILD_SHARED_LIBS=$shared -DCMAKE_TOOLCHAIN_FILE="conan_paths.cmake" -DBUILD_CTL=ON -DBUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=../install
|
cmake .. \
|
||||||
|
-DCMAKE_BUILD_TYPE=Debug \
|
||||||
|
-DBUILD_TESTING=on \
|
||||||
|
-DBUILD_SHARED_LIBS=$shared \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE="conan_paths.cmake" \
|
||||||
|
-DBUILD_CTL=ON \
|
||||||
|
-DBUILD_EXAMPLES=ON \
|
||||||
|
-DCMAKE_INSTALL_PREFIX=../install
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
working-directory: ${{env.GITHUB_WORKSPACE}}
|
run: cmake --build build --target install --parallel
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
cd build
|
|
||||||
cmake --build . --target install --parallel
|
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
working-directory: ${{env.GITHUB_WORKSPACE}}
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: ./test.sh -w
|
run: ./test.sh -w
|
||||||
|
|
||||||
unix:
|
unix:
|
||||||
name: ${{matrix.buildname}}
|
name: ${{ matrix.buildname }}
|
||||||
runs-on: ${{matrix.os}}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@ -100,7 +98,7 @@ jobs:
|
|||||||
if: runner.os == 'macOS'
|
if: runner.os == 'macOS'
|
||||||
run: |
|
run: |
|
||||||
brew install jsoncpp brotli zlib
|
brew install jsoncpp brotli zlib
|
||||||
brew install openssl lz4 mariadb sqlite3 postgresql hiredis
|
brew install lz4 mariadb sqlite3 postgresql hiredis
|
||||||
brew install redis
|
brew install redis
|
||||||
|
|
||||||
- name: (Linux) Install dependencies
|
- name: (Linux) Install dependencies
|
||||||
@ -109,46 +107,46 @@ jobs:
|
|||||||
# Installing packages might fail as the github image becomes outdated
|
# Installing packages might fail as the github image becomes outdated
|
||||||
sudo apt update
|
sudo apt update
|
||||||
# These aren't available or don't work well in vcpkg
|
# These aren't available or don't work well in vcpkg
|
||||||
sudo apt install libjsoncpp-dev uuid-dev openssl libssl-dev zlib1g-dev libsqlite3-dev
|
sudo apt-get install -y libjsoncpp-dev uuid-dev libssl-dev zlib1g-dev libsqlite3-dev
|
||||||
sudo apt install libbrotli-dev
|
sudo apt-get install -y libbrotli-dev
|
||||||
- name: (Linux) Install gcc-10
|
- name: (Linux) Install gcc-10
|
||||||
if: matrix.buildname == 'ubuntu-20.04/gcc-10'
|
if: matrix.buildname == 'ubuntu-20.04/gcc-10'
|
||||||
run: |
|
run: sudo apt-get install -y gcc-10 g++-10
|
||||||
sudo apt install gcc-10 g++-10
|
|
||||||
- name: (Linux) Install boost
|
- name: (Linux) Install boost
|
||||||
if: matrix.buildname == 'ubuntu-20.04/c++14'
|
if: matrix.buildname == 'ubuntu-20.04/c++14'
|
||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt-get update
|
||||||
sudo apt install libboost-all-dev
|
sudo apt-get -y install libboost-all-dev
|
||||||
|
|
||||||
- name: (Linux) Install postgresql
|
- name: (Linux) Install postgresql
|
||||||
if: matrix.os == 'ubuntu-20.04'
|
if: matrix.os == 'ubuntu-20.04'
|
||||||
run: |
|
run: sudo apt-get -y install postgresql-all
|
||||||
sudo apt install postgresql-all
|
|
||||||
|
|
||||||
- name: Create build directory
|
- name: Export `shared`
|
||||||
run: |
|
run: |
|
||||||
mkdir build
|
[[ ${{ matrix.link }} == "SHARED" ]] && shared="ON" || shared="OFF"
|
||||||
|
echo "shared=$shared" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Create Build Environment & Configure Cmake
|
- name: Create Build Environment & Configure Cmake
|
||||||
# Some projects don't allow in-source building, so create a separate build directory
|
# 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
|
# We'll use this as our working directory for all subsequent commands
|
||||||
shell: bash
|
|
||||||
working-directory: ./build
|
|
||||||
if: matrix.buildname != 'ubuntu-20.04/gcc-10' && matrix.buildname != 'ubuntu-20.04/c++14'
|
if: matrix.buildname != 'ubuntu-20.04/gcc-10' && matrix.buildname != 'ubuntu-20.04/c++14'
|
||||||
run: |
|
run: |
|
||||||
[[ ${{ matrix.link }} == "SHARED" ]] && shared="ON" || shared="OFF"
|
cmake -B build \
|
||||||
cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_TESTING=on -DBUILD_SHARED_LIBS=$shared
|
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
|
||||||
|
-DBUILD_TESTING=on \
|
||||||
|
-DBUILD_SHARED_LIBS=$shared
|
||||||
|
|
||||||
- name: Create Build Environment & Configure Cmake (gcc-10)
|
- name: Create Build Environment & Configure Cmake (gcc-10)
|
||||||
# Some projects don't allow in-source building, so create a separate build directory
|
# 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
|
# We'll use this as our working directory for all subsequent commands
|
||||||
shell: bash
|
|
||||||
working-directory: ./build
|
|
||||||
if: matrix.buildname == 'ubuntu-20.04/gcc-10'
|
if: matrix.buildname == 'ubuntu-20.04/gcc-10'
|
||||||
run: |
|
run: |
|
||||||
[[ ${{ matrix.link }} == "SHARED" ]] && shared="ON" || shared="OFF"
|
cmake -B build \
|
||||||
cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_TESTING=on -DCMAKE_CXX_FLAGS="-fcoroutines" -DBUILD_SHARED_LIBS=$shared
|
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
|
||||||
|
-DBUILD_TESTING=on \
|
||||||
|
-DCMAKE_CXX_FLAGS="-fcoroutines" \
|
||||||
|
-DBUILD_SHARED_LIBS=$shared
|
||||||
env:
|
env:
|
||||||
CC: gcc-10
|
CC: gcc-10
|
||||||
CXX: g++-10
|
CXX: g++-10
|
||||||
@ -156,39 +154,38 @@ jobs:
|
|||||||
- name: Create Build Environment & Configure Cmake (C++14)
|
- name: Create Build Environment & Configure Cmake (C++14)
|
||||||
# Some projects don't allow in-source building, so create a separate build directory
|
# 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
|
# We'll use this as our working directory for all subsequent commands
|
||||||
shell: bash
|
|
||||||
working-directory: ./build
|
|
||||||
if: matrix.buildname == 'ubuntu-20.04/C++14'
|
if: matrix.buildname == 'ubuntu-20.04/C++14'
|
||||||
run: |
|
run: |
|
||||||
[[ ${{ matrix.link }} == "SHARED" ]] && shared="ON" || shared="OFF"
|
cmake -B build \
|
||||||
cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_TESTING=on -DCMAKE_CXX_STANDARD=14 -DBUILD_SHARED_LIBS=$shared
|
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
|
||||||
|
-DBUILD_TESTING=on \
|
||||||
|
-DCMAKE_CXX_STANDARD=14 \
|
||||||
|
-DBUILD_SHARED_LIBS=$shared
|
||||||
|
|
||||||
- name: (Linux) Build
|
- name: Build
|
||||||
working-directory: ./build
|
working-directory: ./build
|
||||||
shell: bash
|
|
||||||
# Execute the build. You can specify a specific target with "--target <NAME>"
|
# Execute the build. You can specify a specific target with "--target <NAME>"
|
||||||
run: |
|
run: make -j $(nproc) && sudo make install
|
||||||
sudo make -j $(nproc) && sudo make install
|
|
||||||
|
|
||||||
- name: Prepare for testing (macOS)
|
- name: (macOS) Prepare for testing
|
||||||
if: runner.os == 'macOS'
|
if: runner.os == 'macOS'
|
||||||
run: |
|
run: |
|
||||||
cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-services
|
cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-services
|
||||||
git reset --hard 5f2fe01
|
git reset --hard 5f2fe01
|
||||||
cd ~
|
cd ~
|
||||||
brew tap homebrew/services;
|
brew tap homebrew/services
|
||||||
brew services restart postgresql;
|
brew services restart postgresql
|
||||||
brew services start mariadb;
|
brew services start mariadb
|
||||||
brew services start redis;
|
brew services start redis
|
||||||
sleep 4;
|
sleep 4
|
||||||
mariadb -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('')";
|
mariadb -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('')"
|
||||||
mariadb -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'";
|
mariadb -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'"
|
||||||
mariadb -e "FLUSH PRIVILEGES";
|
mariadb -e "FLUSH PRIVILEGES"
|
||||||
brew services restart mariadb;
|
brew services restart mariadb
|
||||||
sleep 4;
|
sleep 4
|
||||||
psql -c 'create user postgres superuser;' postgres;
|
psql -c 'create user postgres superuser;' postgres
|
||||||
|
|
||||||
- name: Prepare for testing (Linux)
|
- name: (Linux) Prepare for testing
|
||||||
if: runner.os == 'Linux'
|
if: runner.os == 'Linux'
|
||||||
run: |
|
run: |
|
||||||
sudo systemctl start postgresql
|
sudo systemctl start postgresql
|
||||||
@ -196,16 +193,12 @@ jobs:
|
|||||||
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '12345'" postgres
|
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '12345'" postgres
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
working-directory: ${{env.GITHUB_WORKSPACE}}
|
|
||||||
shell: bash
|
|
||||||
# Execute tests defined by the CMake configuration.
|
# Execute tests defined by the CMake configuration.
|
||||||
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
||||||
run: ./test.sh -t
|
run: ./test.sh -t
|
||||||
|
|
||||||
- name: Lint
|
- name: Lint
|
||||||
if: matrix.os == 'ubuntu-20.04'
|
if: matrix.os == 'ubuntu-20.04'
|
||||||
working-directory: ${{env.GITHUB_WORKSPACE}}
|
|
||||||
shell: bash
|
|
||||||
run: |
|
run: |
|
||||||
sudo apt install -y dos2unix
|
sudo apt install -y dos2unix
|
||||||
./format.sh && git diff --exit-code
|
./format.sh && git diff --exit-code
|
||||||
|
Loading…
Reference in New Issue
Block a user