Skip to content

Commit

Permalink
CI fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Björn Svensson <[email protected]>
  • Loading branch information
bjosv committed Jun 26, 2024
1 parent 8cd807d commit fb0d765
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ jobs:
- uses: actions/checkout@v3

- name: Build in FreeBSD
uses: vmactions/[email protected].5
uses: vmactions/freebsd-vm@f8be330398166d1eb0601f01353839d4052367b2 # v1.0.7
with:
prepare: pkg install -y gmake cmake
run: |
mkdir build && cd build && cmake .. && make && cd ..
gmake
mkdir build && cd build && cmake .. && gmake
macos:
name: macOS
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: C/C++ CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
on: [push, pull_request]

jobs:
full-build:
Expand Down
12 changes: 6 additions & 6 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
INCLUDE(FindPkgConfig)
# Check for GLib

PKG_CHECK_MODULES(GLIB2 glib-2.0)
if (GLIB2_FOUND)
find_package(PkgConfig)
if(PkgConfig_FOUND)
pkg_check_modules(GLIB2 glib-2.0)
if (GLIB2_FOUND)
INCLUDE_DIRECTORIES(${GLIB2_INCLUDE_DIRS})
LINK_DIRECTORIES(${GLIB2_LIBRARY_DIRS})
ADD_EXECUTABLE(async-glib async-glib.c)
TARGET_LINK_LIBRARIES(async-glib valkey ${GLIB2_LIBRARIES})
ENDIF(GLIB2_FOUND)
endif()
endif()

FIND_PATH(LIBEV ev.h
HINTS /usr/local /usr/opt/local
Expand Down
25 changes: 14 additions & 11 deletions tests/test_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
#include <stdlib.h>
#include <string.h>

static int valkey_version_major;
static int valkey_version_minor;
static int server_version_major;
static int server_version_minor;

/* Helper to extract Valkey version information. */
/* Helper to extract version information. */
#define VALKEY_VERSION_FIELD "valkey_version:"
#define REDIS_VERSION_FIELD "redis_version:"
void load_valkey_version(valkeyClusterContext *cc) {
valkeyClusterNodeIterator ni;
valkeyClusterNode *node;
Expand All @@ -22,20 +23,22 @@ void load_valkey_version(valkeyClusterContext *cc) {
reply = valkeyClusterCommandToNode(cc, node, "INFO");
if (reply == NULL || cc->err || reply->type != VALKEY_REPLY_STRING)
goto abort;
if ((s = strstr(reply->str, VALKEY_VERSION_FIELD)) == NULL)
if ((s = strstr(reply->str, VALKEY_VERSION_FIELD)) != NULL)
s += strlen(VALKEY_VERSION_FIELD);
else if ((s = strstr(reply->str, REDIS_VERSION_FIELD)) != NULL)
s += strlen(REDIS_VERSION_FIELD);
else
goto abort;

s += strlen(VALKEY_VERSION_FIELD);

/* We need a field terminator and at least 'x.y.z' (5) bytes of data */
if ((e = strstr(s, "\r\n")) == NULL || (e - s) < 5)
goto abort;

/* Extract version info */
valkey_version_major = strtol(s, &eptr, 10);
server_version_major = strtol(s, &eptr, 10);
if (*eptr != '.')
goto abort;
valkey_version_minor = strtol(eptr + 1, NULL, 10);
server_version_minor = strtol(eptr + 1, NULL, 10);

freeReplyObject(reply);
return;
Expand All @@ -48,14 +51,14 @@ void load_valkey_version(valkeyClusterContext *cc) {

/* Helper to verify Valkey version information. */
int valkey_version_less_than(int major, int minor) {
if (valkey_version_major == 0) {
if (server_version_major == 0) {
fprintf(stderr, "Error: Valkey version not loaded, aborting..\n");
exit(1);
}

if (valkey_version_major < major)
if (server_version_major < major)
return 1;
if (valkey_version_major == major && valkey_version_minor < minor)
if (server_version_major == major && server_version_minor < minor)
return 1;
return 0;
}

0 comments on commit fb0d765

Please sign in to comment.