diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..0c8427e --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,43 @@ +name: Redis CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + specs: + services: + redis: + image: redislabs/redismod + options: >- + --health-cmd "redis-cli ping" + --health-interval 5s + --health-timeout 3s + --health-retries 3 + ports: + - 6379:6379 + + strategy: + fail-fast: false + matrix: + crystal_version: + - 1.2.0 + - 1.3.0 + - 1.4.1 + - latest + experimental: + - false + + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.experimental }} + steps: + - uses: actions/checkout@v3 + - uses: crystal-lang/install-crystal@v1 + with: + crystal: ${{matrix.crystal_version}} + - name: Install dependencies + run: shards install + - name: Run tests + run: crystal spec 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