Permalink
Browse files

Setup rake and travis

  • Loading branch information...
1 parent 3644f27 commit 39d924149d11079c44acead7d5f1d11c9a57f4d4 @mirisuzanne mirisuzanne committed Nov 6, 2013
Showing with 75 additions and 0 deletions.
  1. +4 −0 .travis.yml
  2. +70 −0 Rakefile
  3. +1 −0 VERSION
View
@@ -0,0 +1,4 @@
+language: ruby
+script: "rake"
+rvm:
+ - 2.0.0
View
@@ -0,0 +1,70 @@
+require 'rubygems/package_task'
+
+task :default => :test
+
+spec = eval(File.read("susy.gemspec"), binding, "susy.gemspec")
+
+def spec.bump!
+ segments = version.to_s.split(".")
+ segments[-1] = segments.last.succ
+ self.version = Gem::Version.new(segments.join("."))
+end
+
+# Set SAME_VERSION when moving to a new major version and you want to specify the new version
+# explicitly instead of bumping the current version.
+# E.g. rake build SAME_VERSION=susy
+spec.bump! unless ENV["SAME_VERSION"]
+
+desc "Run tests and build susy-#{spec.version}.gem"
+task :build => [:test, :gem]
+
+desc "Make make the prebuilt gem susy-#{spec.version}.gem public."
+task :publish => [:record_version, :push_gem, :tag]
+
+desc "Build & Publish version #{spec.version}"
+task :release => [:build, :publish]
+
+Gem::PackageTask.new(spec) do |pkg|
+ pkg.need_zip = true
+ pkg.need_tar = true
+end
+
+desc "run the tests"
+task :test do
+ sh "cd test && bundle install --quiet && bundle exec compass compile 2> error.output > /dev/null --force && cd - > /dev/null", :verbose => false
+ open("test/error.output") do |f|
+ if f.read =~ /(.*):\d+.*(\d+) Passed.*(\d+) Failed/
+ unless $3 == "0"
+ puts File.read("test/css/test.css")
+ fail "#{$3} Tests Failed"
+ else
+ puts "#{$2} Tests Passed"
+ end
+ else
+ raise "unexpected output"
+ end
+ end
+ sh "rm test/error.output", :verbose => false
+end
+
+desc "Record the new version in version control for posterity"
+task :record_version do
+ unless ENV["SAME_VERSION"]
+ open(FileList["VERSION"].first, "w") do |f|
+ f.write(spec.version.to_s)
+ end
+ sh "git add VERSION test/Gemfile.lock"
+ sh %Q{git commit -m "Bump version to #{spec.version}."}
+ end
+end
+
+desc "Tag the repo as #{spec.version} and push the code and tag."
+task :tag do
+ sh "git tag -a -m 'Version #{spec.version}' #{spec.version}"
+ sh "git push --tags origin #{`git rev-parse --abbrev-ref HEAD`}"
+end
+
+desc "Push susy-#{spec.version}.gem to the rubygems server"
+task :push_gem do
+ sh "gem push pkg/susy-#{spec.version}.gem"
+end
View
@@ -0,0 +1 @@
+2.0.0.alpha.4

0 comments on commit 39d9241

Please sign in to comment.