From daf8537092e49e2518e4a744aa9e69c3ae98e21b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Svensson?= Date: Fri, 11 Oct 2024 08:25:37 +0200 Subject: [PATCH] Modify the `nodeIterator` layout and update CI (#114) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modify the `nodeIterator` layout to get a common size in 32bit architectures, which fixes the alignment for 32bit (arm, ppc and mips). - Add additional targets for cross-compilations to make sure future changes in opaque structures works. - Move 32bit CI job and remove redundant job. Signed-off-by: Björn Svensson --- .github/workflows/build.yml | 36 ++++++++++++++++++- .github/workflows/ci.yml | 22 ++++++++++++ .github/workflows/test.yml | 71 ------------------------------------- include/valkey/cluster.h | 2 -- src/cluster.c | 2 +- 5 files changed, 58 insertions(+), 75 deletions(-) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6d02f589..2e347832 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,5 @@ -name: Build and test +name: Other targets + on: [push, pull_request] jobs: @@ -77,3 +78,36 @@ jobs: run: | gmake mkdir build && cd build && cmake .. && gmake + + build-cross: + name: Cross-compile ${{ matrix.config.target }} + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + config: + - {target: arm, host: arm-linux-gnueabi, qemu: arm, gccver: 12 } + - {target: armhf, host: arm-linux-gnueabihf, qemu: arm, gccver: 12 } + - {target: aarch64, host: aarch64-linux-gnu, qemu: aarch64, gccver: 12 } + - {target: riscv64, host: riscv64-linux-gnu, qemu: riscv64, gccver: 12 } + - {target: ppc, host: powerpc-linux-gnu, qemu: ppc, gccver: 12 } + - {target: ppc64, host: powerpc64-linux-gnu, qemu: ppc64, gccver: 12 } + - {target: ppc64le, host: powerpc64le-linux-gnu, qemu: ppc64le, gccver: 12 } + - {target: s390x, host: s390x-linux-gnu, qemu: s390x, gccver: 12 } + - {target: mips, host: mips-linux-gnu, qemu: mips, gccver: 10 } + - {target: mips64, host: mips64-linux-gnuabi64, qemu: mips64, gccver: 10 } + - {target: mipsel, host: mipsel-linux-gnu, qemu: mipsel, gccver: 10 } + - {target: mips64el, host: mips64el-linux-gnuabi64, qemu: mips64el, gccver: 10 } + steps: + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + - name: Prepare + uses: awalsh128/cache-apt-pkgs-action@a6c3917cc929dd0345bfb2d3feaf9101823370ad # v1.4.2 + with: + packages: gcc-${{ matrix.config.gccver }}-${{ matrix.config.host }} + version: ${{ matrix.config.target }}-1.0 + - name: Build + env: + CC: ${{ matrix.config.host }}-gcc-${{ matrix.config.gccver }} + AR: ${{ matrix.config.host }}-ar + run: | + make diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e69f3f4..71a00c02 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,6 +117,28 @@ jobs: TEST_PREFIX: valgrind --error-exitcode=99 --track-origins=yes --leak-check=full run: ./test.sh + ubuntu-32bit: + name: Build for 32-bit + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + - name: Prepare + uses: awalsh128/cache-apt-pkgs-action@a6c3917cc929dd0345bfb2d3feaf9101823370ad # v1.4.2 + with: + packages: gcc-multilib + version: 1.0 + - name: Install Valkey + run: | + git clone --depth 1 --branch 7.2.5 https://github.com/valkey-io/valkey.git + cd valkey && sudo BUILD_TLS=yes make install + - name: Build + run: | + make 32bit + - name: Run tests + working-directory: tests + run: | + ./test.sh + install: name: Installation tests runs-on: ubuntu-latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index a975f62b..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: C/C++ CI - -on: [push, pull_request] - -jobs: - full-build: - name: Build all, plus default examples, run tests against redis - runs-on: ubuntu-latest - env: - # the docker image used by the test.sh - REDIS_DOCKER: redis:alpine - - steps: - - name: Install prerequisites - run: sudo apt-get update && sudo apt-get install -y libev-dev libevent-dev libglib2.0-dev libssl-dev valgrind - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - - name: Run make - run: make all examples - - name: Run unittests - run: make check - - name: Run tests with valgrind - env: - TEST_PREFIX: valgrind --error-exitcode=100 - SKIPS_ARG: --skip-throughput - run: make check - - build-32-bit: - name: Build and test minimal 32 bit linux - runs-on: ubuntu-latest - steps: - - name: Install prerequisites - run: sudo apt-get update && sudo apt-get install gcc-multilib - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - - name: Run make - run: make 32bit - - name: Run unittests - env: - REDIS_DOCKER: redis:alpine - run: make check - - build-arm: - name: Cross-compile and test arm linux with Qemu - runs-on: ubuntu-latest - strategy: - matrix: - include: - - name: arm - toolset: arm-linux-gnueabi - emulator: qemu-arm - - name: aarch64 - toolset: aarch64-linux-gnu - emulator: qemu-aarch64 - - steps: - - name: Install qemu - if: matrix.emulator - run: sudo apt-get update && sudo apt-get install -y qemu-user - - name: Install platform toolset - if: matrix.toolset - run: sudo apt-get install -y gcc-${{matrix.toolset}} - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - - name: Run make - run: make all - env: - CC: ${{matrix.toolset}}-gcc - AR: ${{matrix.toolset}}-ar - - name: Run unittests - env: - REDIS_DOCKER: redis:alpine - TEST_PREFIX: ${{matrix.emulator}} -L /usr/${{matrix.toolset}}/ - run: make check diff --git a/include/valkey/cluster.h b/include/valkey/cluster.h index 7a9bd844..fda08724 100644 --- a/include/valkey/cluster.h +++ b/include/valkey/cluster.h @@ -150,8 +150,6 @@ typedef struct valkeyClusterAsyncContext { #if UINTPTR_MAX == UINT64_MAX #define VALKEY_NODE_ITERATOR_SIZE 56 -#elif defined(__arm__) -#define VALKEY_NODE_ITERATOR_SIZE 40 #else #define VALKEY_NODE_ITERATOR_SIZE 32 #endif diff --git a/src/cluster.c b/src/cluster.c index 3facef16..c1c6038f 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -3542,8 +3542,8 @@ void valkeyClusterAsyncFree(valkeyClusterAsyncContext *acc) { } struct nodeIterator { - valkeyClusterContext *cc; uint64_t route_version; + valkeyClusterContext *cc; int retries_left; dictIterator di; };