Skip to content

Commit

Permalink
Add support for cider-ci v2
Browse files Browse the repository at this point in the history
  • Loading branch information
DrTom committed Oct 29, 2014
1 parent ab23ec7 commit 4611865
Show file tree
Hide file tree
Showing 16 changed files with 1,188 additions and 80 deletions.
24 changes: 24 additions & 0 deletions cider-ci_v2/bin/check_cucumber-features_tested.rb
@@ -0,0 +1,24 @@
#!/usr/bin/env ruby
require 'yaml'
require 'set'
#require 'pry'

feature_tasks = YAML.load_file("cider-ci_v2/tasks/cucumber-features.yml")["tasks"]

matcher= /.*cucumber.*\"(.*)\".*$/

tested_files = Set.new feature_tasks.map{|t| t['scripts']} \
.map{|s| s['cucumber']}.map{|s| s['body']} \
.map{|s| matcher.match(s)[1]}

existing_files = Set.new Dir.glob("features/**/*.feature")

if existing_files == tested_files
puts "existing_files and the tested_files are equivalent"
exit 0
else
warn "existing_files and the tested_files are not equivalent: "
warn "exiting but not tested: #{(existing_files - tested_files).map(&:to_s)}"
warn "tested but not existing: #{(tested_files - existing_files).map(&:to_s)}"
exit -1
end
24 changes: 24 additions & 0 deletions cider-ci_v2/bin/check_rspec-features_tested.rb
@@ -0,0 +1,24 @@
#!/usr/bin/env ruby
require 'yaml'
require 'set'

rspec_tasks = YAML.load_file("cider-ci_v2/tasks/rspec-features.yml")["tasks"]

matcher= /.*rspec\s+\"(.*)\".*$/

tested_spec_files = Set.new rspec_tasks.map{|t| t['scripts']} \
.map{|s| s['rspec']}.map{|s| s['body']}.map{|s|matcher.match(s)[1]}

existing_spec_files = Set.new(
Dir.glob("spec/**/*_spec.rb").select{|name| name =~ /spec\/feature/})


if existing_spec_files == tested_spec_files
puts "existing_spec_files and the tested_spec_files are equivalent"
exit 0
else
warn "existing_spec_files and the tested_spec_files are not equivalent: "
warn "exiting but not tested: #{(existing_spec_files - tested_spec_files).map(&:to_s)}"
warn "tested but not existing: #{(tested_spec_files - existing_spec_files).map(&:to_s)}"
exit -1
end
24 changes: 24 additions & 0 deletions cider-ci_v2/bin/check_rspec-plain_tested.rb
@@ -0,0 +1,24 @@
#!/usr/bin/env ruby
require 'yaml'
require 'set'

rspec_tasks = YAML.load_file("cider-ci_v2/tasks/rspec-plain.yml")["tasks"]

matcher= /.*rspec\s+\"(.*)\".*$/

tested_spec_files = Set.new rspec_tasks.map{|t| t['scripts']} \
.map{|s| s['rspec']}.map{|s| s['body']}.map{|s|matcher.match(s)[1]}

existing_spec_files = Set.new(
Dir.glob("spec/**/*_spec.rb").reject{|name| name =~ /spec\/feature/})


if existing_spec_files == tested_spec_files
puts "existing_spec_files and the tested_spec_files are equivalent"
exit 0
else
warn "existing_spec_files and the tested_spec_files are not equivalent: "
warn "exiting but not tested: #{(existing_spec_files - tested_spec_files).map(&:to_s)}"
warn "tested but not existing: #{(tested_spec_files - existing_spec_files).map(&:to_s)}"
exit -1
end
19 changes: 19 additions & 0 deletions cider-ci_v2/bin/create_db_config_file.rb
@@ -0,0 +1,19 @@
#!/usr/bin/env ruby
require 'yaml'

raise "env CIDER_CI_TRIAL_ID must be set" unless ENV['CIDER_CI_TRIAL_ID']
raise "env CIDER_CI_EXECUTION_ID ust be set" unless ENV['CIDER_CI_EXECUTION_ID']

def trial_id
@_trial_id ||= (ENV['CIDER_CI_TRIAL_ID'][0..7])
end

config = YAML.load_file("config/database_cider-ci_template.yml")
config["test"]["database"] = %Q[#{config["test"]["database"]}_#{trial_id}]
config["test"]["username"] = ENV['PG93_USER']
config["test"]["password"] = ENV['PG93_PASSWORD']
config["test"]["port"] = ENV['PG93_PORT']


File.delete "config/database.yml" rescue nil
File.open("config/database.yml",'w'){|f| f.write(config.to_yaml)}
17 changes: 17 additions & 0 deletions cider-ci_v2/bin/list_cucumber-feature_tasks.rb
@@ -0,0 +1,17 @@
#!/usr/bin/env ruby
require 'yaml'
require 'pry'

def task_for_feature_file file_path
name= file_path.match(/features\/(.*)\.feature/).captures.first
exec = %{DISPLAY=":$XVNC_PORT" bundle exec cucumber --strict "#{file_path}"}
{"name" => name,
"scripts" => {
"cucumber" => {
"body" => exec } } }
end

STDOUT.write(
{"tasks" =>
Dir.glob("features/**/*.feature") \
.map{|f| task_for_feature_file(f)}}.to_yaml)
17 changes: 17 additions & 0 deletions cider-ci_v2/bin/list_rspec-feature_tasks.rb
@@ -0,0 +1,17 @@
#!/usr/bin/env ruby
require 'yaml'
require 'pry'

def task_for_rspec_file file_path
name= file_path.match(/spec\/(.*)_spec\.rb/).captures.first.gsub(/\//,' ')
exec = %{DISPLAY=":$XVNC_PORT" bundle exec rspec "#{file_path}"}
{"name" => name,
"scripts" => {
"rspec" => {
"body" => exec } } }
end

STDOUT.write(
{"tasks" =>
Dir.glob("spec/**/*_spec.rb").select{|name| name =~ /spec\/feature/ } \
.map{|f| task_for_rspec_file(f)}}.to_yaml)
17 changes: 17 additions & 0 deletions cider-ci_v2/bin/list_rspec-plain_tasks.rb
@@ -0,0 +1,17 @@
#!/usr/bin/env ruby
require 'yaml'
require 'pry'

def task_for_rspec_file file_path
name= file_path.match(/spec\/(.*)_spec\.rb/).captures.first.gsub(/\//,' ')
exec = %{bundle exec rspec "#{file_path}"}
{"name" => name,
"scripts" => {
"rspec" => {
"body" => exec } } }
end

STDOUT.write(
{"tasks" =>
Dir.glob("spec/**/*_spec.rb").reject{|name| name =~ /spec\/feature/ } \
.map{|f| task_for_rspec_file(f)}}.to_yaml)
27 changes: 27 additions & 0 deletions cider-ci_v2/partials/rails_integration_task_defaults.yml
@@ -0,0 +1,27 @@
task_defaults:

traits:
firefox: true
phantomjs: true
tightvnc: true

trial_attachments:
screenshots:
glob: 'tmp/capybara/*.png'
content-type: image/png

ports:
xvnc_port:
inet_address: "localhost"
min: 5900
max: 5999

scripts:
startx:
order: 5
body: tightvncserver ":$XVNC_PORT" -geometry 1024x768 -rfbport "$XVNC_PORT" -interface '127.0.0.1'
stopx:
order: 9
type: post_process
body: tightvncserver -kill ":$XVNC_PORT" -clean

43 changes: 43 additions & 0 deletions cider-ci_v2/partials/rails_task_defaults.yml
@@ -0,0 +1,43 @@
task_defaults:

traits:
imagemagick: true
libimage-exiftool-perl: true
rbenv: true
ruby: true
nodejs: true
pg93: true

environment_variables:
RAILS_ENV: test

trial_attachments:
logs:
glob: 'log/*.log'
content-type: text/plain
coverage_resultset:
glob: 'coverage/.resultset.json'
content-type: application/json
coverage_last_run:
glob: 'coverage/.last_run.json'
content-type: application/json


scripts:
bundle:
timeout: 500
order: 1
body: bundle
configer_db:
order: 2
body: cider-ci_v2/bin/create_db_config_file.rb
setup_database:
order: 3
body: bundle exec rake db:reset
setup_madek:
order: 4
body: bundle exec rake madek:setup:dirs
drop_test_db:
order: 8
type: post_process
body: bundle exec rake db:drop
20 changes: 20 additions & 0 deletions cider-ci_v2/tasks/completeness.yml
@@ -0,0 +1,20 @@
tasks:

- name: Check all cucumber-features are tested
scripts:
main:
body: cider-ci_v2/bin/check_cucumber-features_tested.rb

- name: Check all respec-features are tested
scripts:
main:
body: cider-ci_v2/bin/check_rspec-features_tested.rb

- name: Check all remaining rspec specs are tested
scripts:
main:
body: cider-ci_v2/bin/check_rspec-plain_tested.rb




0 comments on commit 4611865

Please sign in to comment.