Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Heroku buildpack env with working {detect,release}

  • Loading branch information...
commit 26bfc04768f16a8b96498aa47e4133b82608223b 1 parent 02ca331
Susan Potter authored February 18, 2012
2  .gitignore
... ...
@@ -0,0 +1,2 @@
  1
+tmp/
  2
+.rvmrc
11  .rvmrc.example
... ...
@@ -0,0 +1,11 @@
  1
+rvm use 1.9.2@cabal-heroku-buildpack
  2
+BUILDPACK_GHC_BASE_URL="http://www.haskell.org/ghc/dist"
  3
+GHC_BOOTSTRAP_VERSION=7.0.4
  4
+
  5
+export GHC_BOOTSTRAP_VERSION BUILDPACK_GHC_BASE_URL
  6
+
  7
+# Aruba envvars
  8
+ARUBA_REPORT_TEMPLATES=templates
  9
+ARUBA_REPORT_DIR=doc
  10
+
  11
+export ARUBA_REPORT_TEMPLATES ARUBA_REPORT_DIR
5  Gemfile
... ...
@@ -0,0 +1,5 @@
  1
+source :rubygems
  2
+
  3
+group :testing do
  4
+  gem 'aruba'
  5
+end
37  Gemfile.lock
... ...
@@ -0,0 +1,37 @@
  1
+GEM
  2
+  remote: http://rubygems.org/
  3
+  specs:
  4
+    aruba (0.4.11)
  5
+      childprocess (>= 0.2.3)
  6
+      cucumber (>= 1.1.1)
  7
+      ffi (>= 1.0.11)
  8
+      rspec (>= 2.7.0)
  9
+    builder (3.0.0)
  10
+    childprocess (0.3.1)
  11
+      ffi (~> 1.0.6)
  12
+    cucumber (1.1.5)
  13
+      builder (>= 2.1.2)
  14
+      diff-lcs (>= 1.1.2)
  15
+      gherkin (~> 2.8.0)
  16
+      json (>= 1.4.6)
  17
+      term-ansicolor (>= 1.0.6)
  18
+    diff-lcs (1.1.3)
  19
+    ffi (1.0.11)
  20
+    gherkin (2.8.0)
  21
+      json (>= 1.4.6)
  22
+    json (1.6.5)
  23
+    rspec (2.8.0)
  24
+      rspec-core (~> 2.8.0)
  25
+      rspec-expectations (~> 2.8.0)
  26
+      rspec-mocks (~> 2.8.0)
  27
+    rspec-core (2.8.0)
  28
+    rspec-expectations (2.8.0)
  29
+      diff-lcs (~> 1.1.2)
  30
+    rspec-mocks (2.8.0)
  31
+    term-ansicolor (1.0.7)
  32
+
  33
+PLATFORMS
  34
+  ruby
  35
+
  36
+DEPENDENCIES
  37
+  aruba
47  README.md
Source Rendered
... ...
@@ -0,0 +1,47 @@
  1
+# GHC/Cabal Heroku Buildpack
  2
+
  3
+This is a custom Heroku buildpack for Haskell applications that are built
  4
+using GHC and Cabal.
  5
+
  6
+## Version / Dependencies
  7
+
  8
+Based on the current (as of this writing) Haskell Platform (2011.4.0.0 ->
  9
+GHC v7.0.4).
  10
+
  11
+Work will be done after some level of stability to update this buildpack
  12
+to support GHC 7.4.x soon thereafter.
  13
+
  14
+The goal will be to allow some variance of GHC and Platform versions. At
  15
+present there are zero plans to actively support GHC 6.x with this
  16
+buildpack. If it happens to work, then great, otherwise you are free to fork
  17
+this repository to make it work for your needs.
  18
+
  19
+## Status
  20
+
  21
+Experimental; in progress - still testing.
  22
+
  23
+## Usage
  24
+
  25
+Like other buildpacks you will need to specify the buildpack when creating
  26
+your Heroku application. Something like the following:
  27
+
  28
+    heroku create --stack cedar --buildpack https://github.com/mbbx6spp/cabal-heroku-buildpack
  29
+
  30
+You will also need to specify environment variables after your app is
  31
+created. For instance,
  32
+
  33
+    BUILDPACK_GHC_BASE_URL
  34
+    BUILDPACK_PLATFORM_BASE_URL
  35
+
  36
+These should be your S3 base URL for the GHC bootstrap and Platform
  37
+distributions respectively.
  38
+
  39
+More to be said, but I am too tired to write it now.
  40
+
  41
+Check back soon.
  42
+
  43
+## Contributors
  44
+
  45
+* Susan Potter [mbbx6spp on GitHub](https://github.com/mbbx6spp)
  46
+
  47
+
22  Rakefile
... ...
@@ -0,0 +1,22 @@
  1
+# encoding: utf-8
  2
+require 'rubygems'
  3
+require 'bundler'
  4
+Bundler.setup(:testing)
  5
+
  6
+require 'cucumber/rake/task'
  7
+
  8
+def darwin?
  9
+  os=%x[uname -s]
  10
+  "Darwin" === os
  11
+end
  12
+
  13
+Cucumber::Rake::Task.new do |t|
  14
+  opts = defined?(JRUBY_VERSION) ? %w{--tags ~@jruby} : []
  15
+  opts += %w{--tags ~@fails-on-darwin} if darwin?
  16
+  t.cucumber_opts = opts
  17
+end
  18
+
  19
+desc "Run Cucumber features"
  20
+task :test => [:cucumber]
  21
+
  22
+task :default => :test
30  bin/compile
... ...
@@ -0,0 +1,30 @@
  1
+#!/usr/bin/env bash
  2
+# bin/compile BUILD_DIR CACHE_DIR
  3
+
  4
+set -e
  5
+
  6
+source scripts/functions
  7
+
  8
+BUILD_DIR=$1
  9
+CACHE_DIR=$2
  10
+
  11
+## CHECK BUILDPACK_GHC_BASE_URL is set
  12
+if [ "$BUILDPACK_GHC_BASE_URL" != "" ]; then
  13
+  arch=$(uname -m)
  14
+  ghcver=$GHC_BOOTSTRAP_VERSION
  15
+  bsdir=$CACHE_DIR/bootstrap
  16
+  ghcurl="$BUILDPACK_GHC_BASE_URL/$ghcver/ghc-$ghcver-$arch-unknown-linux.tar.bz2"
  17
+  echo "Info: bootstrap directory: ${bsdir}";
  18
+  echo "Info: bootstrap URL: $ghcurl";
  19
+  if [ -f "$bsdir.completed" ]; then
  20
+    echo "Info: already downloaded GHC bootstrap version ${ghcver}";
  21
+  else
  22
+    echo "Info: downloading GHC $ghcver form $ghcurl";
  23
+    $(downloadAndExtract $bsdir $ghcurl);
  24
+    $(configureMakeInstall $bsdir/ghc-$ghcver $BUILD_DIR/bootstrap/ghc-$ghcver);
  25
+    touch $bsdir.completed
  26
+  fi;
  27
+else
  28
+  echo "Error: please set BUILDPACK_GHC_BASE_URL";
  29
+  exit 1;
  30
+fi
15  bin/detect
... ...
@@ -0,0 +1,15 @@
  1
+#!/usr/bin/env bash
  2
+# bin/detect BUILD_DIR
  3
+set -e
  4
+
  5
+BUILD_DIR=$1
  6
+echo $BUILD_DIR
  7
+
  8
+CABAL_FILE="$(find $BUILD_DIR -maxdepth 1 -name '*.cabal' -print -quit)"
  9
+
  10
+# Check a *.cabal file exists at the root of the source tree
  11
+if [[ -e $CABAL_FILE ]]; then
  12
+  echo "GHC/Cabal" && exit 0
  13
+else
  14
+  echo "nada" && exit 1
  15
+fi
19  bin/release
... ...
@@ -0,0 +1,19 @@
  1
+#!/usr/bin/env bash
  2
+# bin/release BUILD_DIR
  3
+
  4
+BUILD_DIR=$1
  5
+
  6
+cat <<EOF
  7
+---
  8
+config_vars:
  9
+  GHC_PACKAGE_PATH: "$BUILD_DIR/ghc-packages.conf:"
  10
+  GHCRTS: "-M512m -c70 -H128m"
  11
+  HASKELL_PLATFORM_VERSION: 2011.4.0.0
  12
+  GHC_BOOTSTRAP_VERSION: 7.0.4
  13
+  BUILDPACK_GHC_BASE_URL:
  14
+  BUILDPACK_PLATFORM_BASE_URL:
  15
+addons:
  16
+  - shared-database:5mb
  17
+default_process_types:
  18
+EOF
  19
+
15  features/detect.feature
... ...
@@ -0,0 +1,15 @@
  1
+Feature: Detect
  2
+
  3
+  In order to build and deploy an application
  4
+  As the bin/detect script of the buildpack
  5
+  I want to determine if the source tree is buildable
  6
+
  7
+  Scenario: no *.cabal file
  8
+    When I run `detect ../features/fixtures/invaliddir`
  9
+    Then the output should contain "nada"
  10
+    And the exit status should be 1
  11
+
  12
+  Scenario: a *.cabal file
  13
+    When I run `detect ../features/fixtures/validdir`
  14
+    Then the output should contain "GHC/Cabal"
  15
+    And the exit status should be 0
0  features/fixtures/validdir/bla.cabal
No changes.
12  features/release.feature
... ...
@@ -0,0 +1,12 @@
  1
+Feature: Release
  2
+
  3
+  In order to build and deploy an application
  4
+  As the bin/release script of the buildpack
  5
+  I want to setup the build environment
  6
+
  7
+  Scenario: default
  8
+    When I run `release`
  9
+    Then the output should contain "addons:"
  10
+    And  the output should contain "config_vars:"
  11
+    And  the output should contain "default_process_types:"
  12
+    And  the exit status should be 0
0  features/step_definitions/core.rb
No changes.
17  features/support/env.rb
... ...
@@ -0,0 +1,17 @@
  1
+require 'rubygems'
  2
+require 'aruba/cucumber'
  3
+require 'fileutils'
  4
+require 'rspec/expectations'
  5
+
  6
+ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
  7
+
  8
+Before do
  9
+  @aruba_timeout_seconds = 5
  10
+  @dirs = ["bin"]
  11
+end
  12
+
  13
+Aruba.configure do |config|
  14
+  config.before_cmd do |cmd|
  15
+    puts "About to run '#{cmd}'"
  16
+  end
  17
+end
37  scripts/functions
... ...
@@ -0,0 +1,37 @@
  1
+
  2
+function indent() {
  3
+  c='s/^/       /'
  4
+    case $(uname) in
  5
+      Darwin) sed -l "$c";;
  6
+  *)      sed -u "$c";;
  7
+  esac
  8
+}
  9
+
  10
+function clearEnvironment() {
  11
+  unset GIT_DIR
  12
+}
  13
+
  14
+function downloadAndExtract() {
  15
+  mkdir -p $1 && curl $2 -o - | tar jxf - -C $1
  16
+}
  17
+
  18
+function configureMakeInstall() {
  19
+  pushd $1
  20
+  echo -n "Info: configure --prefix=$2"
  21
+  ./configure --prefix=$2;
  22
+  echo "[OK]"
  23
+  echo -n "Info: make"
  24
+  make
  25
+  echo "[OK]";
  26
+  echo -n "Info: make install"
  27
+  make install
  28
+  echo "[OK]"
  29
+  popd
  30
+}
  31
+
  32
+function mkCompilerDir() {
  33
+  local compilerDir=$CACHE_DIR/compilers/$1;
  34
+  [[ ! -d "$compilerDir" ]]; mkdir -p $compilerDir;
  35
+  echo $compilerDir;
  36
+}
  37
+

0 notes on commit 26bfc04

Please sign in to comment.
Something went wrong with that request. Please try again.