From 0cac8dae1b161f400d81bf789fb3713d6dc2a18e Mon Sep 17 00:00:00 2001 From: michael-grunder Date: Sun, 10 Oct 2021 11:58:19 -0700 Subject: Switch to GitHub actions Since TravisCI.org was deprecated we've been without any tests. This commit adds back basic tests in Ubuntu, CentOS, and MacOS. More sophisticated tests/platforms to come in the future (e.g. 32bit tests). See: #992 --- .github/workflows/build.yml | 65 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/build.yml (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..e2d94c5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,65 @@ +name: Build and test +on: push + +jobs: + ubuntu: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + repository: ${{ env.GITHUB_REPOSITORY }} + ref: ${{ env.GITHUB_HEAD_REF }} + + - name: Install redis-server + run: | + sudo add-apt-repository -y ppa:chris-lea/redis-server + sudo apt-get update + sudo apt-get install -y redis-server + + - name: Build hiredis + run: USE_SSL=1 make + + - name: Run tests + run: $GITHUB_WORKSPACE/test.sh + + centos7: + runs-on: ubuntu-latest + container: centos:7 + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + repository: ${{ env.GITHUB_REPOSITORY }} + ref: ${{ env.GITHUB_HEAD_REF }} + + - name: Install redis-server + run: | + yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm + yum -y --enablerepo=remi install redis + yum -y install gcc make openssl-devel + + - name: Build hiredis + run: USE_SSL=1 make + + - name: Run tests + run: $GITHUB_WORKSPACE/test.sh + + macos: + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + repository: ${{ env.GITHUB_REPOSITORY }} + ref: ${{ env.GITHUB_HEAD_REF }} + + - name: Install dependencies + run: | + brew install openssl redis + + - name: Build hiredis + run: USE_SSL=1 make + + - name: Run tests + run: $GITHUB_WORKSPACE/test.sh -- cgit v1.2.3 From 783a3789c2c2a7fb1cc28c33d532a4366db9100a Mon Sep 17 00:00:00 2001 From: michael-grunder Date: Sun, 10 Oct 2021 13:38:39 -0700 Subject: Add Windows tests in GitHub actions See: #992 TODO: MinGW/cygwin tests --- .github/workflows/build.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e2d94c5..3f146db 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -63,3 +63,27 @@ jobs: - name: Run tests run: $GITHUB_WORKSPACE/test.sh + + windows: + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + repository: ${{ env.GITHUB_REPOSITORY }} + ref: ${{ env.GITHUB_HEAD_REF }} + + - name: Install dependencies + run: | + choco install -y ninja memurai-developer + + - uses: ilammy/msvc-dev-cmd@v1 + - name: Build hiredis + run: | + mkdir build && cd build + cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DENABLE_EXAMPLES=ON + ninja -v + + - name: Run tests + run: | + ./build/hiredis-test.exe -- cgit v1.2.3 From 6ad4ccf3c7c6bed282f55d4658462b8c40c6ad39 Mon Sep 17 00:00:00 2001 From: michael-grunder Date: Sun, 10 Oct 2021 15:47:15 -0700 Subject: Add Cygwin build test --- .github/workflows/build.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3f146db..9053d27 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -87,3 +87,21 @@ jobs: - name: Run tests run: | ./build/hiredis-test.exe + + - name: Setup cygwin + uses: egor-tensin/setup-cygwin@v3 + with: + platform: x64 + packages: cmake gcc-core gcc-g++ + + - name: Build in cygwin + env: + HIREDIS_PATH: ${{ github.workspace }} + run: | + build_hiredis() { + cd $(cygpath -u $HIREDIS_PATH) + rm -rf build && mkdir build && cd build + cmake .. -G "Unix Makefiles" && make VERBOSE=1 + } + build_hiredis + shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}' -- cgit v1.2.3 From e9f64738450374e7f324c99988308d7d1f16451d Mon Sep 17 00:00:00 2001 From: michael-grunder Date: Tue, 12 Oct 2021 13:17:45 -0700 Subject: We should run actions on PRs --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9053d27..fbf1596 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,5 @@ name: Build and test -on: push +on: [push, pull_request] jobs: ubuntu: -- cgit v1.2.3 From b73c2d410f4c7c2510cf63e98660bab2ca82fbc9 Mon Sep 17 00:00:00 2001 From: michael-grunder Date: Tue, 12 Oct 2021 13:49:17 -0700 Subject: Add Centos8 I'm sure this can be done with a container matrix but figuring that out is left for another day. --- .github/workflows/build.yml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fbf1596..25d4fa3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,7 @@ jobs: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} - - name: Install redis-server + - name: Install dependencies run: | yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum -y --enablerepo=remi install redis @@ -45,6 +45,29 @@ jobs: - name: Run tests run: $GITHUB_WORKSPACE/test.sh + centos8: + runs-on: ubuntu-latest + container: centos:8 + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + repository: ${{ env.GITHUB_REPOSITORY }} + ref: ${{ env.GITHUB_HEAD_REF }} + + - name: Install dependencies + run: | + dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm + dnf -y module install redis:remi-6.0 + dnf -y group install "Development Tools" + dnf -y install openssl-devel + + - name: Build hiredis + run: USE_SSL=1 make + + - name: Run tests + run: $GITHUB_WORKSPACE/test.sh + macos: runs-on: macos-latest steps: -- cgit v1.2.3 From 4a126e8a9c52ac2fd0bb46cae57afa3f1cb44fd6 Mon Sep 17 00:00:00 2001 From: michael-grunder Date: Wed, 13 Oct 2021 12:15:54 -0700 Subject: Add valgrind and CMake to tests --- .github/workflows/build.yml | 61 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 8 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 25d4fa3..a787700 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,18 +11,33 @@ jobs: repository: ${{ env.GITHUB_REPOSITORY }} ref: ${{ env.GITHUB_HEAD_REF }} - - name: Install redis-server + - name: Install dependencies run: | sudo add-apt-repository -y ppa:chris-lea/redis-server sudo apt-get update - sudo apt-get install -y redis-server - - - name: Build hiredis + sudo apt-get install -y redis-server valgrind + + - name: Build using cmake + env: + EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON + CFLAGS: -Werror + CXXFLAGS: -Werror + run: mkdir build-ubuntu && cd build-ubuntu && cmake .. + + - name: Build using makefile run: USE_SSL=1 make - name: Run tests + env: + SKIPS_AS_FAILS: 1 run: $GITHUB_WORKSPACE/test.sh + # - name: Run tests under valgrind + # env: + # SKIPS_AS_FAILS: 1 + # TEST_PREFIX: valgrind --track-origins=yes --leak-check=full + # run: $GITHUB_WORKSPACE/test.sh + centos7: runs-on: ubuntu-latest container: centos:7 @@ -37,12 +52,27 @@ jobs: run: | yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum -y --enablerepo=remi install redis - yum -y install gcc make openssl-devel + yum -y install gcc gcc-c++ make openssl-devel cmake3 valgrind - - name: Build hiredis + - name: Build using cmake + env: + EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON + CFLAGS: -Werror + CXXFLAGS: -Werror + run: mkdir build-centos7 && cd build-centos7 && cmake3 .. + + - name: Build using Makefile run: USE_SSL=1 make - name: Run tests + env: + SKIPS_AS_FAILS: 1 + run: $GITHUB_WORKSPACE/test.sh + + - name: Run tests under valgrind + env: + SKIPS_AS_FAILS: 1 + TEST_PREFIX: valgrind --track-origins=yes --leak-check=full run: $GITHUB_WORKSPACE/test.sh centos8: @@ -60,12 +90,27 @@ jobs: dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm dnf -y module install redis:remi-6.0 dnf -y group install "Development Tools" - dnf -y install openssl-devel + dnf -y install openssl-devel cmake valgrind - - name: Build hiredis + - name: Build using cmake + env: + EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON + CFLAGS: -Werror + CXXFLAGS: -Werror + run: mkdir build-centos8 && cd build-centos8 && cmake .. + + - name: Build using Makefile run: USE_SSL=1 make - name: Run tests + env: + SKIPS_AS_FAILS: 1 + run: $GITHUB_WORKSPACE/test.sh + + - name: Run tests under valgrind + env: + SKIPS_AS_FAILS: 1 + TEST_PREFIX: valgrind --track-origins=yes --leak-check=full run: $GITHUB_WORKSPACE/test.sh macos: -- cgit v1.2.3 From 30ff8d850e3cbc26064c5bc6ad4edbc34addd15d Mon Sep 17 00:00:00 2001 From: Björn Svensson Date: Wed, 20 Oct 2021 10:44:18 +0200 Subject: Run SSL tests in CI --- .github/workflows/build.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a787700..2ce06a1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,6 +30,7 @@ jobs: - name: Run tests env: SKIPS_AS_FAILS: 1 + TEST_SSL: 1 run: $GITHUB_WORKSPACE/test.sh # - name: Run tests under valgrind @@ -52,7 +53,7 @@ jobs: run: | yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum -y --enablerepo=remi install redis - yum -y install gcc gcc-c++ make openssl-devel cmake3 valgrind + yum -y install gcc gcc-c++ make openssl openssl-devel cmake3 valgrind - name: Build using cmake env: @@ -67,11 +68,13 @@ jobs: - name: Run tests env: SKIPS_AS_FAILS: 1 + TEST_SSL: 1 run: $GITHUB_WORKSPACE/test.sh - name: Run tests under valgrind env: SKIPS_AS_FAILS: 1 + TEST_SSL: 1 TEST_PREFIX: valgrind --track-origins=yes --leak-check=full run: $GITHUB_WORKSPACE/test.sh @@ -105,11 +108,13 @@ jobs: - name: Run tests env: SKIPS_AS_FAILS: 1 + TEST_SSL: 1 run: $GITHUB_WORKSPACE/test.sh - name: Run tests under valgrind env: SKIPS_AS_FAILS: 1 + TEST_SSL: 1 TEST_PREFIX: valgrind --track-origins=yes --leak-check=full run: $GITHUB_WORKSPACE/test.sh @@ -130,6 +135,8 @@ jobs: run: USE_SSL=1 make - name: Run tests + env: + TEST_SSL: 1 run: $GITHUB_WORKSPACE/test.sh windows: -- cgit v1.2.3 From 648763c36e9f6493b13a77da35eb33ef0652b4e2 Mon Sep 17 00:00:00 2001 From: Björn Svensson Date: Mon, 25 Oct 2021 10:13:48 +0200 Subject: Add build options for enabling async tests Asynchronous testcases that requires the event library `libevent` can be built and enabled by using the added build flags: - ENABLE_ASYNC_TESTS when using CMake - TEST_ASYNC when using Make The async tests are disabled by default to avoid adding new requirements, but the testcases are built and run in CI. --- .github/workflows/build.yml | 18 +++++++++--------- CMakeLists.txt | 10 +++++++--- Makefile | 6 ++++++ 3 files changed, 22 insertions(+), 12 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2ce06a1..af834ab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,17 +15,17 @@ jobs: run: | sudo add-apt-repository -y ppa:chris-lea/redis-server sudo apt-get update - sudo apt-get install -y redis-server valgrind + sudo apt-get install -y redis-server valgrind libevent-dev - name: Build using cmake env: - EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON + EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON -DENABLE_ASYNC_TESTS:BOOL=ON CFLAGS: -Werror CXXFLAGS: -Werror run: mkdir build-ubuntu && cd build-ubuntu && cmake .. - name: Build using makefile - run: USE_SSL=1 make + run: USE_SSL=1 TEST_ASYNC=1 make - name: Run tests env: @@ -53,17 +53,17 @@ jobs: run: | yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum -y --enablerepo=remi install redis - yum -y install gcc gcc-c++ make openssl openssl-devel cmake3 valgrind + yum -y install gcc gcc-c++ make openssl openssl-devel cmake3 valgrind libevent-devel - name: Build using cmake env: - EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON + EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON -DENABLE_ASYNC_TESTS:BOOL=ON CFLAGS: -Werror CXXFLAGS: -Werror run: mkdir build-centos7 && cd build-centos7 && cmake3 .. - name: Build using Makefile - run: USE_SSL=1 make + run: USE_SSL=1 TEST_ASYNC=1 make - name: Run tests env: @@ -93,17 +93,17 @@ jobs: dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm dnf -y module install redis:remi-6.0 dnf -y group install "Development Tools" - dnf -y install openssl-devel cmake valgrind + dnf -y install openssl-devel cmake valgrind libevent-devel - name: Build using cmake env: - EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON + EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON -DENABLE_ASYNC_TESTS:BOOL=ON CFLAGS: -Werror CXXFLAGS: -Werror run: mkdir build-centos8 && cd build-centos8 && cmake .. - name: Build using Makefile - run: USE_SSL=1 make + run: USE_SSL=1 TEST_ASYNC=1 make - name: Run tests env: diff --git a/CMakeLists.txt b/CMakeLists.txt index eb43f01..6d290a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ PROJECT(hiredis) OPTION(ENABLE_SSL "Build hiredis_ssl for SSL support" OFF) OPTION(DISABLE_TESTS "If tests should be compiled or not" OFF) OPTION(ENABLE_SSL_TESTS "Should we test SSL connections" OFF) +OPTION(ENABLE_ASYNC_TESTS "Should we run all asynchronous API tests" OFF) MACRO(getVersionBit name) SET(VERSION_REGEX "^#define ${name} (.+)$") @@ -218,11 +219,14 @@ ENDIF() IF(NOT DISABLE_TESTS) ENABLE_TESTING() ADD_EXECUTABLE(hiredis-test test.c) + TARGET_LINK_LIBRARIES(hiredis-test hiredis) IF(ENABLE_SSL_TESTS) ADD_DEFINITIONS(-DHIREDIS_TEST_SSL=1) - TARGET_LINK_LIBRARIES(hiredis-test hiredis hiredis_ssl) - ELSE() - TARGET_LINK_LIBRARIES(hiredis-test hiredis) + TARGET_LINK_LIBRARIES(hiredis-test hiredis_ssl) + ENDIF() + IF(ENABLE_ASYNC_TESTS) + ADD_DEFINITIONS(-DHIREDIS_TEST_ASYNC=1) + TARGET_LINK_LIBRARIES(hiredis-test event) ENDIF() ADD_TEST(NAME hiredis-test COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test.sh) diff --git a/Makefile b/Makefile index 34c7909..f30c2ac 100644 --- a/Makefile +++ b/Makefile @@ -75,6 +75,9 @@ USE_SSL?=0 ifeq ($(USE_SSL),1) export CFLAGS+=-DHIREDIS_TEST_SSL endif +ifeq ($(TEST_ASYNC),1) + export CFLAGS+=-DHIREDIS_TEST_ASYNC +endif ifeq ($(uname_S),Linux) ifdef OPENSSL_PREFIX @@ -211,6 +214,9 @@ ifeq ($(USE_SSL),1) TEST_LIBS += $(SSL_STLIBNAME) TEST_LDFLAGS = $(SSL_LDFLAGS) -lssl -lcrypto -lpthread endif +ifeq ($(TEST_ASYNC),1) + TEST_LDFLAGS += -levent +endif hiredis-test: test.o $(TEST_LIBS) $(CC) -o $@ $(REAL_CFLAGS) -I. $^ $(REAL_LDFLAGS) $(TEST_LDFLAGS) -- cgit v1.2.3 From 1aed21a8c50fe075e8abce9db30c3860673f0fc7 Mon Sep 17 00:00:00 2001 From: Michael Grunder Date: Thu, 18 Nov 2021 13:50:09 -0800 Subject: Move to using make directly in Cygwin (#1020) CMake started hanging when trying to detect the C compiler ABI in cygin, so for now just build with make directly. --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index af834ab..c43beb6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -167,7 +167,7 @@ jobs: uses: egor-tensin/setup-cygwin@v3 with: platform: x64 - packages: cmake gcc-core gcc-g++ + packages: make git gcc-core - name: Build in cygwin env: @@ -175,8 +175,8 @@ jobs: run: | build_hiredis() { cd $(cygpath -u $HIREDIS_PATH) - rm -rf build && mkdir build && cd build - cmake .. -G "Unix Makefiles" && make VERBOSE=1 + git clean -xfd + make } build_hiredis shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}' -- cgit v1.2.3 From b5716ee82926316f7764b834eec636f5652d5600 Mon Sep 17 00:00:00 2001 From: Bjorn Svensson Date: Thu, 25 Nov 2021 08:09:23 +0100 Subject: Valgrind returns error exit code when errors found (#1011) By default Valgrind will return the exit code from the tested process. Since our test can return 0 (ALL TESTS PASS) even when a leak was found we need to tell Valgrind to return an error code. This will fail the CI job when issues are found. --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c43beb6..e4dde05 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: # - name: Run tests under valgrind # env: # SKIPS_AS_FAILS: 1 - # TEST_PREFIX: valgrind --track-origins=yes --leak-check=full + # TEST_PREFIX: valgrind --error-exitcode=99 --track-origins=yes --leak-check=full # run: $GITHUB_WORKSPACE/test.sh centos7: @@ -75,7 +75,7 @@ jobs: env: SKIPS_AS_FAILS: 1 TEST_SSL: 1 - TEST_PREFIX: valgrind --track-origins=yes --leak-check=full + TEST_PREFIX: valgrind --error-exitcode=99 --track-origins=yes --leak-check=full run: $GITHUB_WORKSPACE/test.sh centos8: @@ -115,7 +115,7 @@ jobs: env: SKIPS_AS_FAILS: 1 TEST_SSL: 1 - TEST_PREFIX: valgrind --track-origins=yes --leak-check=full + TEST_PREFIX: valgrind --error-exitcode=99 --track-origins=yes --leak-check=full run: $GITHUB_WORKSPACE/test.sh macos: -- cgit v1.2.3