Skip to content

Commit

Permalink
adding new repos to hatchet tests
Browse files Browse the repository at this point in the history
added a hatchet task to run the hatchet suite

setup the travis matrix

added heroku api key to travis

added a build props file

tweaked thing to get travis passing

moved jruby dep into plugins

cleaned up the jruby config

shorted a dir reference
  • Loading branch information
jkutner committed Aug 25, 2014
1 parent 96a19c2 commit f822291
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 3 deletions.
15 changes: 15 additions & 0 deletions .gitignore
@@ -1 +1,16 @@
spec/fixtures/repos/*
logs
project/project
project/target
target
tmp
.history
dist
/.idea
/*.iml
/out
/.idea_modules
/.classpath
/.project
/RUNNING_PID
/.settings
27 changes: 24 additions & 3 deletions .travis.yml
@@ -1,8 +1,29 @@
env:
- SHUNIT_HOME="/tmp/shunit2-2.1.6"
language: scala

branches:
only:
- master

before_install:
- curl --silent https://shunit2.googlecode.com/files/shunit2-2.1.6.tgz | tar xz -C /tmp/
- git clone https://github.com/ryanbrainard/heroku-buildpack-testrunner.git /tmp/testrunner
- ./etc/hatchet_travis_setup.sh

install: true

script: /tmp/testrunner/bin/run -c .
script: $TEST_CMD

after_script: heroku keys:remove ~/.ssh/id_rsa

env:
global:
- IS_RUNNING_ON_TRAVIS=true
- HATCHET_RETRIES=3
- HATCHET_DEPLOY_STRATEGY=git
- HATCHET_BUILDPACK_BASE="https://github.com/heroku/heroku-buildpack-scala.git"
- SHUNIT_HOME="/tmp/shunit2-2.1.6"
# HEROKU_API_KEY
- secure: gR5b3OjggCuZ5E/UuxZHgz5WU7LRkyFwGLB5osPOcbuyxSGxl9gRd18TyTNkwEIDX0z+kcYjnbZVXF+Z8YpTGpkR9FieWY7sWUlb7VqHV6Bc1ZRMekinOR9L9N8Al6fLvXqHRQUrstG6/V4Zx2ylgQUqQOqUhvOexcF5Hh3s964=
matrix:
- TEST_CMD="sbt hatchet"
- TEST_CMD="/tmp/testrunner/bin/run -c ."
42 changes: 42 additions & 0 deletions build.sbt
@@ -0,0 +1,42 @@
name := "heroku-buildpack-scala"

resolvers +=
"rubygems-release" at "http://rubygems-proxy.torquebox.org/releases"

libraryDependencies ++= Seq(
"rubygems" % "thor" % "0.15.4",
"rubygems" % "rspec-retry" % "0.3.0",
"rubygems" % "heroku_hatchet" % "1.3.4" excludeAll(ExclusionRule("rubygems", "thor")),
"rubygems" % "rspec" % "3.0.0"
)

val hatchet = taskKey[Unit]("Run the suite of Hatchet specs")

val Hatchet = config("hatchet")

def jruby(rubyGemsHome: File): org.jruby.Main = {
val ruby = new org.jruby.RubyInstanceConfig()
val env = ruby.getEnvironment.asInstanceOf[java.util.Map[String,String]]
val newEnv = new java.util.HashMap[String, String]
newEnv.putAll(env)
newEnv.put("GEM_HOME", rubyGemsHome.getAbsolutePath)
newEnv.put("GEM_PATH", rubyGemsHome.getAbsolutePath)
ruby.setEnvironment(newEnv)
new org.jruby.Main(ruby)
}

hatchet := {
val rubyGemsHome = target.value / "rubygems"
IO.createDirectory(rubyGemsHome)
val oldContextClassLoader = Thread.currentThread.getContextClassLoader
Thread.currentThread.setContextClassLoader(this.getClass.getClassLoader)
(update in Hatchet).value.allFiles.foreach { f =>
if (f.getName.endsWith(".gem")) {
jruby(rubyGemsHome).run(List("-S", "gem", "install", f.getAbsolutePath, "-f", "-l", "-i", rubyGemsHome.getAbsolutePath).toArray[String])
}
}
val rubyGemsBin = rubyGemsHome / "bin"
jruby(rubyGemsHome).run(List("-S", rubyGemsBin.getAbsolutePath + "/hatchet", "install").toArray[String])
jruby(rubyGemsHome).run(List("-S", rubyGemsBin.getAbsolutePath + "/rspec").toArray[String])
Thread.currentThread.setContextClassLoader(oldContextClassLoader)
}
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions etc/hatchet_travis_setup.sh
@@ -0,0 +1,21 @@
if [ "$TEST_CMD" == "sbt hatchet" ]; then
if [ -n "`git config --get user.email`" ]; then
echo 'already set'; else `git config --global user.email 'buildpack@example.com'`
fi
if [ -n "`git config --get user.name`" ]; then
echo 'already set'; else `git config --global user.name 'BuildpackTester'`
fi

cat <<EOF > ~/.ssh/config
Host heroku.com
StrictHostKeyChecking no
CheckHostIP no
UserKnownHostsFile=/dev/null
Host github.com
StrictHostKeyChecking no
EOF

curl --fail --retry 3 --retry-delay 1 --connect-timeout 3 --max-time 30 https://toolbelt.heroku.com/install-ubuntu.sh | sh

yes | heroku keys:add
fi
File renamed without changes.
3 changes: 3 additions & 0 deletions hatchet.json
Expand Up @@ -15,5 +15,8 @@
"sbt": [
"kissaten/sbt-minimal-scala-sample",
"kissaten/sbt-start-script-sample"
],
"lift": [
"kissaten/lift-2.5-sample"
]
}
1 change: 1 addition & 0 deletions project/build.properties
@@ -0,0 +1 @@
sbt.version=0.13.5
1 change: 1 addition & 0 deletions project/plugins.sbt
@@ -0,0 +1 @@
libraryDependencies += "org.jruby" % "jruby-complete" % "1.7.12"
15 changes: 15 additions & 0 deletions spec/lift_spec.rb
@@ -0,0 +1,15 @@
require_relative 'spec_helper'

describe "Lift" do
it "should not download pre-cached dependencies" do
Hatchet::Runner.new("lift-2.5-sample").deploy do |app|
# expect(app.output).to match("Running: sbt update")
expect(app.output).to match("Running: sbt compile stage")
expect(app.output).not_to match(/Priming Ivy cache/)

expect(app.output).to match("downloading http://repo1.maven.org/maven2/com/github/jsimone/webapp-runner")

expect(successful_body(app)).to match("Welcome, you now have a working Lift installation")
end
end
end
1 change: 1 addition & 0 deletions spec/sbt_spec.rb
Expand Up @@ -22,6 +22,7 @@

it "not prime cache for sbt-start-script projects" do
Hatchet::Runner.new("sbt-start-script-sample") do |app|
# expect(app.output).to match("Running: sbt update")
expect(app.output).not_to match(/Priming Ivy cache/)
expect(app.output).to match("Running: sbt compile stage")
end
Expand Down

0 comments on commit f822291

Please sign in to comment.