From de45ad50feb51d4b2f0abd230ee96bc2a8a04b89 Mon Sep 17 00:00:00 2001 From: Mateusz Drewniak Date: Fri, 15 Nov 2024 19:35:16 +0100 Subject: [PATCH] Add redis service to github actions --- .github/workflows/ci.yml | 15 +++++++++++++++ test/simple_feature_flags/redis_storage_test.rb | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c77a1b..87ce32b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,8 +9,23 @@ on: jobs: test: runs-on: ubuntu-latest + services: + # Label used to access the service container + redis: + # Docker Hub image + image: redis + # Set health checks to wait until redis has started + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 env: CI: true + # The hostname used to communicate with the Redis service container + REDIS_HOST: redis + # The default Redis port + REDIS_PORT: 6379 strategy: matrix: ruby-version: ['3.1', '3.2', '3.3'] diff --git a/test/simple_feature_flags/redis_storage_test.rb b/test/simple_feature_flags/redis_storage_test.rb index 52d6d10..085a747 100644 --- a/test/simple_feature_flags/redis_storage_test.rb +++ b/test/simple_feature_flags/redis_storage_test.rb @@ -30,7 +30,9 @@ def setup file = Tempfile.new("feature_flags_#{Time.now.to_i}") File.write(T.must(file.path), T.unsafe(flags).to_yaml) - redis = Redis.new(db: 14) + host = ENV['REDIS_HOST'] || 'localhost' + port = ENV['REDIS_PORT'] || '6379' + redis = Redis.new(host: host, port: port, db: 14) redis_namespaced = Redis::Namespace.new(:feature_flags, redis: redis) # clean redis before each test