diff --git a/.appveyor.yml b/.appveyor.yml index e033177a..11eaad4d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -38,4 +38,4 @@ build: project: build\ALL_BUILD.vcxproj verbosity: minimal cache: -- c:\tools\vcpkg\installed\ \ No newline at end of file +- c:\tools\vcpkg\installed\ diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 1f3b778a..c0bdaa6f 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -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}} diff --git a/cmake_modules/FindMySQL.cmake b/cmake_modules/FindMySQL.cmake index e6544f6a..e35e164c 100644 --- a/cmake_modules/FindMySQL.cmake +++ b/cmake_modules/FindMySQL.cmake @@ -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 diff --git a/test.sh b/test.sh index 3d8e8b4e..e37cf5d3 100755 --- a/test.sh +++ b/test.sh @@ -1,5 +1,29 @@ #!/usr/bin/env bash +usage() +{ + echo "$0: [=t] [--extra-cmake-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"