Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions .github/workflows/ubuntu-minimal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Ubuntu

'on':
pull_request:
push:
branches:
- master
- develop
- feature/**

env:
JAVA_HOME: /usr/lib/jvm/java-17-openjdk-amd64
UBSAN_OPTIONS: print_stacktrace=1
ASAN_OPTIONS: detect_odr_violation=2
CCACHE_DIR: /home/runner/.cache/ccache
CCACHE_NOHASHDIR: true
CPM_SOURCE_CACHE: /home/runner/.cache/CPM
REDIS_SLEEP_WORKAROUND_SECONDS: 60

jobs:
posix:
strategy:
fail-fast: false
env:
CMAKE_FLAGS: >-
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_CXX_STANDARD=17
-DUSERVER_SANITIZE="ub addr"
-DUSERVER_BUILD_SAMPLES=1
-DUSERVER_BUILD_TESTS=1

name: ubuntu (minimal installation)
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Restore cached directories
id: restore-cache
uses: actions/cache/restore@v4
with:
path: |
${{env.CCACHE_DIR}}
${{env.CPM_SOURCE_CACHE}}
key: 'ubuntu-cache-dir ${{matrix.id}} ${{github.ref}} run-${{github.run_number}}'
restore-keys: |
ubuntu-cache-dir ${{matrix.id}} ${{github.ref}}
ubuntu-cache-dir ${{matrix.id}}

- name: Setup ramdrive for testsuites
run: |
sudo mkdir -p "/mnt/ramdisk/$USER"
sudo chmod 777 "/mnt/ramdisk/$USER"
sudo mount -t tmpfs -o size=2048M tmpfs "/mnt/ramdisk/$USER"

- name: Free disk space
run: |
df -h
# See https://stackoverflow.com/questions/75536771/github-runner-out-of-disk-space-after-building-docker-image
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /usr/lib/php* /opt/ghc \
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
/opt/hostedtoolcache/CodeQL || true
sudo docker image prune --all --force
df -h

- name: Install common deps
run: |
sudo apt update
sudo apt install build-essential clang cmake ccache libjemalloc-dev
sudo apt install \
libnghttp2-dev \
libev-dev \
libssl-dev \
libboost-context1.83-dev \
libboost-coroutine1.83-dev \
libboost-filesystem1.83-dev \
libboost-iostreams1.83-dev \
libboost-locale1.83-dev \
libboost-program-options1.83-dev \
libboost-stacktrace1.83-dev \
libbenchmark-dev

- name: Setup ccache
run: |
ccache -M 2.0GB
ccache -s -v

- name: Run cmake
run: |
cmake -S . -B build_debug

- name: Compile
run: |
pwd
cd build_debug
cmake --build . -j $(nproc)

- name: Save cached directories
uses: actions/cache/save@v4
with:
path: |
${{env.CCACHE_DIR}}
${{env.CPM_SOURCE_CACHE}}
key: ${{ steps.restore-cache.outputs.cache-primary-key }}

- name: Show cache stats
run: |
du -h -d 1 ${{env.CCACHE_DIR}}
du -h -d 1 ${{env.CPM_SOURCE_CACHE}}
ccache -s -v
47 changes: 41 additions & 6 deletions cmake/ModuleHelpers.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include_guard(GLOBAL)

include(DownloadUsingCPM)

cmake_policy(SET CMP0054 NEW)

macro(_userver_module_begin)
Expand All @@ -11,6 +13,13 @@ macro(_userver_module_begin)
DEBIAN_NAMES FORMULA_NAMES RPM_NAMES PACMAN_NAMES PKG_NAMES
# For version detection of manually installed packages and unknown package managers.
PKG_CONFIG_NAMES
# For CPM options
CPM_NAME
CPM_VERSION
CPM_GITHUB_REPOSITORY
CPM_OPTIONS
CPM_SOURCE_SUBDIR
CPM_GIT_TAG
)

cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
Expand Down Expand Up @@ -261,12 +270,26 @@ macro(_userver_module_end)
list(APPEND required_vars "${programs_variable}")
endif()
if(required_vars)
find_package_handle_standard_args(
"${current_package_name}"
REQUIRED_VARS ${required_vars}
FAIL_MESSAGE "${FULL_ERROR_MESSAGE}"
)
mark_as_advanced(${required_vars})
foreach(_CURRENT_VAR ${required_vars})
if(NOT ${_CURRENT_VAR})
set(NEED_CPM TRUE)
if(NOT ("${ARG_CPM_NAME}" STREQUAL ""))
set(${_CURRENT_VAR})
endif()
endif()
endforeach()

if("${NEED_CPM}" AND NOT ("${ARG_CPM_NAME}" STREQUAL ""))
_userver_cpm_addpackage("${current_package_name}")
return()
else()
find_package_handle_standard_args(
"${current_package_name}"
REQUIRED_VARS ${required_vars}
FAIL_MESSAGE "${FULL_ERROR_MESSAGE}"
)
mark_as_advanced(${required_vars})
endif()
else()
# Forward to another CMake module, add nice error messages if missing.
set(wrapped_package_name "${current_package_name}")
Expand Down Expand Up @@ -323,6 +346,18 @@ macro(_userver_module_end)
endif()
endmacro()

macro(_userver_cpm_addpackage name)
cpmaddpackage(
NAME ${name}
VERSION ${ARG_CPM_VERSION}
GITHUB_REPOSITORY ${ARG_CPM_GITHUB_REPOSITORY}
OPTIONS ${ARG_CPM_OPTIONS}
SOURCE_SUBDIR ${ARG_CPM_SOURCE_SUBDIR}
GIT_TAG ${ARG_CPM_GIT_TAG}
)
set(${name}_FOUND 1)
endmacro()

function(_userver_macos_set_default_dir variable command_args)
set(default_value "")
if(CMAKE_SYSTEM_NAME MATCHES "Darwin" AND NOT DEFINED ${variable})
Expand Down
10 changes: 10 additions & 0 deletions cmake/modules/Findc-ares.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ _userver_module_begin(
c-ares
PKG_CONFIG_NAMES
libcares

CPM_NAME c-ares
CPM_GITHUB_REPOSITORY c-ares/c-ares
CPM_VERSION 1.34.5
CPM_OPTIONS
"CARES_STATIC ON"
"CARES_SHARED OFF"
"CARES_INSTALL OFF"
"CARES_BUILD_TOOLS OFF"
"CARES_STATIC_PIC ON"
)

_userver_module_find_include(NAMES ares.h)
Expand Down
2 changes: 2 additions & 0 deletions cmake/modules/Findlibev.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ _userver_module_begin(
libev-devel
PACMAN_NAMES
libev

# TODO: CPM
)

_userver_module_find_include(NAMES ev.h libev/ev.h)
Expand Down
2 changes: 2 additions & 0 deletions cmake/modules/Findlibnghttp2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ _userver_module_begin(
nghttp2
PACMAN_NAMES
libnghttp2

# TODO: CPM
)

_userver_module_find_include(NAMES nghttp2/nghttp2.h)
Expand Down
4 changes: 4 additions & 0 deletions cmake/modules/Findyaml-cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ _userver_module_begin(
yaml-cpp
PACMAN_NAMES
yaml-cpp

CPM_NAME yaml-cpp
CPM_GITHUB_REPOSITORY jbeder/yaml-cpp
CPM_GIT_TAG yaml-cpp-0.7.0
)

_userver_module_find_include(NAMES yaml-cpp/yaml.h yaml-cpp/node.h PATH_SUFFIXES include)
Expand Down
8 changes: 7 additions & 1 deletion cmake/modules/Findzstd.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ _userver_module_begin(
libzstd-dev
PACMAN_NAMES
zstd

# TODO: CPM
)

_userver_module_find_include(NAMES zdict.h zstd.h zstd_errors.h PATH_SUFFIXES include)
Expand All @@ -18,7 +20,11 @@ _userver_module_find_library(NAMES zstd PATH_SUFFIXES lib)
_userver_module_end()

if(NOT TARGET zstd::zstd)
add_library(zstd::zstd ALIAS zstd)
if(TARGET libzstd_static)
add_library(zstd::zstd ALIAS libzstd_static)
else()
add_library(zstd::zstd ALIAS zstd)
endif()
endif()
if(NOT TARGET ZSTD::ZSTD)
add_library(ZSTD::ZSTD ALIAS zstd)
Expand Down
Loading