Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
Added support for building in GitLab CI
Browse files Browse the repository at this point in the history
  • Loading branch information
brodock committed Jul 22, 2016
1 parent 4cacaf3 commit e124f2e
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 3 deletions.
60 changes: 60 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 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"
<<: *test-common
script:
- bundle exec rake
allow_failure: true
6 changes: 5 additions & 1 deletion lib/lita/default_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 21 additions & 2 deletions spec/lita/default_configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e124f2e

Please sign in to comment.