diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..6cac4375 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,59 @@ +# Cache gems in between builds +cache: + paths: + - vendor + +variables: + LANG: "C.UTF-8" + REDIS_HOST: "redis" + REDIS_PORT: "6379" + +.test-template: &test-common + services: + - redis:latest + before_script: + - gem update --system --no-document + - gem install bundler --no-ri --no-rdoc + - bundle install -j $(nproc) --path vendor --retry 3 + +test:2.0: + image: "ruby:2.0" + <<: *test-common + script: + - bundle exec rake + +test:2.1: + image: "ruby:2.1" + <<: *test-common + script: + - bundle exec rake + +test:2.2: + image: "ruby:2.2" + <<: *test-common + script: + - bundle exec rake + +test:2.3: + image: "ruby:2.3" + <<: *test-common + script: + - bundle exec rake + +test:jruby-9.1: + image: "jruby:9.1" + services: + - redis:latest + before_script: + - jgem update --system --no-document + - jgem install bundler --no-ri --no-rdoc + - bundle install -j $(nproc) --path vendor --retry 3 + script: + - bundle exec rake + allow_failure: true + +test:rubinius-latest: + image: "rubinius/docker:latest" + script: + - bundle exec rake + allow_failure: true diff --git a/lib/lita/default_configuration.rb b/lib/lita/default_configuration.rb index 59be5fcc..1c3d2744 100644 --- a/lib/lita/default_configuration.rb +++ b/lib/lita/default_configuration.rb @@ -75,7 +75,11 @@ def http_config # Builds config.redis def redis_config - root.config :redis, type: Hash, default: {} + # Overrides Redis host/port defined by ENVIRONMENT variables + default = {} + default[:host] = ENV["REDIS_HOST"] if ENV["REDIS_HOST"] + default[:port] = ENV["REDIS_PORT"] if ENV["REDIS_PORT"] + root.config :redis, type: Hash, default: default end # Builds config.robot diff --git a/spec/lita/default_configuration_spec.rb b/spec/lita/default_configuration_spec.rb index 792c8ff1..ef815774 100644 --- a/spec/lita/default_configuration_spec.rb +++ b/spec/lita/default_configuration_spec.rb @@ -117,8 +117,27 @@ end describe "redis config" do - it "has empty default options" do - expect(config.redis).to eq({}) + before do + allow(ENV).to receive(:[]).with("REDIS_HOST") { nil } + allow(ENV).to receive(:[]).with("REDIS_PORT") { nil } + end + + context "with no specific environmental variables" do + it "has empty default options" do + expect(config.redis).to eq({}) + end + end + + context "with specific environmental variables" do + it "defines a default redis host based on REDIS_HOST env variable" do + allow(ENV).to receive(:[]).with("REDIS_HOST") { "myredis" } + expect(config.redis).to eq(host: "myredis") + end + + it "defines a default redis port based on REDIS_PORT env variable" do + allow(ENV).to receive(:[]).with("REDIS_PORT") { "6380" } + expect(config.redis).to eq(port: "6380") + end end it "can set options" do