From 5d99e1db67b6dd1583ec9a9cdd83e1965f1ede2b Mon Sep 17 00:00:00 2001 From: Maxim Tretyakov Date: Thu, 28 Apr 2022 10:23:40 +0500 Subject: [PATCH] Fix lua code for redis >= 6.2.7 --- .github/workflows/ruby.yml | 4 ++-- dip.yml | 12 +++++++++--- docker/Dockerfile | 6 ++++++ docker-compose.yml => docker/docker-compose.yml | 14 ++++++++------ lib/qless/lua/qless-lib.lua | 6 +++--- lib/qless/lua/qless.lua | 6 +++--- 6 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 docker/Dockerfile rename docker-compose.yml => docker/docker-compose.yml (61%) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 128cae31..b78f7442 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -18,8 +18,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: ["2.7", "3", "3.1"] - redis-version: ["5", "6"] + ruby-version: ["2.7", "3.0", "3.1"] + redis-version: ["5", "6", "7"] services: redis: diff --git a/dip.yml b/dip.yml index 827ac59d..08525a0b 100644 --- a/dip.yml +++ b/dip.yml @@ -2,25 +2,31 @@ version: "5.0" compose: files: - - ./docker-compose.yml + - docker/docker-compose.yml + project_name: qless interaction: ruby: service: ruby - command: /bin/bash + command: sh sh: service: ruby - command: /bin/bash + command: sh bundle: service: ruby command: bundle + clean: + service: ruby + command: rm -f Gemfile.lock + rspec: service: ruby command: bundle exec rspec provision: - docker volume create --name bundler_data + - dip clean - dip bundle install diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..fc2894a1 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,6 @@ +FROM ruby:3.1-alpine + +RUN gem update --system && \ + apk add --update --no-cache less git build-base curl jq mc + +WORKDIR /app diff --git a/docker-compose.yml b/docker/docker-compose.yml similarity index 61% rename from docker-compose.yml rename to docker/docker-compose.yml index a3b80a7b..18d434e4 100644 --- a/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,20 +1,22 @@ -version: "2.1" +version: "3.7" services: ruby: - image: ruby:2.7 + build: + context: ../ + dockerfile: ./docker/Dockerfile depends_on: - redis environment: - - BUNDLE_PATH=/bundle/2.7 + - BUNDLE_PATH=/bundle/3.1 - RACK_ENV=test - REDIS_HOST=redis - SKIP_JS_SPEC=true volumes: - - .:/usr/src/qless + - ..:/app - bundler-data:/bundle - working_dir: /usr/src/qless + redis: - image: redis:6 + image: redis:7-alpine volumes: bundler-data: diff --git a/lib/qless/lua/qless-lib.lua b/lib/qless/lua/qless-lib.lua index 7efd1f76..26bbf7d2 100644 --- a/lib/qless/lua/qless-lib.lua +++ b/lib/qless/lua/qless-lib.lua @@ -33,7 +33,7 @@ QlessRecurringJob.__index = QlessRecurringJob Qless.config = {} -- Extend a table. This comes up quite frequently -function table.extend(self, other) +local function table_extend(self, other) for i, v in ipairs(other) do table.insert(self, v) end @@ -1525,7 +1525,7 @@ function QlessQueue:peek(now, count) -- With these in place, we can expand this list of jids based on the work -- queue itself and the priorities therein - table.extend(jids, self.work.peek(count - #jids)) + table_extend(jids, self.work.peek(count - #jids)) return jids end @@ -1600,7 +1600,7 @@ function QlessQueue:pop(now, worker, count) -- With these in place, we can expand this list of jids based on the work -- queue itself and the priorities therein - table.extend(jids, self.work.peek(count - #jids)) + table_extend(jids, self.work.peek(count - #jids)) local state for index, jid in ipairs(jids) do diff --git a/lib/qless/lua/qless.lua b/lib/qless/lua/qless.lua index 9f566e08..7ae3aa11 100644 --- a/lib/qless/lua/qless.lua +++ b/lib/qless/lua/qless.lua @@ -24,7 +24,7 @@ QlessRecurringJob.__index = QlessRecurringJob Qless.config = {} -function table.extend(self, other) +local function table_extend(self, other) for i, v in ipairs(other) do table.insert(self, v) end @@ -1121,7 +1121,7 @@ function QlessQueue:peek(now, count) self:check_scheduled(now, count - #jids) - table.extend(jids, self.work.peek(count - #jids)) + table_extend(jids, self.work.peek(count - #jids)) return jids end @@ -1170,7 +1170,7 @@ function QlessQueue:pop(now, worker, count) self:check_scheduled(now, count - #jids) - table.extend(jids, self.work.peek(count - #jids)) + table_extend(jids, self.work.peek(count - #jids)) local state for index, jid in ipairs(jids) do