Skip to content

Commit

Permalink
Make mgclient compile on Ubuntu 22.04 (#41)
Browse files Browse the repository at this point in the history
* Update CI to run on Ubuntu 22.04

* Fix include order and its formatting

* Make CI compiler version independent

* Fix clang-format issues

* Avoid deprecated low level API in OpenSSL 3.0

* Call OPENSSL_init_crypto to initialize ciphers required for RSA

* Ignore warning from gmock

* Parallelize compilation in CI

* Ignore unknown warning option to make gmock_wrapper compile with older compilers

* Restrict ingoring warnings for clang and gcc

* Replace NULL by nullptr in tests

* Explicitly ignore macOS for diagnostic pragma
  • Loading branch information
János Benjamin Antal committed Jun 14, 2022
1 parent bd57bae commit ca6249a
Show file tree
Hide file tree
Showing 18 changed files with 134 additions and 94 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ UseTab: Never
DerivePointerAlignment: false
PointerAlignment: Right
ColumnLimit: 80
IncludeBlocks: Preserve
...
35 changes: 19 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ on: [push]

jobs:
clang_check:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- name: Set-up repository
uses: actions/checkout@v2
- name: Install environment
run: |
sudo apt install -y clang-format-8
sudo apt install -y clang-format
- name: Run clang formatter
run: |
./tool/format.sh
Expand All @@ -32,35 +32,38 @@ jobs:
mkdir build
cd build
cmake -DOPENSSL_ROOT_DIR="$(ls -rd -- /usr/local/Cellar/[email protected]/* | head -n 1)" -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_TESTING=ON -DBUILD_TESTING_INTEGRATION=ON -DC_WARNINGS_AS_ERRORS=ON -DCPP_WARNINGS_AS_ERRORS=ON ..
make
cmake --build . --parallel
ctest -E "example|integration"
sudo make install
build_and_test_linux:
strategy:
matrix:
platform: [ubuntu-18.04]
platform: [ubuntu-20.04, ubuntu-22.04]
mgversion: ["2.0.0", "2.3.0"]
packages: ["gcc g++ clang"]
gcc-postfix: [""]
clang-postfix: [""]
include:
- {platform: [ubuntu-18.04], mgversion: "2.0.0", packages: "gcc-8 g++-8 clang-8 clang++-8", gcc-postfix: "-8", clang-postfix: "-8"}
runs-on: ${{ matrix.platform }}
env:
MG_VERSION: "1.4.0"
steps:
- name: Set-up repository
uses: actions/checkout@v1
- name: Install environment
run: |
sudo apt install -y gcc-8 g++-8 clang-8 clang++-8
sudo apt install -y ${{ matrix.packages }}
- name: Cache Memgraph Docker image
id: cache-memgraph-docker
uses: actions/cache@v1
with:
path: ~/memgraph
key: cache-memgraph-v${{ env.MG_VERSION }}-docker-image
key: cache-memgraph-v${{ matrix.mgversion }}-docker-image
- name: Download Memgraph Docker image
if: steps.cache-memgraph-docker.outputs.cache-hit != 'true'
run: |
mkdir ~/memgraph
curl -L https://memgraph.com/download/memgraph/v${MG_VERSION}/docker/memgraph-${MG_VERSION}-community-docker.tar.gz > ~/memgraph/memgraph-docker.tar.gz
curl -L https://memgraph.com/download/memgraph/v${{ matrix.mgversion }}/docker/memgraph-${{ matrix.mgversion }}-docker.tar.gz > ~/memgraph/memgraph-docker.tar.gz
- name: Load and run Memgraph Docker image
run: |
docker load -i ~/memgraph/memgraph-docker.tar.gz
Expand All @@ -69,15 +72,15 @@ jobs:
- name: Build with gcc, test and install mgclient
run: |
mkdir build-gcc && cd build-gcc
cmake -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8 -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DBUILD_TESTING_INTEGRATION=ON -DC_WARNINGS_AS_ERRORS=ON -DCPP_WARNINGS_AS_ERRORS=ON ..
make
cmake -DCMAKE_C_COMPILER=gcc${{ matrix.gcc-postfix }} -DCMAKE_CXX_COMPILER=g++${{ matrix.gcc-postfix }} -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DBUILD_TESTING_INTEGRATION=ON -DC_WARNINGS_AS_ERRORS=ON -DCPP_WARNINGS_AS_ERRORS=ON ..
cmake --build . --parallel
ctest --output-on-failure
sudo make install
- name: Build with clang, test and install mgclient
run: |
mkdir build-clang && cd build-clang
cmake -DCMAKE_C_COMPILER=clang-8 -DCMAKE_CXX_COMPILER=clang++-8 -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DBUILD_TESTING_INTEGRATION=ON -DC_WARNINGS_AS_ERRORS=ON -DCPP_WARNINGS_AS_ERRORS=ON ..
make
cmake -DCMAKE_C_COMPILER=clang${{ matrix.clang-postfix }} -DCMAKE_CXX_COMPILER=clang++${{ matrix.clang-postfix }} -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DBUILD_TESTING_INTEGRATION=ON -DC_WARNINGS_AS_ERRORS=ON -DCPP_WARNINGS_AS_ERRORS=ON ..
cmake --build . --parallel
ctest --output-on-failure
sudo make install
Expand Down Expand Up @@ -126,7 +129,7 @@ jobs:
mkdir build
cd build
cmake .. -G "MinGW Makefiles" -DBUILD_TESTING=ON -DBUILD_TESTING_INTEGRATION=ON -DC_WARNINGS_AS_ERRORS=ON -DCPP_WARNINGS_AS_ERRORS=ON
cmake --build .
cmake --build . --parallel
ctest --verbose -R "allocator|value|example_basic|integration_basic"
build_and_test_linux_wasm:
Expand All @@ -140,7 +143,7 @@ jobs:

- name: Build with clang
run: |
mkdir build
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DC_WARNINGS_AS_ERRORS=ON -DWASM=ON
make
3 changes: 2 additions & 1 deletion src/apple/mgsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "mgsocket.h"

#include <string.h>

#include "mgcommon.h"
#include "mgsocket.h"

#define MG_RETRY_ON_EINTR(expression) \
__extension__({ \
Expand Down
3 changes: 2 additions & 1 deletion src/mgsession.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "mgsession.h"

#include <assert.h>
#include <errno.h>
#include <stdalign.h>
Expand All @@ -26,7 +28,6 @@

#include "mgcommon.h"
#include "mgconstants.h"
#include "mgsession.h"
#include "mgtransport.h"

int mg_session_status(const mg_session *session) {
Expand Down
6 changes: 3 additions & 3 deletions src/mgtransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
extern "C" {
#endif

#include <stddef.h>
#include <stdio.h>

#ifndef __EMSCRIPTEN__
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
#endif

#include <stddef.h>
#include <stdio.h>

#include "mgallocator.h"
#include "mgcommon.h"

Expand Down
4 changes: 2 additions & 2 deletions src/windows/mgsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <limits.h>

#include "mgsocket.h"

#include <limits.h>

// Please refer to https://docs.microsoft.com/en-us/windows/win32/api/winsock2/
// for more details about Windows system calls.

Expand Down
4 changes: 3 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ set_target_properties(${GTEST_MAIN_LIBRARY} PROPERTIES
INTERFACE_LINK_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
add_dependencies(${GTEST_MAIN_LIBRARY} gtest-proj)

set(TESTS_ROOT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

macro(add_gtest target_name target_path)
add_executable(${target_name} ${target_path})
target_include_directories(${target_name} PRIVATE ${GTEST_INCLUDE_DIRS} "${PROJECT_SOURCE_DIR}/src")
target_include_directories(${target_name} PRIVATE ${GTEST_INCLUDE_DIRS} "${PROJECT_SOURCE_DIR}/src" "${TESTS_ROOT_DIRECTORY}")
target_link_libraries(${target_name} mgclient-static mgclient_cpp gtest gtest-main project_cpp_warnings)

if (ENABLE_COVERAGE)
Expand Down
8 changes: 4 additions & 4 deletions tests/bolt-testdata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,10 @@ std::vector<ValueTestParam> UnboundRelationshipTestCases() {
std::vector<ValueTestParam> PathTestCases() {
std::vector<ValueTestParam> inputs;
{
mg_node *nodes[] = {mg_node_make(1, 0, NULL, mg_map_make_empty(0)),
mg_node_make(2, 0, NULL, mg_map_make_empty(0)),
mg_node_make(3, 0, NULL, mg_map_make_empty(0)),
mg_node_make(4, 0, NULL, mg_map_make_empty(0))};
mg_node *nodes[] = {mg_node_make(1, 0, nullptr, mg_map_make_empty(0)),
mg_node_make(2, 0, nullptr, mg_map_make_empty(0)),
mg_node_make(3, 0, nullptr, mg_map_make_empty(0)),
mg_node_make(4, 0, nullptr, mg_map_make_empty(0))};
mg_unbound_relationship *relationships[] = {
mg_unbound_relationship_make(12, mg_string_make("EDGE"),
mg_map_make_empty(0)),
Expand Down
Loading

0 comments on commit ca6249a

Please sign in to comment.