Skip to content

Commit

Permalink
Merge branch 'master' into try_improve_coverage_build
Browse files Browse the repository at this point in the history
  • Loading branch information
melroy89 authored Dec 14, 2023
2 parents d1641fc + f300abb commit cf99350
Show file tree
Hide file tree
Showing 192 changed files with 6,583 additions and 4,321 deletions.
76 changes: 44 additions & 32 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,42 @@
name: ci
name: build_and_test

on:
push:
branches:
- master
- "master"
pull_request:
branches:
- master

- "*"
jobs:
builds:
name: "${{ matrix.name }}"
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: "Ubuntu Focal clang-10 build"
os: ubuntu-20.04
cpp_compiler: clang++
- name: "Ubuntu Jammy clang-14 build"
os: ubuntu-22.04
cpp_compiler: clang++

- name: "Ubuntu Focal gcc-10 build"
os: ubuntu-20.04
cpp_compiler: g++-10
- name: "Ubuntu Jammy gcc-12 build"
os: ubuntu-22.04
cpp_compiler: g++-12

- name: "Ubuntu Focal gcc-9 build"
os: ubuntu-20.04
cpp_compiler: g++-9
- name: "Ubuntu Jammy gcc-11 build"
os: ubuntu-22.04
cpp_compiler: g++-11

- name: "Mac OS clang-12 build"
os: macos-10.15
cpp_compiler: clang++
- name: "Mac OS clang-14 build"
os: macos-12
cpp_compiler: clang++
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt install -y --no-install-recommends ninja-build clang-tidy-10 libcurl4-openssl-dev
sudo ln -s /usr/bin/clang-tidy-10 /usr/local/bin/clang-tidy
sudo apt install -y --no-install-recommends ninja-build clang-tidy-14 libcurl4-openssl-dev
sudo ln -s /usr/bin/clang-tidy-14 /usr/local/bin/clang-tidy
- name: Install (macOS)
if: runner.os == 'macOS'
run: |
Expand All @@ -59,9 +58,9 @@ jobs:

code_coverage:
name: "Run testcases with Code Coverage"
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install packages
run: |
sudo apt update
Expand All @@ -76,7 +75,7 @@ jobs:
-DBUILD_SHARED_LIBS=ON
- name: Install IPFS
env:
GO_IPFS_VERSION: "v0.9.1"
GO_IPFS_VERSION: "v0.20.0"
run: |
GO_IPFS_DOWNLOAD_URL="https://dist.ipfs.io/go-ipfs/${GO_IPFS_VERSION}/go-ipfs_${GO_IPFS_VERSION}_linux-amd64.tar.gz"
GO_IPFS_DIR="${GITHUB_WORKSPACE}/go-ipfs"
Expand All @@ -94,19 +93,25 @@ jobs:
./../scripts/ipfs_daemon_stop.sh
env:
CTEST_OUTPUT_ON_FAILURE: ON
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v3
with:
file: ./build/ctest_coverage_xml.xml

doxygen:
name: "Generate Doxygen"
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install
run: |
sudo apt update
sudo apt install -y --no-install-recommends doxygen libcurl4-openssl-dev
sudo apt install -y --no-install-recommends libcurl4-openssl-dev
- name: Install latest Doxygen (v1.9.7)
run: |
wget https://www.doxygen.nl/files/doxygen-1.9.7.linux.bin.tar.gz
tar -xf doxygen-1.9.7.linux.bin.tar.gz
cd doxygen-1.9.7
sudo make install
- name: Configure
run: >
cmake
Expand All @@ -118,16 +123,23 @@ jobs:

static_analytics:
name: "Static code analysis"
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install
run: |
sudo apt update
sudo apt install -y --no-install-recommends clang-tidy-10 libcurl4-openssl-dev
sudo ln -s /usr/bin/clang-tidy-10 /usr/local/bin/clang-tidy
sudo apt install -y --no-install-recommends clang-tidy-14 libcurl4-openssl-dev
sudo ln -s /usr/bin/clang-tidy-14 /usr/local/bin/clang-tidy
- name: Analysis
run: |
CCC_CXX=clang++-10 scan-build-10 --status-bugs cmake -DBUILD_SHARED_LIBS=ON "${SOURCE_DIR}"
CCC_CXX=clang++-10 scan-build-10 --status-bugs make VERBOSE=1
CCC_CXX=clang++-10 scan-build-14 --status-bugs cmake -DBUILD_SHARED_LIBS=ON "${SOURCE_DIR}"
CCC_CXX=clang++-10 scan-build-14 --status-bugs make VERBOSE=1
code_style_guidelines:
name: "Coding style guidelines"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Check style format
run: ./scripts/check_format.sh
70 changes: 34 additions & 36 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,51 +13,49 @@ name: "CodeQL"

on:
push:
branches: [ master ]
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '24 18 * * 2'
- cron: "24 18 * * 2"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
language: ["cpp"]

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

- name: Install packages
run: |
sudo apt update
sudo apt install -y --no-install-recommends ninja-build libcurl4-openssl-dev
- name: Configure
run: >
cmake
-B build
-G Ninja
-DCMAKE_BUILD_TYPE=Release
-DBUILD_SHARED_LIBS=ON
- name: Build
run: cmake --build build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

- name: Install packages
run: |
sudo apt update
sudo apt install -y --no-install-recommends ninja-build libcurl4-openssl-dev
- name: Configure
run: >
cmake
-B build
-G Ninja
-DCMAKE_BUILD_TYPE=Release
-DBUILD_SHARED_LIBS=ON
- name: Build
run: cmake --build build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
_deps

# Example target
examples/threading_app
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp",
"bit": "cpp"
"bit": "cpp",
"codecvt": "cpp"
},
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
}
54 changes: 34 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
cmake_minimum_required(VERSION 3.11.0)
cmake_minimum_required(VERSION 3.12.0)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

# Adhere the version number to http://semver.org/
project(cpp-ipfs-http-client VERSION 0.5.0 LANGUAGES CXX)
project(cpp-ipfs-http-client
VERSION 0.7.0
LANGUAGES CXX)

# Compile in C++11 mode
set(CMAKE_CXX_STANDARD 11)
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()

# Compile in C++20 mode
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Add compiler warnings
if(NOT COVERAGE)
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(AppleClang|Clang|GNU)$")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Wextra -Werror")
endif()
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(AppleClang|Clang|GNU)$" && NOT COVERAGE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -pedantic -Werror=incompatible-pointer-types")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Wextra -Werror")
endif()

# Generate compile_commands.json, to be used by YouCompleteMe.
Expand All @@ -23,12 +29,14 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Set the available options
option(DOC "Build Doxygen" OFF)
option(COVERAGE "Enable generation of coverage info" OFF)
option(BUILD_TESTING "Enable building test cases" ON)

# Find curl
# Look for static import symbols for Windows builds
if(WIN32)
add_definitions("-DCURL_STATICLIB")
endif()
find_package(CURL REQUIRED)
include_directories(${CURL_INCLUDE_DIRS})

include_directories("include")

# When build with coverage, set the correct compiler flags before the targets are defined
if(COVERAGE)
Expand All @@ -48,28 +56,34 @@ add_library(${IPFS_API_LIBNAME}
src/http/transport-curl.cc
)

# Add include directories
target_include_directories(${IPFS_API_LIBNAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CURL_INCLUDE_DIRS}
)

# Fetch "JSON for Modern C++"
include(FetchContent)
# Retrieve Nlohmann JSON
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
FetchContent_MakeAvailable(json)

FetchContent_Declare(json
GIT_REPOSITORY https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent
GIT_TAG v3.9.1)

FetchContent_GetProperties(json)
if(NOT json_POPULATED)
FetchContent_Populate(json)
add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
# libcurl requires additional libs only for static Windows builds
if(WIN32)
set(WINDOWS_CURL_LIBS idn2 unistring iconv charset ssh2 gcrypt gpg-error ws2_32 advapi32 crypt32 wldap32)
endif()

set_target_properties(${IPFS_API_LIBNAME} PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${PROJECT_VERSION}
)
target_link_libraries(${IPFS_API_LIBNAME} ${CURL_LIBRARIES} nlohmann_json::nlohmann_json)
target_link_libraries(${IPFS_API_LIBNAME} ${CURL_LIBRARIES} ${WINDOWS_CURL_LIBS} nlohmann_json::nlohmann_json)
if(NOT DISABLE_INSTALL)
install(TARGETS ${IPFS_API_LIBNAME} DESTINATION lib)
install(FILES include/ipfs/client.h DESTINATION include/ipfs)
install(FILES include/ipfs/http/transport.h DESTINATION include/ipfs/http)
install(FILES ${json_SOURCE_DIR}/include/nlohmann/json.hpp DESTINATION include/nlohmann)
endif()
# Tests, use "CTEST_OUTPUT_ON_FAILURE=1 make test" to see output from failed tests

Expand Down
Loading

0 comments on commit cf99350

Please sign in to comment.