From 26bfc04768f16a8b96498aa47e4133b82608223b Mon Sep 17 00:00:00 2001 From: Susan Potter Date: Sat, 18 Feb 2012 01:25:51 -0600 Subject: [PATCH] Heroku buildpack env with working {detect,release} --- .gitignore | 2 ++ .rvmrc.example | 11 +++++++ Gemfile | 5 +++ Gemfile.lock | 37 ++++++++++++++++++++++ README.md | 47 ++++++++++++++++++++++++++++ Rakefile | 22 +++++++++++++ bin/compile | 30 ++++++++++++++++++ bin/detect | 15 +++++++++ bin/release | 19 +++++++++++ features/detect.feature | 15 +++++++++ features/fixtures/validdir/bla.cabal | 0 features/release.feature | 12 +++++++ features/step_definitions/core.rb | 0 features/support/env.rb | 17 ++++++++++ scripts/functions | 37 ++++++++++++++++++++++ 15 files changed, 269 insertions(+) create mode 100644 .gitignore create mode 100644 .rvmrc.example create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 README.md create mode 100644 Rakefile create mode 100755 bin/compile create mode 100755 bin/detect create mode 100755 bin/release create mode 100644 features/detect.feature create mode 100644 features/fixtures/validdir/bla.cabal create mode 100644 features/release.feature create mode 100644 features/step_definitions/core.rb create mode 100644 features/support/env.rb create mode 100644 scripts/functions diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1577a23 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +tmp/ +.rvmrc diff --git a/.rvmrc.example b/.rvmrc.example new file mode 100644 index 0000000..eabab72 --- /dev/null +++ b/.rvmrc.example @@ -0,0 +1,11 @@ +rvm use 1.9.2@cabal-heroku-buildpack +BUILDPACK_GHC_BASE_URL="http://www.haskell.org/ghc/dist" +GHC_BOOTSTRAP_VERSION=7.0.4 + +export GHC_BOOTSTRAP_VERSION BUILDPACK_GHC_BASE_URL + +# Aruba envvars +ARUBA_REPORT_TEMPLATES=templates +ARUBA_REPORT_DIR=doc + +export ARUBA_REPORT_TEMPLATES ARUBA_REPORT_DIR diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..1c906f8 --- /dev/null +++ b/Gemfile @@ -0,0 +1,5 @@ +source :rubygems + +group :testing do + gem 'aruba' +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..e8867ee --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,37 @@ +GEM + remote: http://rubygems.org/ + specs: + aruba (0.4.11) + childprocess (>= 0.2.3) + cucumber (>= 1.1.1) + ffi (>= 1.0.11) + rspec (>= 2.7.0) + builder (3.0.0) + childprocess (0.3.1) + ffi (~> 1.0.6) + cucumber (1.1.5) + builder (>= 2.1.2) + diff-lcs (>= 1.1.2) + gherkin (~> 2.8.0) + json (>= 1.4.6) + term-ansicolor (>= 1.0.6) + diff-lcs (1.1.3) + ffi (1.0.11) + gherkin (2.8.0) + json (>= 1.4.6) + json (1.6.5) + rspec (2.8.0) + rspec-core (~> 2.8.0) + rspec-expectations (~> 2.8.0) + rspec-mocks (~> 2.8.0) + rspec-core (2.8.0) + rspec-expectations (2.8.0) + diff-lcs (~> 1.1.2) + rspec-mocks (2.8.0) + term-ansicolor (1.0.7) + +PLATFORMS + ruby + +DEPENDENCIES + aruba diff --git a/README.md b/README.md new file mode 100644 index 0000000..c47d6d1 --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# GHC/Cabal Heroku Buildpack + +This is a custom Heroku buildpack for Haskell applications that are built +using GHC and Cabal. + +## Version / Dependencies + +Based on the current (as of this writing) Haskell Platform (2011.4.0.0 -> +GHC v7.0.4). + +Work will be done after some level of stability to update this buildpack +to support GHC 7.4.x soon thereafter. + +The goal will be to allow some variance of GHC and Platform versions. At +present there are zero plans to actively support GHC 6.x with this +buildpack. If it happens to work, then great, otherwise you are free to fork +this repository to make it work for your needs. + +## Status + +Experimental; in progress - still testing. + +## Usage + +Like other buildpacks you will need to specify the buildpack when creating +your Heroku application. Something like the following: + + heroku create --stack cedar --buildpack https://github.com/mbbx6spp/cabal-heroku-buildpack + +You will also need to specify environment variables after your app is +created. For instance, + + BUILDPACK_GHC_BASE_URL + BUILDPACK_PLATFORM_BASE_URL + +These should be your S3 base URL for the GHC bootstrap and Platform +distributions respectively. + +More to be said, but I am too tired to write it now. + +Check back soon. + +## Contributors + +* Susan Potter [mbbx6spp on GitHub](https://github.com/mbbx6spp) + + diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..b8376c9 --- /dev/null +++ b/Rakefile @@ -0,0 +1,22 @@ +# encoding: utf-8 +require 'rubygems' +require 'bundler' +Bundler.setup(:testing) + +require 'cucumber/rake/task' + +def darwin? + os=%x[uname -s] + "Darwin" === os +end + +Cucumber::Rake::Task.new do |t| + opts = defined?(JRUBY_VERSION) ? %w{--tags ~@jruby} : [] + opts += %w{--tags ~@fails-on-darwin} if darwin? + t.cucumber_opts = opts +end + +desc "Run Cucumber features" +task :test => [:cucumber] + +task :default => :test diff --git a/bin/compile b/bin/compile new file mode 100755 index 0000000..30f546e --- /dev/null +++ b/bin/compile @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# bin/compile BUILD_DIR CACHE_DIR + +set -e + +source scripts/functions + +BUILD_DIR=$1 +CACHE_DIR=$2 + +## CHECK BUILDPACK_GHC_BASE_URL is set +if [ "$BUILDPACK_GHC_BASE_URL" != "" ]; then + arch=$(uname -m) + ghcver=$GHC_BOOTSTRAP_VERSION + bsdir=$CACHE_DIR/bootstrap + ghcurl="$BUILDPACK_GHC_BASE_URL/$ghcver/ghc-$ghcver-$arch-unknown-linux.tar.bz2" + echo "Info: bootstrap directory: ${bsdir}"; + echo "Info: bootstrap URL: $ghcurl"; + if [ -f "$bsdir.completed" ]; then + echo "Info: already downloaded GHC bootstrap version ${ghcver}"; + else + echo "Info: downloading GHC $ghcver form $ghcurl"; + $(downloadAndExtract $bsdir $ghcurl); + $(configureMakeInstall $bsdir/ghc-$ghcver $BUILD_DIR/bootstrap/ghc-$ghcver); + touch $bsdir.completed + fi; +else + echo "Error: please set BUILDPACK_GHC_BASE_URL"; + exit 1; +fi diff --git a/bin/detect b/bin/detect new file mode 100755 index 0000000..9ac0dae --- /dev/null +++ b/bin/detect @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# bin/detect BUILD_DIR +set -e + +BUILD_DIR=$1 +echo $BUILD_DIR + +CABAL_FILE="$(find $BUILD_DIR -maxdepth 1 -name '*.cabal' -print -quit)" + +# Check a *.cabal file exists at the root of the source tree +if [[ -e $CABAL_FILE ]]; then + echo "GHC/Cabal" && exit 0 +else + echo "nada" && exit 1 +fi diff --git a/bin/release b/bin/release new file mode 100755 index 0000000..b6adfa8 --- /dev/null +++ b/bin/release @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# bin/release BUILD_DIR + +BUILD_DIR=$1 + +cat <