Skip to content

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 eba3886
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 3 deletions.
59 changes: 59 additions & 0 deletions .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
6 changes: 5 additions & 1 deletion lib/lita/default_configuration.rb
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
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 eba3886

Please sign in to comment.