Fix CI fail on OS X (#699)

This commit is contained in:
Martin Chang 2021-02-03 13:10:08 +08:00 committed by GitHub
parent 2919fdb7d4
commit a060351f7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 9 deletions

View File

@ -38,4 +38,4 @@ build:
project: build\ALL_BUILD.vcxproj
verbosity: minimal
cache:
- c:\tools\vcpkg\installed\
- c:\tools\vcpkg\installed\

View File

@ -42,7 +42,8 @@ jobs:
if: runner.os == 'macOS'
run: |
brew install jsoncpp ossp-uuid brotli zlib
brew install openssl lz4 mariadb sqlite3 postgresql
brew install openssl lz4 mysql mariadb-connector-c sqlite3 postgresql
mv /usr/local/include/mysql /usr/local/include/mysql_not_used
- name: (Linux) Install dependencies
if: runner.os == 'Linux'
@ -74,11 +75,23 @@ jobs:
# We'll use this as our working directory for all subsequent commands
shell: bash
working-directory: ${{env.GITHUB_WORKSPACE}}
if: runner.os != 'macOS'
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_TESTING=on
- name: Create Build Environment & Configure Cmake (MacOS)
# 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
shell: bash
working-directory: ${{env.GITHUB_WORKSPACE}}
if: runner.os == 'macOS'
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_TESTING=on -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl
- name: Build
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: bash
@ -92,12 +105,13 @@ jobs:
run: |
brew tap homebrew/services;
brew services restart postgresql;
brew services start mariadb;
mysqld --initialize-insecure
brew services start mysql;
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;
mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '';";
mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'";
mysql -e "FLUSH PRIVILEGES";
brew services restart mysql;
sleep 4;
psql -c 'create user postgres superuser;' postgres;
@ -111,10 +125,19 @@ jobs:
- name: Test
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: bash
if: runner.os != 'macOS'
# 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
- name: Test (MacOS)
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: bash
if: runner.os == 'macOS'
# 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 --extra-cmake-flags "-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl"
- name: Lint
if: runner.os == 'Linux'
working-directory: ${{env.GITHUB_WORKSPACE}}

View File

@ -77,7 +77,9 @@ else(WIN32)
find_library(MYSQL_LIBRARIES
NAMES mysqlclient_r mariadbclient
PATHS /usr/lib/mysql
/usr/lib/mariadb
/usr/local/lib/mysql
/usr/local/lib/mariadb
/usr/local/mysql/lib
/usr/local/mysql/lib/mysql
/opt/local/mysql5/lib

28
test.sh
View File

@ -1,5 +1,29 @@
#!/usr/bin/env bash
usage()
{
echo "$0: [=t] [--extra-cmake-flags <extra flags>]"
}
args=( "$@" )
testing=0
ignore_next=0
extra_cmake_flags=''
for i in `seq 0 $((${#args[@]} - 1))`; do
if [ $ignore_next = 1 ]; then ignore_next=0; continue; fi
if [ "${args[$i]}" = '-t' ]; then
testing=1
elif [ "${args[$i]}" = '--extra-cmake-flags' ]; then
extra_cmake_flags=${args[$(( i+1 ))]}
ignore_next=1
elif [ "${args[$i]}" = '-h' ]; then
usage; exit
else
usage; exit 1
fi
done
drogon_ctl_exec=`pwd`/build/drogon_ctl/drogon_ctl
echo ${drogon_ctl_exec}
cd build/examples/
@ -123,7 +147,7 @@ cd ../views
echo "Hello, world!" >> hello.csp
cd ../build
cmake .. $cmake_gen
cmake .. $cmake_gen $extra_cmake_flags
if [ $? -ne 0 ]; then
echo "Error in testing"
@ -145,7 +169,7 @@ fi
cd ../../
rm -rf drogon_test
if [ "$1" = "-t" ]; then
if [ $testing = 1 ]; then
#unit testing
cd ../
echo "Unit testing"