diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 00000000..ef45d147 --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,116 @@ +name: Build Drogon + +on: + push: + branches: [master] + pull_request: + workflow_dispatch: + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + name: ${{matrix.buildname}} + runs-on: ${{matrix.os}} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-20.04 + buildname: 'ubuntu-20.04/gcc' + triplet: x64-linux + compiler: gcc_64 + - os: ubuntu-16.04 + buildname: 'ubuntu-16.04/gcc' + triplet: x64-linux + compiler: gcc_64 + - os: macos-latest + buildname: 'macos/clang' + triplet: x64-osx + compiler: clang_64 + + steps: + - name: Checkout Drogon source code + uses: actions/checkout@v2 + with: + submodules: true + fetch-depth: 0 + + - name: (macOS) Install dependencies + if: runner.os == 'macOS' + run: | + brew install jsoncpp ossp-uuid brotli zlib + brew install openssl lz4 mariadb sqlite3 postgresql + + - name: (Linux) Install dependencies + if: runner.os == 'Linux' + 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 install libjsoncpp-dev uuid-dev openssl libssl-dev zlib1g-dev postgresql-all libsqlite3-dev + sudo apt install libbrotli-dev + + - name: (Linux) Install boost + if: matrix.os == 'ubuntu-16.04' + run: | + sudo add-apt-repository ppa:mhier/libboost-latest + sudo apt update + sudo apt install boost1.67 + + - name: install gtest + run: | + wget https://github.com/google/googletest/archive/release-1.10.0.tar.gz + tar xf release-1.10.0.tar.gz + cd googletest-release-1.10.0 + cmake . + make + sudo make install + + - 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 + shell: bash + working-directory: ${{env.GITHUB_WORKSPACE}} + run: | + mkdir build + cd build + cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_TESTING=on + + - name: Build + working-directory: ${{env.GITHUB_WORKSPACE}} + shell: bash + # Execute the build. You can specify a specific target with "--target " + run: | + cd build + sudo make && sudo make install + + - name: Prepare for testing (macOS) + if: runner.os == 'macOS' + run: | + brew tap homebrew/services; + brew services restart postgresql; + brew services start mariadb; + 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: Prepare for testing (Linux) + if: runner.os == 'Linux' + run: | + sudo systemctl start postgresql + sleep 1 + sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '12345'" postgres + + - name: Test + working-directory: ${{env.GITHUB_WORKSPACE}} + shell: bash + # 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 diff --git a/README.md b/README.md index 3daf3534..8d0269fd 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ ![](https://github.com/an-tao/drogon/wiki/images/drogon-white.jpg) [![Build Status](https://travis-ci.com/an-tao/drogon.svg?branch=master)](https://travis-ci.com/an-tao/drogon) +![Build Status](https://github.com/an-tao/drogon/workflows/Build%20Drogon/badge.svg?branch=master) [![Build status](https://ci.appveyor.com/api/projects/status/12ffuf6j5vankgyb/branch/master?svg=true)](https://ci.appveyor.com/project/an-tao/drogon/branch/master) [![Total alerts](https://img.shields.io/lgtm/alerts/g/an-tao/drogon.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/an-tao/drogon/alerts/) [![Join the chat at https://gitter.im/drogon-web/community](https://badges.gitter.im/drogon-web/community.svg)](https://gitter.im/drogon-web/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) diff --git a/README.zh-CN.md b/README.zh-CN.md index a3444bb5..58a2ebfe 100755 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,6 +1,7 @@ ![](https://github.com/an-tao/drogon/wiki/images/drogon-white.jpg) [![Build Status](https://travis-ci.com/an-tao/drogon.svg?branch=master)](https://travis-ci.com/an-tao/drogon) +![Build Status](https://github.com/an-tao/drogon/workflows/Build%20Drogon/badge.svg?branch=master) [![Build status](https://ci.appveyor.com/api/projects/status/12ffuf6j5vankgyb/branch/master?svg=true)](https://ci.appveyor.com/project/an-tao/drogon/branch/master) [![Total alerts](https://img.shields.io/lgtm/alerts/g/an-tao/drogon.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/an-tao/drogon/alerts/) [![Join the chat at https://gitter.im/drogon-web/community](https://badges.gitter.im/drogon-web/community.svg)](https://gitter.im/drogon-web/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) diff --git a/README.zh-TW.md b/README.zh-TW.md index d2a37d75..4f015be3 100644 --- a/README.zh-TW.md +++ b/README.zh-TW.md @@ -1,6 +1,7 @@ ![](https://github.com/an-tao/drogon/wiki/images/drogon-white.jpg) [![Build Status](https://travis-ci.com/an-tao/drogon.svg?branch=master)](https://travis-ci.com/an-tao/drogon) +![Build Status](https://github.com/an-tao/drogon/workflows/Build%20Drogon/badge.svg?branch=master) [![Build status](https://ci.appveyor.com/api/projects/status/12ffuf6j5vankgyb/branch/master?svg=true)](https://ci.appveyor.com/project/an-tao/drogon/branch/master) [![Total alerts](https://img.shields.io/lgtm/alerts/g/an-tao/drogon.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/an-tao/drogon/alerts/) [![Join the chat at https://gitter.im/drogon-web/community](https://badges.gitter.im/drogon-web/community.svg)](https://gitter.im/drogon-web/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) diff --git a/examples/simple_example_test/main.cc b/examples/simple_example_test/main.cc index 378cc1ec..03cbf6da 100644 --- a/examples/simple_example_test/main.cc +++ b/examples/simple_example_test/main.cc @@ -20,6 +20,8 @@ #include #include +#include + #ifndef _WIN32 #include #endif @@ -1159,31 +1161,31 @@ void doTest(const HttpClientPtr &client, req = HttpRequest::newHttpRequest(); req->setMethod(drogon::Get); req->setPath("/a-directory"); - client->sendRequest(req, - [req, isHttps, &body](ReqResult result, - const HttpResponsePtr &resp) { - if (result == ReqResult::Ok) - { - if (resp->getBody().length() == - indexImplicitLen) - { - body = resp->getBody(); - outputGood(req, isHttps); - } - else - { - LOG_DEBUG << resp->getBody().length(); - LOG_ERROR << "Error!"; - LOG_ERROR << resp->getBody(); - exit(1); - } - } - else - { - LOG_ERROR << "Error!"; - exit(1); - } - }); + client->sendRequest( + req, + [req, isHttps, &body](ReqResult result, const HttpResponsePtr &resp) { + if (result == ReqResult::Ok) + { + if (resp->getBody().length() == indexImplicitLen) + { + body = std::string(resp->getBody().data(), + resp->getBody().length()); + outputGood(req, isHttps); + } + else + { + LOG_DEBUG << resp->getBody().length(); + LOG_ERROR << "Error!"; + LOG_ERROR << resp->getBody(); + exit(1); + } + } + else + { + LOG_ERROR << "Error!"; + exit(1); + } + }); req = HttpRequest::newHttpRequest(); req->setMethod(drogon::Get); req->setPath("/a-directory/page.html"); @@ -1194,7 +1196,9 @@ void doTest(const HttpClientPtr &client, { if (resp->getBody().length() == indexImplicitLen && - body == resp->getBody()) + std::equal(body.begin(), + body.end(), + resp->getBody().begin())) { outputGood(req, isHttps); } diff --git a/orm_lib/tests/db_test.cc b/orm_lib/tests/db_test.cc index f51449bb..a21a9b79 100644 --- a/orm_lib/tests/db_test.cc +++ b/orm_lib/tests/db_test.cc @@ -1994,7 +1994,7 @@ int main(int argc, char *argv[]) trantor::Logger::setLogLevel(trantor::Logger::kDebug); #if USE_POSTGRESQL auto postgre_client = DbClient::newPgClient( - "host=127.0.0.1 port=5432 dbname=postgres user=postgres " + "host=127.0.0.1 port=5432 dbname=postgres user=postgres password=12345 " "client_encoding=utf8", 1); #endif