Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add installation tests to CI #30

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
41 changes: 33 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,40 @@ jobs:
working-directory: build
shell: bash
run: make stop
- name: Build examples
shell: bash
env:
CC: ${{ matrix.compiler }}

install:
name: Installation tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
- name: Prepare
uses: awalsh128/cache-apt-pkgs-action@a6c3917cc929dd0345bfb2d3feaf9101823370ad # v1.4.2
with:
packages: libevent-dev libuv1-dev libev-dev libglib2.0-dev
version: 1.0
- name: Install libvalkey using Makefile
run: |
make USE_SSL=1 DESTDIR=${{ github.workspace }}/make-install install
- name: Install libvalkey using CMake
run: |
mkdir build && cd build
cmake -DDISABLE_TESTS=ON -DENABLE_SSL=ON ..
make DESTDIR=${{ github.workspace }}/cmake-install install
- name: Build examples with Makefile using a Makefile-installed libvalkey
run: |
make CFLAGS="-I${{ github.workspace }}/make-install/usr/local/include" \
STLIBNAME="${{ github.workspace }}/make-install/usr/local/lib/libvalkey.a" \
-C examples
- name: Build examples with Makefile using a CMake-installed libvalkey
run: |
make CFLAGS="-I${{ github.workspace }}/cmake-install/usr/local/include" \
STLIBNAME="${{ github.workspace }}/cmake-install/usr/local/lib/libvalkey.a" \
-C examples
- name: Build examples with CMake using a CMake-installed libvalkey
run: |
examples/using_cmake_externalproject/build.sh
examples/using_cmake_separate/build.sh
examples/using_cmake_and_make_mixed/build.sh
examples/using_make/build.sh
cd examples && mkdir build && cd build
cmake -DCMAKE_PREFIX_PATH=${{ github.workspace }}/cmake-install/usr/local -DENABLE_SSL=ON ..
make
macos:
name: macOS
Expand Down
18 changes: 5 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ OPTION(ENABLE_SSL "Build valkey_ssl for SSL support" OFF)
OPTION(DISABLE_TESTS "If tests should be compiled or not" OFF)
OPTION(ENABLE_EXAMPLES "Enable building valkey examples" OFF)
option(ENABLE_IPV6_TESTS "Enable IPv6 tests requiring special prerequisites" OFF)
# Historically, the NuGet file was always install; default
# to ON for those who rely on that historical behaviour.
OPTION(ENABLE_NUGET "Install NuGET packaging details" ON)
OPTION(ENABLE_NUGET "Install NuGET packaging details" OFF)

# valkey requires C99
SET(CMAKE_C_STANDARD 99)
Expand Down Expand Up @@ -72,7 +70,7 @@ ENDIF()

TARGET_INCLUDE_DIRECTORIES(valkey
PUBLIC
$<INSTALL_INTERFACE:include/valkey>
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/valkey>
)

Expand Down Expand Up @@ -122,11 +120,8 @@ if (ENABLE_NUGET)
DESTINATION build/native)
endif()

INSTALL(FILES valkey.h read.h sds.h async.h alloc.h sockcompat.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/valkey)

INSTALL(DIRECTORY adapters
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/valkey)
install(DIRECTORY include/valkey
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/valkey.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
Expand Down Expand Up @@ -173,7 +168,7 @@ IF(ENABLE_SSL)

TARGET_INCLUDE_DIRECTORIES(valkey_ssl
PRIVATE
$<INSTALL_INTERFACE:include/valkey>
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/valkey>
)

Expand Down Expand Up @@ -207,9 +202,6 @@ IF(ENABLE_SSL)
CONFIGURATIONS Debug RelWithDebInfo)
endif()

INSTALL(FILES valkey_ssl.h valkeycluster_ssl.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/valkey)

INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/valkey_ssl.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

Expand Down
44 changes: 26 additions & 18 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
cmake_minimum_required(VERSION 3.0.0)
project(examples LANGUAGES C)

# Add path to enable <valkey/x.h> includes
include_directories(${CMAKE_SOURCE_DIR}/include)
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
# This CMakeLists.txt is used standalone to build the examples.
# Find required valkey package to get include paths.
find_package(valkey REQUIRED)
find_package(valkey_ssl QUIET)
else()
# This CMakeLists.txt is included, most likely from libvalkey's project
# CMakeLists.txt. Add path to enable <valkey/x.h> includes.
include_directories(${CMAKE_SOURCE_DIR}/include)
endif()

# Check for GLib
find_package(PkgConfig QUIET)
Expand All @@ -11,7 +19,7 @@ if(PkgConfig_FOUND)
if(GLIB2_FOUND)
add_executable(example-async-glib async-glib.c)
target_include_directories(example-async-glib PUBLIC ${GLIB2_INCLUDE_DIRS})
target_link_libraries(example-async-glib valkey ${GLIB2_LIBRARIES})
target_link_libraries(example-async-glib valkey::valkey ${GLIB2_LIBRARIES})
endif()
endif()

Expand All @@ -20,72 +28,72 @@ find_path(LIBEV ev.h
ENV LIBEV_INCLUDE_DIR)
if(LIBEV)
add_executable(example-async-libev async-libev.c)
target_link_libraries(example-async-libev valkey ev)
target_link_libraries(example-async-libev valkey::valkey ev)
endif()

find_path(LIBEVENT event.h)
if(LIBEVENT)
add_executable(example-async-libevent async-libevent.c)
target_link_libraries(example-async-libevent valkey event)
target_link_libraries(example-async-libevent valkey::valkey event)

if(ENABLE_SSL)
add_executable(example-async-libevent-ssl async-libevent-ssl.c)
target_link_libraries(example-async-libevent-ssl valkey valkey_ssl event)
target_link_libraries(example-async-libevent-ssl valkey::valkey valkey::valkey_ssl event)
endif()
endif()

find_path(LIBHV hv/hv.h)
if(LIBHV)
add_executable(example-async-libhv async-libhv.c)
target_link_libraries(example-async-libhv valkey hv)
target_link_libraries(example-async-libhv valkey::valkey hv)
endif()

find_path(LIBUV uv.h)
if(LIBUV)
add_executable(example-async-libuv async-libuv.c)
target_link_libraries(example-async-libuv valkey uv)
target_link_libraries(example-async-libuv valkey::valkey uv)
endif()

find_path(LIBSDEVENT systemd/sd-event.h)
if(LIBSDEVENT)
add_executable(example-async-libsdevent async-libsdevent.c)
target_link_libraries(example-async-libsdevent valkey systemd)
target_link_libraries(example-async-libsdevent valkey::valkey systemd)
endif()

if(APPLE)
find_library(CF CoreFoundation)
add_executable(example-async-macosx async-macosx.c)
target_link_libraries(example-async-macosx valkey ${CF})
target_link_libraries(example-async-macosx valkey::valkey ${CF})
endif()

if(ENABLE_SSL)
add_executable(example-blocking-ssl blocking-ssl.c)
target_link_libraries(example-blocking-ssl valkey valkey_ssl)
target_link_libraries(example-blocking-ssl valkey::valkey valkey::valkey_ssl)
endif()

add_executable(example-blocking blocking.c)
target_link_libraries(example-blocking valkey)
target_link_libraries(example-blocking valkey::valkey)

add_executable(example-blocking-push blocking-push.c)
target_link_libraries(example-blocking-push valkey)
target_link_libraries(example-blocking-push valkey::valkey)

if(LIBEVENT)
add_executable(example-cluster-async cluster-async.c)
target_link_libraries(example-cluster-async valkey event)
target_link_libraries(example-cluster-async valkey::valkey event)

if(ENABLE_SSL)
add_executable(example-cluster-async-tls cluster-async-tls.c)
target_link_libraries(example-cluster-async-tls valkey valkey_ssl event)
target_link_libraries(example-cluster-async-tls valkey::valkey valkey::valkey_ssl event)
endif()

add_executable(example-cluster-clientside-caching-async cluster-clientside-caching-async.c)
target_link_libraries(example-cluster-clientside-caching-async valkey event)
target_link_libraries(example-cluster-clientside-caching-async valkey::valkey event)
endif()

add_executable(example-cluster-simple cluster-simple.c)
target_link_libraries(example-cluster-simple valkey)
target_link_libraries(example-cluster-simple valkey::valkey)

if(ENABLE_SSL)
add_executable(example-cluster-tls cluster-tls.c)
target_link_libraries(example-cluster-tls valkey valkey_ssl)
target_link_libraries(example-cluster-tls valkey::valkey valkey::valkey_ssl)
endif()
4 changes: 2 additions & 2 deletions examples/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CC?=gcc
CXX?=g++

CFLAGS=-Wall -Wextra -g -O2 -I../include
STLIBNAME=../lib/libvalkey.a
CFLAGS?=-Wall -Wextra -g -O2 -I../include
STLIBNAME?=../lib/libvalkey.a

# Define examples
EXAMPLES=example-blocking example-blocking-push example-async-libevent \
Expand Down
36 changes: 0 additions & 36 deletions libvalkeycluster/examples/using_cmake_and_make_mixed/build.sh

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions libvalkeycluster/examples/using_cmake_externalproject/build.sh

This file was deleted.

40 changes: 0 additions & 40 deletions libvalkeycluster/examples/using_cmake_separate/build.sh

This file was deleted.

Loading
Loading