From 45b8c157f7f02ce21708d49e9259b0d3f6a71ba3 Mon Sep 17 00:00:00 2001 From: Evgenii Date: Wed, 26 Jan 2022 00:11:44 +0500 Subject: [PATCH 1/8] github CI --- .github/workflows/CI.yml | 41 ++++++++++++++++++++++++++++++++++++++++ spec/graph_spec.cr | 2 +- spec/json_spec.cr | 2 +- spec/redis_spec.cr | 9 +++------ spec/search_spec.cr | 2 +- spec/spec_helper.cr | 5 +++++ spec/time_series_spec.cr | 2 +- 7 files changed, 53 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/CI.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..b3d18ea --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,41 @@ +name: Redis CI + +on: + push: + branches: [master] + pull_request: + branches: "*" + +jobs: + specs: + services: + redis: + image: redislabs/redismod + options: >- + --health-cmd "redis-cli ping" + --health-interval 5s + --health-timeout 3s + --health-retries 3 + + strategy: + fail-fast: false + matrix: + crystal_version: + - 1.2.0 + - 1.3.0 + - latest + experimental: + - false + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.experimental }} + steps: + - uses: actions/checkout@v2 + - uses: crystal-lang/install-crystal@v1 + with: + crystal: ${{matrix.crystal_version}} + - name: Install dependencies + run: shards install + - name: Run tests + run: crystal spec + env: + REDIS_URL: redis://redis:6379 diff --git a/spec/graph_spec.cr b/spec/graph_spec.cr index 6fd1468..2bbb72e 100644 --- a/spec/graph_spec.cr +++ b/spec/graph_spec.cr @@ -17,7 +17,7 @@ private macro test(name, &block) end describe Redis::Graph do - redis = Redis::Client.new + redis = Redis::Client.new(uri: redis_uri()) test "creates and retrieves nodes" do 2.times do diff --git a/spec/json_spec.cr b/spec/json_spec.cr index 13feb0f..6b18f3c 100644 --- a/spec/json_spec.cr +++ b/spec/json_spec.cr @@ -49,7 +49,7 @@ private macro test(name) end # redis = Redis::Cluster.new -redis = Redis::Client.new +redis = Redis::Client.new(uri: redis_uri()) describe Redis::JSON do test "sets and gets JSON objects" do diff --git a/spec/redis_spec.cr b/spec/redis_spec.cr index 435deb3..5117536 100644 --- a/spec/redis_spec.cr +++ b/spec/redis_spec.cr @@ -5,8 +5,7 @@ require "../src/redis" # Do not use DB slot 15. That's used as the secondary DB for testing the ability # to use DBs other than 0. -redis_uri = URI.parse("redis:///") -redis = Redis::Client.new(uri: redis_uri) +redis = Redis::Client.new(uri: redis_uri()) private def random_key UUID.random.to_s @@ -84,7 +83,6 @@ describe Redis::Client do redis.incrby(key, 3).should eq 5 redis.decrby(key, 2).should eq 3 redis.incrby(key, 1234567812345678).should eq 1234567812345678 + 3 - ensure redis.del key end @@ -156,9 +154,9 @@ describe Redis::Client do key = random_key begin - first_incr = Redis::Future.new + first_incr = Redis::Future.new second_incr = Redis::Future.new - first_decr = Redis::Future.new + first_decr = Redis::Future.new second_decr = Redis::Future.new redis.pipeline do |redis| @@ -266,7 +264,6 @@ describe Redis::Client do consumer_id = UUID.random.to_s result = redis.xreadgroup group, consumer_id, count: "10", streams: {"my-stream": ">"} - rescue ex pp ex raise ex diff --git a/spec/search_spec.cr b/spec/search_spec.cr index 13ec739..169e8e7 100644 --- a/spec/search_spec.cr +++ b/spec/search_spec.cr @@ -4,7 +4,7 @@ require "uuid" require "../src/redis" require "../src/search" -redis = Redis::Client.new +redis = Redis::Client.new(uri: redis_uri()) module Redis describe FullText do diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr index e2f4f80..67e51c2 100644 --- a/spec/spec_helper.cr +++ b/spec/spec_helper.cr @@ -1 +1,6 @@ require "spec" + +# REDIS_URL for CI, redis:/// to run spec test locally +def redis_uri + URI.parse(ENV["REDIS_URL"]? || "redis:///") +end diff --git a/spec/time_series_spec.cr b/spec/time_series_spec.cr index 3d9590d..25e81d6 100644 --- a/spec/time_series_spec.cr +++ b/spec/time_series_spec.cr @@ -15,7 +15,7 @@ private macro test(name) end end -redis = Redis::Client.new +redis = Redis::Client.new(uri: redis_uri()) module Redis describe TimeSeries do From 6f9f3ead192ae96ef77cd0c202a8f2877ca921a3 Mon Sep 17 00:00:00 2001 From: Evgenii Date: Wed, 26 Jan 2022 00:29:19 +0500 Subject: [PATCH 2/8] redis uri fix --- .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 b3d18ea..a974403 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -38,4 +38,4 @@ jobs: - name: Run tests run: crystal spec env: - REDIS_URL: redis://redis:6379 + REDIS_URL: redis://redis/ From 31c2442a17bd2c5e6129df444c67097504632005 Mon Sep 17 00:00:00 2001 From: Evgenii Date: Wed, 26 Jan 2022 00:49:49 +0500 Subject: [PATCH 3/8] redis port mapping --- .github/workflows/CI.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a974403..5331413 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -16,6 +16,8 @@ jobs: --health-interval 5s --health-timeout 3s --health-retries 3 + ports: + - 6379:6379 strategy: fail-fast: false @@ -26,6 +28,7 @@ jobs: - latest experimental: - false + runs-on: ubuntu-latest continue-on-error: ${{ matrix.experimental }} steps: From ab8a721e5ad3e8d0c768339b033a8cbf9d0dcb5d Mon Sep 17 00:00:00 2001 From: Evgenii Date: Wed, 26 Jan 2022 00:49:59 +0500 Subject: [PATCH 4/8] redis port mapping --- .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 5331413..fb209ba 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -41,4 +41,4 @@ jobs: - name: Run tests run: crystal spec env: - REDIS_URL: redis://redis/ + # REDIS_URL: redis://redis/ From af0ad1ba664e44ec126e674fac816996c76b45f7 Mon Sep 17 00:00:00 2001 From: Evgenii Date: Wed, 26 Jan 2022 00:50:58 +0500 Subject: [PATCH 5/8] env fix --- .github/workflows/CI.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index fb209ba..d081eb1 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -40,5 +40,3 @@ jobs: run: shards install - name: Run tests run: crystal spec - env: - # REDIS_URL: redis://redis/ From c0732a0b1a4c74a76f8a02f3afe086fa78dd666c Mon Sep 17 00:00:00 2001 From: Evgenii Date: Mon, 22 Aug 2022 22:10:37 +0300 Subject: [PATCH 6/8] crystal_version 1.4.1 --- .github/workflows/CI.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d081eb1..f0e43ec 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -25,6 +25,7 @@ jobs: crystal_version: - 1.2.0 - 1.3.0 + - 1.4.1 - latest experimental: - false From 5ed2c22d50b7fb83abd43ad98547314be3b3361e Mon Sep 17 00:00:00 2001 From: Evgenii Date: Mon, 22 Aug 2022 22:24:15 +0300 Subject: [PATCH 7/8] actions/checkout@v3 --- .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 f0e43ec..d9e7cb3 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -33,7 +33,7 @@ jobs: runs-on: ubuntu-latest continue-on-error: ${{ matrix.experimental }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: crystal-lang/install-crystal@v1 with: crystal: ${{matrix.crystal_version}} From 5d5cfa48e6b7bba245b1dd27676e4763091f8d82 Mon Sep 17 00:00:00 2001 From: Evgenii Date: Mon, 22 Aug 2022 22:33:23 +0300 Subject: [PATCH 8/8] pull requests for master branche --- .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 d9e7cb3..0c8427e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -4,7 +4,7 @@ on: push: branches: [master] pull_request: - branches: "*" + branches: [master] jobs: specs: