diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..28d7d4e --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,24 @@ +before_install: + - mkdir -p tmp/pids log + - script/noosfero-plugins disableall + - bundle check || bundle install +# database + - cp config/database.yml.gitlab-ci config/database.yml + - dropdb gitlab_ci_test + - createdb gitlab_ci_test + - bundle exec rake db:schema:load + - bundle exec rake db:migrate + +units: + script: 'bundle exec rake test:units' +functionals: + script: 'bundle exec rake test:functionals' +integration: + script: 'bundle exec rake test:integration' +cucumber: + script: 'bundle exec rake cucumber' +selenium: + script: 'bundle exec rake selenium' +plugins: + script: 'bundle exec rake test:noosfero_plugins' + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2bde06a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,35 @@ +language: ruby +rvm: +# for 2.2 support we need to upgrade the pg gem + - 2.1.6 + +before_install: +# dependencies + - sudo apt-get update + - sudo apt-get -y install po4a iso-codes tango-icon-theme pidgin-data openjdk-6-jre curl wget + - sudo apt-get -y install libmagickwand-dev libpq-dev libreadline-dev libsqlite3-dev libxslt1-dev +# selenium support + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start + +before_script: + - mkdir -p tmp/pids log + - script/noosfero-plugins disableall + - bundle check || bundle install +# database + - cp config/database.yml.travis config/database.yml + - psql -c 'create database myapp_test;' -U postgres + - bundle exec rake db:schema:load + - bundle exec rake db:migrate + +env: + - TASK=test:units + - TASK=test:functionals + - TASK=test:integration + - TASK=cucumber + - TASK=selenium + - TASK=test:noosfero_plugins + +script: + - bundle exec rake $TASK + diff --git a/Gemfile b/Gemfile index d210af4..ac78c37 100644 --- a/Gemfile +++ b/Gemfile @@ -32,6 +32,7 @@ group :test do gem 'rspec', '~> 2.14.0' gem 'rspec-rails', '~> 2.14.1' gem 'mocha', '~> 1.1.0', :require => false + gem 'test-unit' if RUBY_VERSION >= '2.2.0' end group :cucumber do diff --git a/config/database.yml.gitlab-ci b/config/database.yml.gitlab-ci new file mode 100644 index 0000000..585b2fb --- /dev/null +++ b/config/database.yml.gitlab-ci @@ -0,0 +1,5 @@ +# From http://about.travis-ci.org/docs/user/database-setup/ +test: + adapter: postgresql + database: gitlab_ci_test + username: postgres diff --git a/config/database.yml.travis b/config/database.yml.travis new file mode 100644 index 0000000..610cb00 --- /dev/null +++ b/config/database.yml.travis @@ -0,0 +1,5 @@ +# From http://about.travis-ci.org/docs/user/database-setup/ +test: + adapter: postgresql + database: myapp_test + username: postgres diff --git a/script/gitlab-ci b/script/gitlab-ci deleted file mode 100755 index 419e61f..0000000 --- a/script/gitlab-ci +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env ruby - -# These just forward the signals to the whole process group and -# then immediately exit. -pgid = Process.getpgid Process.pid -Signal.trap(:TERM) { Process.kill(:TERM, -pgid); exit } -Signal.trap(:INT) { Process.kill(:INT, -pgid); exit } - -def run command, options = {} - command = "#{command} 2>&1 > /dev/null" if options[:output] == false - #command = "time #{command}" unless options[:runtime] == false - puts "== #{command}" - system command -end - -@id = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join -@db = "gitlab-ci-#{@id}" - -def config - require 'yaml' - db_config = { - 'adapter' => 'postgresql', 'encoding' => 'unicode', - 'database' => @db, 'username' => ENV['USER'], - } - File.write 'config/database.yml', YAML.dump('test' => db_config, 'development' => db_config) -end - -def prepare - run("createdb #{@db}") and - run('mkdir -p tmp/pids log') and - run('bundle check || bundle install') and - run('rake db:schema:load', output: false) and - run('script/noosfero-plugins disableall') and - run('rake db:migrate') -end - -def test - %w[ - test:units - test:functionals - test:integration - cucumber - test:noosfero_plugins - ].each do |task| - run "rake #{task}" - end -end - -def cleanup - run "dropdb #{@db}" -end - -ret = config and prepare and test -cleanup - -exit (if ret == true then 0 else 1 end) -- libgit2 0.21.2