From a4d7d3a41e99f07a2e05c1106dcc695551304447 Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Tue, 1 Oct 2024 14:07:29 +0200 Subject: [PATCH 01/19] Add a simple CI workflow --- .github/workflows/ci.yml | 58 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..b7211d8b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,58 @@ +name: CI + +on: [pull_request] + +jobs: + test: + name: Build and run the unit tests using the latest rust. + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + name: + - stable + os: + - ubuntu-latest + - macos-latest + redis-version: + - 6-0 + - 6-2 + - 7-0 + - 7-2 + toolchain: + - 1.78.0 + - stable + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install toolchain + id: tc + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.toolchain }} + profile: minimal + override: true + components: rustfmt, clippy + + - name: Setup cache + if: runner.os != 'macOS' + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-test-${{ steps.tc.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.toml') }} + + - name: Format and clippy + run: | + cargo fmt --all -- --check + cargo clippy --all-targets --all-features + + - name: Build, test and doc for the available redis versions + run: | + cargo build --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version }} + cargo test --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version }} + cargo doc --all-features From 8c8aca3bd5688fbf0e87007d1d64ccf6ed2615ff Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Tue, 1 Oct 2024 14:07:39 +0200 Subject: [PATCH 02/19] Fix the features specification --- Cargo.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2c0e673a..cef0114c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -140,7 +140,7 @@ anyhow = "1" redis = "0.23" lazy_static = "1" redis-module-macros = { path = "./redismodule-rs-macros"} -redis-module = { path = "./", default-features = false, features = ["min-redis-compatibility-version-7-2"] } +redis-module = { path = "./", default-features = false } [build-dependencies] bindgen = "0.66" @@ -148,7 +148,7 @@ cc = "1" [features] default = ["min-redis-compatibility-version-6-0"] -min-redis-compatibility-version-7-2 = [] -min-redis-compatibility-version-7-0 = [] -min-redis-compatibility-version-6-2 = [] -min-redis-compatibility-version-6-0 = [] +min-redis-compatibility-version-7-2 = ["redis-module/min-redis-compatibility-version-7-2"] +min-redis-compatibility-version-7-0 = ["redis-module/min-redis-compatibility-version-7-0"] +min-redis-compatibility-version-6-2 = ["redis-module/min-redis-compatibility-version-6-2"] +min-redis-compatibility-version-6-0 = ["redis-module/min-redis-compatibility-version-6-0"] From 2c5f0d6d82fd2cb5a2874aa4f981419894ae0c74 Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Tue, 1 Oct 2024 14:17:47 +0200 Subject: [PATCH 03/19] Install python and redis, split the steps --- .github/workflows/ci.yml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7211d8b..8b15c095 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,10 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v4 + - name: Setup python + uses: actions/setup-python@v5 + with: + python-version: '3.10' - name: Install toolchain id: tc @@ -51,8 +55,20 @@ jobs: cargo fmt --all -- --check cargo clippy --all-targets --all-features - - name: Build, test and doc for the available redis versions + - name: Install redis run: | - cargo build --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version }} - cargo test --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version }} - cargo doc --all-features + export HOMEBREW_NO_AUTO_UPDATE=1 + ./deps/readies/bin/getredis -v '${{ matrix.redis-version }}' --force '' + redis-server --version + + - name: Build debug + run: cargo build --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version }} + + - name: Build release + run: cargo build --release --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version }} + + - name: Test + run: cargo test --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version }} + + - name: Doc + run: cargo doc --all-features From 5f62c84145bf70df506dc5036ce37081527b1c36 Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Tue, 1 Oct 2024 14:21:22 +0200 Subject: [PATCH 04/19] Address the formatting --- redismodule-rs-macros/src/redis_value.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/redismodule-rs-macros/src/redis_value.rs b/redismodule-rs-macros/src/redis_value.rs index 5633f3fd..96228c3c 100644 --- a/redismodule-rs-macros/src/redis_value.rs +++ b/redismodule-rs-macros/src/redis_value.rs @@ -141,8 +141,6 @@ pub fn redis_value(item: TokenStream) -> TokenStream { match struct_input.data { Data::Struct(s) => struct_redis_value(struct_name, s), Data::Enum(e) => enum_redis_value(struct_name, e), - _ => { - quote! {compile_error!("RedisValue derive can only be apply on struct.")}.into() - } + _ => quote! {compile_error!("RedisValue derive can only be apply on struct.")}.into(), } } From dd2c95cef316f32489ce326fe0e8cf643aac50e0 Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Tue, 1 Oct 2024 14:23:37 +0200 Subject: [PATCH 05/19] Specify the features for clippy --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b15c095..254a6dc1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,7 +53,7 @@ jobs: - name: Format and clippy run: | cargo fmt --all -- --check - cargo clippy --all-targets --all-features + cargo clippy --all-targets --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version }} - name: Install redis run: | From 0057c426561386a8742b60da7d9cdd496adf8149 Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Tue, 1 Oct 2024 14:25:23 +0200 Subject: [PATCH 06/19] Git checkout with submodules --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 254a6dc1..cbb459e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,8 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v4 + with: + submodules: recursive - name: Setup python uses: actions/setup-python@v5 with: From 620950f2bf289c176f490e77958bec4244b81c8e Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Tue, 1 Oct 2024 14:30:05 +0200 Subject: [PATCH 07/19] Remove the empty string --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cbb459e3..20c03c73 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,7 +60,7 @@ jobs: - name: Install redis run: | export HOMEBREW_NO_AUTO_UPDATE=1 - ./deps/readies/bin/getredis -v '${{ matrix.redis-version }}' --force '' + ./deps/readies/bin/getredis -v '${{ matrix.redis-version }}' --force redis-server --version - name: Build debug From e2ca4f7ee70311b82dd4abee298b96c6440f29cb Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Tue, 1 Oct 2024 14:31:27 +0200 Subject: [PATCH 08/19] Specify the redis tags and the features differently --- .github/workflows/ci.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20c03c73..0db81d94 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,10 +15,10 @@ jobs: - ubuntu-latest - macos-latest redis-version: - - 6-0 - - 6-2 - - 7-0 - - 7-2 + - [6-0, 6.0] + - [6-2, 6.2] + - [7-0, 7.0] + - [7-2, 7.2] toolchain: - 1.78.0 - stable @@ -55,22 +55,22 @@ jobs: - name: Format and clippy run: | cargo fmt --all -- --check - cargo clippy --all-targets --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version }} + cargo clippy --all-targets --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version[0] }} - name: Install redis run: | export HOMEBREW_NO_AUTO_UPDATE=1 - ./deps/readies/bin/getredis -v '${{ matrix.redis-version }}' --force + ./deps/readies/bin/getredis -v '${{ matrix.redis-version[1] }}' --force redis-server --version - name: Build debug - run: cargo build --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version }} + run: cargo build --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version[0] }} - name: Build release - run: cargo build --release --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version }} + run: cargo build --release --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version[0] }} - name: Test - run: cargo test --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version }} + run: cargo test --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version[0] }} - name: Doc run: cargo doc --all-features From 80a1117cd5cceb5379ff12933098f84e5f5fdb76 Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Tue, 1 Oct 2024 14:39:58 +0200 Subject: [PATCH 09/19] Pass redis version tags as strings instead --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0db81d94..e903189a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,10 +15,10 @@ jobs: - ubuntu-latest - macos-latest redis-version: - - [6-0, 6.0] - - [6-2, 6.2] - - [7-0, 7.0] - - [7-2, 7.2] + - [6-0, "6.0"] + - [6-2, "6.2"] + - [7-0, "7.0"] + - [7-2, "7.2"] toolchain: - 1.78.0 - stable From 772d07a0f55c069de8e83adbb0411e0637eb0674 Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Tue, 1 Oct 2024 14:42:05 +0200 Subject: [PATCH 10/19] Remove the unused matrix parameter --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e903189a..2e9b107d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,8 +9,6 @@ jobs: strategy: fail-fast: false matrix: - name: - - stable os: - ubuntu-latest - macos-latest From e602d2a0f4e34afeb5ab26fc45313a26b4a670a3 Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Tue, 1 Oct 2024 14:44:19 +0200 Subject: [PATCH 11/19] Always test with redis 7.2 --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e9b107d..824e0aa3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,9 +13,9 @@ jobs: - ubuntu-latest - macos-latest redis-version: - - [6-0, "6.0"] - - [6-2, "6.2"] - - [7-0, "7.0"] + - [6-0, "7.2"] + - [6-2, "7.2"] + - [7-0, "7.2"] - [7-2, "7.2"] toolchain: - 1.78.0 From 16409d991f2b90332a643cc5fa8dea377a8b8a63 Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Tue, 1 Oct 2024 15:01:43 +0200 Subject: [PATCH 12/19] Specify macos-14 instead of macos-latest --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 824e0aa3..2ea313bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: matrix: os: - ubuntu-latest - - macos-latest + - macos-14 redis-version: - [6-0, "7.2"] - [6-2, "7.2"] From 31807789b0e5f604e88c1c3e45c49da5a3db50c9 Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Tue, 1 Oct 2024 15:07:25 +0200 Subject: [PATCH 13/19] Delete the .circleci subdirectory --- .circleci/config.yml | 323 ------------------------------------------- 1 file changed, 323 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 6acfc02c..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,323 +0,0 @@ -version: 2.1 - -commands: - early-returns: - steps: - - run: - name: Early return if this is a docs build - command: | - if [[ $CIRCLE_BRANCH == *docs ]]; then - echo "Identifies as documents PR, no testing required." - circleci step halt - fi - - run: - name: Early return if this branch should ignore CI - command: | - if [[ $CIRCLE_BRANCH == *noci ]]; then - echo "Identifies as actively ignoring CI, no testing required." - circleci step halt - fi - - early-return-for-forked-pull-requests: - description: >- - If this build is from a fork, stop executing the current job and return success. - This is useful to avoid steps that will fail due to missing credentials. - steps: - - run: - name: Early return if this build is from a forked PR - command: | - if [[ -n "$CIRCLE_PR_NUMBER" ]]; then - echo "Nothing to do for forked PRs, so marking this step successful" - circleci step halt - fi - - setup-executor: - steps: - - run: - name: Setup executor - command: | - apt-get -qq update - apt-get -q install -y git openssh-client curl ca-certificates make tar gzip - bash <(curl -fsSL https://raw.githubusercontent.com/docker/docker-install/master/install.sh) - - setup_remote_docker: - version: 20.10.14 - docker_layer_caching: true - - checkout-all: - steps: - - checkout - - run: - name: Checkout submodules - command: git submodule update --init --recursive - - setup-automation: - steps: - - run: - name: Setup automation - command: | - git submodule update --init deps/readies - if [[ $(uname -s) == Darwin ]]; then rm -f /usr/local/bin/python3; fi - ./deps/readies/bin/getpy3 - - run: - name: Setup automation (part 2) - shell: /bin/bash -l -eo pipefail - command: | - ls -l /usr/local/bin/python* || true - echo "python3: $(command -v python3)" - python3 --version - python3 -m pip list - - install-prerequisites: - parameters: - redis_version: - type: string - default: "7.2" - getredis_params: - type: string - default: "" - steps: - - setup-automation - - run: - name: Setup build environment - shell: /bin/bash -l -eo pipefail - command: | - ./sbin/system-setup.py - bash -l -c "make info" - - run: - name: Install Redis - shell: /bin/bash -l -eo pipefail - command: | - export HOMEBREW_NO_AUTO_UPDATE=1 - ./deps/readies/bin/getredis -v '<>' --force <> - redis-server --version - - build-steps: - parameters: - build_params: - type: string - default: "" - test_params: - type: string - default: "" - redis_version: - type: string - default: "7.2" - getredis_params: - type: string - default: "" - steps: - - early-returns - - checkout-all - - install-prerequisites: - redis_version: <> - getredis_params: <> - - run: - name: patch macos tests # Avoid AVX with Regex with CircleCI since virtualization layer doesn't support it. Use sed to replace the relevant entry in cargo.toml - command: | - if [[ $(uname -s) == Darwin ]]; then sed -i 's/regex = "1"/regex = { version = "1", features = ["perf", "unicode"], default-features = false }/g' Cargo.toml; fi - cat Cargo.toml - - restore_cache: - keys: - - v3-dependencies-{{ arch }}-{{ checksum "Cargo.toml" }} - - run: - name: Check formatting - shell: /bin/bash -l -eo pipefail - command: make lint - - run: - name: Build debug - shell: /bin/bash -l -eo pipefail - command: make build DEBUG=1 <> - - run: - name: Build release - shell: /bin/bash -l -eo pipefail - command: make build <> - - save_cache: - key: v3-dependencies-{{ arch }}-{{ checksum "Cargo.toml" }} - paths: - - "~/.cargo" - - "./target" - - run: - name: Run tests - shell: /bin/bash -l -eo pipefail - command: make test - - build-platforms-steps: - parameters: - platform: - type: string - steps: - - early-returns - - setup-executor - - checkout-all - - setup-automation - - run: - name: Build for platform - shell: /bin/bash -l -eo pipefail - command: | - cd build/docker - make build OSNICK="<>" VERSION="$CIRCLE_TAG" BRANCH="$CIRCLE_BRANCH" TEST=1 SHOW=1 - - vm-build-platforms-steps: - parameters: - platform: - type: string - steps: - - early-returns - - checkout - - setup-automation - - run: - name: Install Docker - shell: /bin/bash -l -eo pipefail - command: ./deps/readies/bin/getdocker - - run: - name: Build for platform - command: | - cd build/docker - make build OSNICK="<>" VERSION="$CIRCLE_TAG" BRANCH="$CIRCLE_BRANCH" TEST=1 SHOW=1 - no_output_timeout: 30m - -#---------------------------------------------------------------------------------------------------------------------------------- - -jobs: - build-linux-debian: - docker: - - image: redisfab/rmbuilder:6.2.7-x64-bullseye - steps: - - build-steps - - build-platforms: - parameters: - platform: - type: string - docker: - - image: debian:bullseye - steps: - - build-platforms-steps: - platform: <> - - build-arm-platforms: - parameters: - platform: - type: string - machine: - image: ubuntu-2004:202101-01 - resource_class: arm.medium - steps: - - vm-build-platforms-steps: - platform: <> - - build-macos-x64: - macos: - xcode: 15.4.0 - resource_class: macos.m1.large.gen1 - steps: - - run: brew install openssl - - build-steps - - build-macos-m1: - macos: - xcode: 14.2.0 - resource_class: macos.m1.large.gen1 - steps: - - build-steps - -#---------------------------------------------------------------------------------------------------------------------------------- - -on-any-branch: &on-any-branch - filters: - branches: - only: /.*/ - tags: - only: /.*/ - -always: &always - filters: - branches: - only: /.*/ - tags: - only: /.*/ - -never: &never - filters: - branches: - ignore: /.*/ - tags: - ignore: /.*/ - -on-master: &on-master - filters: - branches: - only: master - tags: - ignore: /.*/ - -on-integ-branch: &on-integ-branch - filters: - branches: - only: - - master - - /^\d+\.\d+.*$/ - - /^feature-.*$/ - tags: - ignore: /.*/ - -on-integ-branch-cron: &on-integ-branch-cron - filters: - branches: - only: - - master - - /^\d+\.\d+.*$/ - - /^feature-.*$/ - -not-on-integ-branch: ¬-on-integ-branch - filters: - branches: - ignore: - - master - - /^\d+\.\d+.*$/ - - /^feature-.*$/ - tags: - ignore: /.*/ - -on-version-tags: &on-version-tags - filters: - branches: - ignore: /.*/ - tags: - only: /^v[0-9].*/ - -on-integ-and-version-tags: &on-integ-and-version-tags - filters: - branches: - only: - - master - - /^\d+\.\d+.*$/ - - /^feature-.*$/ - tags: - only: /^v[0-9].*/ - -#---------------------------------------------------------------------------------------------------------------------------------- - -workflows: - version: 2 - default-flow: - jobs: - - build-linux-debian: - name: build - <<: *not-on-integ-branch - - build-platforms: - <<: *on-integ-and-version-tags - context: common - matrix: - parameters: - platform: [jammy, focal, bionic, xenial, rocky8, centos7, bullseye, amzn2] - - build-arm-platforms: - <<: *on-integ-and-version-tags - context: common - matrix: - parameters: - platform: [jammy, bionic, focal] - - build-macos-x64: - <<: *always - - build-macos-m1: - <<: *on-integ-and-version-tags From 2923c116c9d258e70941a6e936ee30586fa62fdf Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Tue, 1 Oct 2024 15:08:55 +0200 Subject: [PATCH 14/19] Revert to using macos-latest in CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ea313bf..824e0aa3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: matrix: os: - ubuntu-latest - - macos-14 + - macos-latest redis-version: - [6-0, "7.2"] - [6-2, "7.2"] From 1136a52f8843a1a2c37d14764bcf763bb35c7ae0 Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Mon, 7 Oct 2024 12:29:06 +0200 Subject: [PATCH 15/19] Guard the call module under 7-2 in the tests --- tests/integration.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration.rs b/tests/integration.rs index bb0bfe77..e8aafb93 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -279,6 +279,7 @@ fn test_stream_reader() -> Result<()> { } #[test] +#[cfg(feature = "min-redis-compatibility-version-7-2")] fn test_call() -> Result<()> { let port: u16 = 6488; let _guards = vec![start_redis_server_with_module("call", port) @@ -630,6 +631,7 @@ fn test_redis_value_derive() -> Result<()> { } #[test] +#[cfg(feature = "min-redis-compatibility-version-7-2")] fn test_call_blocking() -> Result<()> { let port: u16 = 6499; let _guards = vec![start_redis_server_with_module("call", port) From 675a308243798210353e396922f8e8421470fc33 Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Mon, 7 Oct 2024 13:49:39 +0200 Subject: [PATCH 16/19] Install redis ourselves --- .github/workflows/ci.yml | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 824e0aa3..ee681cc8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,24 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive + + - name: Checkout redis sources + uses: actions/checkout@v4 + with: + submodules: recursive + repository: redis/redis + ref: ${{ matrix.redis-version[1] }} + path: redis + + - name: Install redis + run: | + export HOMEBREW_NO_AUTO_UPDATE=1 + cd redis + make -j + ./src/redis-server --version + make install PREFIX=/usr/local + redis-server --version + - name: Setup python uses: actions/setup-python@v5 with: @@ -55,12 +73,6 @@ jobs: cargo fmt --all -- --check cargo clippy --all-targets --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version[0] }} - - name: Install redis - run: | - export HOMEBREW_NO_AUTO_UPDATE=1 - ./deps/readies/bin/getredis -v '${{ matrix.redis-version[1] }}' --force - redis-server --version - - name: Build debug run: cargo build --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version[0] }} From 1188f78d32fcd294530cc954ec3fc7e5bf48faa4 Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Mon, 7 Oct 2024 14:19:41 +0200 Subject: [PATCH 17/19] Delete the FREEBSD CI --- .github/workflows/freebsd.yml | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 .github/workflows/freebsd.yml diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml deleted file mode 100644 index 93c5de08..00000000 --- a/.github/workflows/freebsd.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: freebsd - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - - runs-on: macos-12 - - steps: - - uses: actions/checkout@v3 - - name: build - uses: vmactions/freebsd-vm@v0.3.0 - with: - usesh: true - sync: rsync - copyback: false - prepare: pkg install -y bash curl lang/rust devel/llvm-devel - run: | - cargo build --all --all-targets --verbose - cargo install cargo-deny - cargo deny check licenses - cargo deny check bans - curl https://sh.rustup.rs -sSf > rustup.sh - sh rustup.sh -y - . $HOME/.cargo/env - rustup target add i686-unknown-freebsd - cargo build --all --all-targets --verbose --no-default-features --target i686-unknown-freebsd - From 94bd508d8e3b9786a136a328a7fe87c68f0e3d4a Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Mon, 7 Oct 2024 14:21:12 +0200 Subject: [PATCH 18/19] Split cargo fmt and clippy --- .github/workflows/ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee681cc8..3c78660c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,10 +68,11 @@ jobs: target key: ${{ runner.os }}-test-${{ steps.tc.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.toml') }} - - name: Format and clippy - run: | - cargo fmt --all -- --check - cargo clippy --all-targets --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version[0] }} + - name: Format + run: cargo fmt --all -- --check + + - name: Clippy + run: cargo clippy --all-targets --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version[0] }} - name: Build debug run: cargo build --no-default-features --features min-redis-compatibility-version-${{ matrix.redis-version[0] }} From e72149f36795912629b9fdcb94b57c2a37bfe73e Mon Sep 17 00:00:00 2001 From: Victor Polevoy Date: Mon, 7 Oct 2024 14:23:12 +0200 Subject: [PATCH 19/19] Delete unused files and directories --- Makefile | 101 -------------------------------------- deps/readies | 1 - sbin/setup | 24 --------- sbin/system-setup.py | 56 --------------------- unused/hello_no_macros.rs | 92 ---------------------------------- 5 files changed, 274 deletions(-) delete mode 100644 Makefile delete mode 160000 deps/readies delete mode 100755 sbin/setup delete mode 100755 sbin/system-setup.py delete mode 100644 unused/hello_no_macros.rs diff --git a/Makefile b/Makefile deleted file mode 100644 index 77ec83b3..00000000 --- a/Makefile +++ /dev/null @@ -1,101 +0,0 @@ -ROOT=. - -include $(ROOT)/deps/readies/mk/main - -#---------------------------------------------------------------------------------------------- - -define HELPTEXT -make build - DEBUG=1 # build debug variant -make clean # remove binary files - ALL=1 # remove binary directories - -make all # build all libraries and packages - -make test # run tests - -make docker # build for specific Linux distribution - OSNICK=nick # Linux distribution to build for - REDIS_VER=ver # use Redis version `ver` - TEST=1 # test aftar build - - -endef - -#---------------------------------------------------------------------------------------------- - -MK_CUSTOM_CLEAN=1 -BINDIR=$(BINROOT) - -include $(MK)/defs -include $(MK)/rules - -#---------------------------------------------------------------------------------------------- - -MODULE_NAME=redismodule-rs.so - -ifeq ($(DEBUG),1) -TARGET_DIR=target/debug -else -CARGO_FLAGS += --release -TARGET_DIR=target/release -endif - -TARGET=$(TARGET_DIR)/$(MODULE_NAME) - -#---------------------------------------------------------------------------------------------- - -lint: - cargo fmt -- --check - -.PHONY: lint - -#---------------------------------------------------------------------------------------------- - -RUST_SOEXT.linux=so -RUST_SOEXT.freebsd=so -RUST_SOEXT.macos=dylib - -build: - cargo build --all --all-targets --no-default-features $(CARGO_FLAGS) - # cp $(TARGET_DIR)/librejson.$(RUST_SOEXT.$(OS)) $(TARGET) - -clean: -ifneq ($(ALL),1) - cargo clean -else - rm -rf target -endif - -.PHONY: build clean - -#---------------------------------------------------------------------------------------------- - -test: cargo_test cargo_deny - -cargo_deny: - cargo install --locked cargo-deny - cargo deny check licenses - cargo deny check bans - -cargo_test: - cargo test --workspace --no-default-features $(CARGO_FLAGS) - cargo test --doc --workspace --no-default-features $(CARGO_FLAGS) - -.PHONY: test cargo_test cargo_deny - -#---------------------------------------------------------------------------------------------- - -docker: - @make -C build/docker build - -info: - gcc --version - cmake --version - clang --version - rustc --version - cargo --version - rustup --version - rustup show - -.PHONY: docker info diff --git a/deps/readies b/deps/readies deleted file mode 160000 index 876d0db6..00000000 --- a/deps/readies +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 876d0db6c40ed151e78136b09e2141d5bf9c2273 diff --git a/sbin/setup b/sbin/setup deleted file mode 100755 index 534648ce..00000000 --- a/sbin/setup +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -PROGNAME="${BASH_SOURCE[0]}" -HERE="$(cd "$(dirname "$PROGNAME")" &>/dev/null && pwd)" -ROOT=$(cd $HERE/.. && pwd) -READIES=$ROOT/deps/readies -. $READIES/shibumi/defs - -export HOMEBREW_NO_AUTO_UPDATE=1 - -$READIES/bin/getpy3 -pyenv="$(get_profile_d)/pyenv.sh" -if [[ -f $pyenv ]]; then - . $pyenv -fi -if [[ $VERBOSE == 1 ]]; then - python3 --version - python3 -m pip list -fi - -$ROOT/sbin/system-setup.py -if [[ $VERBOSE == 1 ]]; then - python3 -m pip list -fi diff --git a/sbin/system-setup.py b/sbin/system-setup.py deleted file mode 100755 index 4443f9c2..00000000 --- a/sbin/system-setup.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -import argparse - -HERE = os.path.abspath(os.path.dirname(__file__)) -ROOT = os.path.abspath(os.path.join(HERE, "..")) -READIES = os.path.join(ROOT, "deps/readies") -sys.path.insert(0, READIES) -import paella - -#---------------------------------------------------------------------------------------------- - -class RedisModuleRSSetup(paella.Setup): - def __init__(self, args): - paella.Setup.__init__(self, args.nop) - - def common_first(self): - self.install_downloaders() - self.run("%s/bin/enable-utf8" % READIES, sudo=self.os != 'macos') - self.install("git") - - self.run("%s/bin/getclang --modern" % READIES) - self.run("%s/bin/getrust" % READIES) - if self.osnick == 'ol8': - self.install('tar') - self.run("%s/bin/getcmake --usr" % READIES) - - def debian_compat(self): - self.run("%s/bin/getgcc" % READIES) - - def redhat_compat(self): - self.install("redhat-lsb-core") - self.run("%s/bin/getgcc --modern" % READIES) - - if not self.platform.is_arm(): - self.install_linux_gnu_tar() - - def fedora(self): - self.run("%s/bin/getgcc" % READIES) - - def macos(self): - self.install_gnu_utils() - self.run("%s/bin/getredis -v 6" % READIES) - - def common_last(self): - pass - -#---------------------------------------------------------------------------------------------- - -parser = argparse.ArgumentParser(description='Set up system for build.') -parser.add_argument('-n', '--nop', action="store_true", help='no operation') -args = parser.parse_args() - -RedisModuleRSSetup(args).setup() diff --git a/unused/hello_no_macros.rs b/unused/hello_no_macros.rs deleted file mode 100644 index 03bd1e2d..00000000 --- a/unused/hello_no_macros.rs +++ /dev/null @@ -1,92 +0,0 @@ -use std::ffi::CString; - -extern crate libc; - -use libc::c_int; - -extern crate redis_module; - -use redis_module::raw; -use redis_module::Context; -use redis_module::{Command, RedisResult, RedisValue, RedisError}; - -const MODULE_NAME: &str = "hello"; -const MODULE_VERSION: u32 = 1; - - -fn hello_mul(_: &Context, args: Vec) -> RedisResult { - if args.len() != 3 { - return Err(RedisError::WrongArity); - } - - // TODO: Write generic RedisValue::parse method - if let RedisValue::Integer(m1) = parse_integer(&args[1])? { - if let RedisValue::Integer(m2) = parse_integer(&args[2])? { - let result = m1 * m2; - - return Ok(RedisValue::Array( - vec![m1, m2, result] - .into_iter() - .map(|v| RedisValue::Integer(v)) - .collect())); - } - } - - Err(RedisError::String("Something went wrong")) -} - -////////////////////////////////////////////////////// - -#[no_mangle] -#[allow(non_snake_case)] -pub extern "C" fn RedisModule_OnLoad( - ctx: *mut raw::RedisModuleCtx, - _argv: *mut *mut raw::RedisModuleString, - _argc: c_int, -) -> c_int { - unsafe { - ////////////////// - - let module_name = MODULE_NAME; - let module_version = MODULE_VERSION; - - let commands = [ - Command::new("hello.mul", hello_mul, "write"), - ]; - - ////////////////// - - let module_name = CString::new(module_name).unwrap(); - let module_version = module_version as c_int; - - if raw::Export_RedisModule_Init( - ctx, - module_name.as_ptr(), - module_version, - raw::REDISMODULE_APIVER_1 as c_int, - ) == raw::Status::Err as _ { return raw::Status::Err as _; } - - for command in &commands { - let name = CString::new(command.name).unwrap(); - let flags = CString::new(command.flags).unwrap(); - let (firstkey, lastkey, keystep) = (1, 1, 1); - - if raw::RedisModule_CreateCommand.unwrap()( - ctx, - name.as_ptr(), - command.wrap_handler(), - flags.as_ptr(), - firstkey, lastkey, keystep, - ) == raw::Status::Err as _ { return raw::Status::Err as _; } - } - - raw::Status::Ok as _ - } -} - -fn parse_integer(arg: &str) -> RedisResult { - arg.parse::() - .map_err(|_| RedisError::String("Couldn't parse as integer")) - .map(|v| RedisValue::Integer(v)) - //Error::generic(format!("Couldn't parse as integer: {}", arg).as_str())) -}