From 040893a0d49ed7f0302fe6433fcadcc278c5d569 Mon Sep 17 00:00:00 2001 From: Greg Weber Date: Fri, 15 Jul 2011 07:25:56 -0700 Subject: [PATCH 1/3] add heroku Procfile dd Procfile --- scaffold.hs | 3 +++ scaffold/deploy/Procfile.cg | 47 +++++++++++++++++++++++++++++++++++++ yesod.cabal | 2 ++ 3 files changed, 52 insertions(+) create mode 100644 scaffold/deploy/Procfile.cg diff --git a/scaffold.hs b/scaffold.hs index 8d0fb6ab..c76fe7b7 100644 --- a/scaffold.hs +++ b/scaffold.hs @@ -100,6 +100,9 @@ scaffold = do mkDir "static/js" mkDir "config" mkDir "Model" + mkDir "deploy" + + writeFile' ("deploy/Procfile") $(codegen "deploy/Procfile") case backendS of "s" -> writeFile' ("config/" ++ backendLower ++ ".yml") $(codegen ("config/sqlite.yml")) diff --git a/scaffold/deploy/Procfile.cg b/scaffold/deploy/Procfile.cg new file mode 100644 index 00000000..3f79f92c --- /dev/null +++ b/scaffold/deploy/Procfile.cg @@ -0,0 +1,47 @@ +# Simple and free deployment to Heroku. +# +# !! Warning: You must use a 64 bit machine to compile !! +# +# This could mean using a virtual machine. Give your VM as much memory as you can to speed up linking. +# +# Yesod setup: +# +# * Move this file out of the deploy directory and into your root directory +# +# mv deploy/Procfile ./ +# +# * Create an empty Gemfile and Gemfile.lock +# +# touch Gemfile && touch Gemfile.lock +# +# * TODO: code to read DATABASE_URL environment variable. +# +# import System.Environment +# main = do +# durl <- getEnv "DATABASE_URL" +# # parse env variable +# # pass settings to withConnectionPool instead of directly using loadConnStr +# +# Heroku setup: +# Find the Heroku guide. Roughly: +# +# * sign up for a heroku account and register your ssh key +# * create a new application on the *cedar* stack +# +# * make your Yesod project the git repository for that application +# * create a deploy branch +# +# git checkout -b deploy +# +# Repeat these steps to deploy: +# * add your web executable binary (referenced below) to the git repository +# +# git add ./dist/build/~project~/~project~ +# +# * push to Heroku +# +# git push heroku deploy:master + + +# Heroku configuration that runs your app +web: ./dist/build/~project~/~project~ -p $PORT diff --git a/yesod.cabal b/yesod.cabal index 287f6d18..b5171709 100644 --- a/yesod.cabal +++ b/yesod.cabal @@ -16,6 +16,7 @@ build-type: Simple homepage: http://www.yesodweb.com/ extra-source-files: + input/*.cg scaffold/cassius/default-layout.cassius.cg, scaffold/cassius/homepage.cassius.cg, scaffold/Model.hs.cg scaffold/sitearg.hs.cg, @@ -31,6 +32,7 @@ extra-source-files: scaffold/pconn1.cg, scaffold/.ghci.cg, scaffold/cabal.cg, + scaffold/deploy/Procfile.cg, scaffold/Controller.hs.cg, scaffold/julius/homepage.julius.cg, scaffold/hamlet/homepage.hamlet.cg, From 67fc2f8aa7f3707331a71df64deed2bd9246def1 Mon Sep 17 00:00:00 2001 From: Greg Weber Date: Fri, 15 Jul 2011 08:03:25 -0700 Subject: [PATCH 2/3] fix tests- clientsession dependencies --- development.md | 2 ++ scaffold/cabal.cg | 1 + scaffold/mini/cabal.cg | 1 + scaffold/mini/sitearg.hs.cg | 1 + 4 files changed, 5 insertions(+) diff --git a/development.md b/development.md index cd390502..9568de23 100644 --- a/development.md +++ b/development.md @@ -6,6 +6,8 @@ Run this from the project root directory. It will make sure each site type build shelltest tests/scaffold.shelltest +Give it the --debug flag to see all output + ## Quicker, repeatable site building Useful for debugging individual failures. diff --git a/scaffold/cabal.cg b/scaffold/cabal.cg index b58eaf07..67b8b7b2 100644 --- a/scaffold/cabal.cg +++ b/scaffold/cabal.cg @@ -51,6 +51,7 @@ executable ~project~ , yesod-auth >= 0.4 && < 0.5 , yesod-static >= 0.1 && < 0.2 , mime-mail + , clientsession , wai-extra , directory , bytestring diff --git a/scaffold/mini/cabal.cg b/scaffold/mini/cabal.cg index 4f570c2d..20d3381f 100644 --- a/scaffold/mini/cabal.cg +++ b/scaffold/mini/cabal.cg @@ -48,6 +48,7 @@ executable ~project~ build-depends: base >= 4 && < 5 , yesod-core >= 0.8 && < 0.9 , yesod-static + , clientsession , wai-extra , directory , bytestring diff --git a/scaffold/mini/sitearg.hs.cg b/scaffold/mini/sitearg.hs.cg index e7c59ee8..64763598 100644 --- a/scaffold/mini/sitearg.hs.cg +++ b/scaffold/mini/sitearg.hs.cg @@ -24,6 +24,7 @@ import Control.Monad (unless) import Control.Monad.Trans.Class (lift) import Control.Monad.IO.Class (liftIO) import qualified Data.Text as T +import Web.ClientSession (getKey) -- | The site argument for your application. This can be a good place to -- keep settings and values requiring initialization before your application From ab30fdcfe6a45beee2f930c06820802dfeb65c9a Mon Sep 17 00:00:00 2001 From: Greg Weber Date: Fri, 15 Jul 2011 08:41:07 -0700 Subject: [PATCH 3/3] add wrapper for shelltest --- development.md | 4 +++- tests/run.sh | 17 +++++++++++++++++ tests/runscaffold.sh | 2 +- tests/scaffold.shelltest | 11 +---------- 4 files changed, 22 insertions(+), 12 deletions(-) create mode 100755 tests/run.sh diff --git a/development.md b/development.md index 9568de23..531621ea 100644 --- a/development.md +++ b/development.md @@ -2,9 +2,11 @@ ## Test suite +install the shelltest package: cabal install shelltests + Run this from the project root directory. It will make sure each site type builds. It first does an sdist, which ensures we are testing what will be put on hackage. - shelltest tests/scaffold.shelltest + tests/run.sh Give it the --debug flag to see all output diff --git a/tests/run.sh b/tests/run.sh new file mode 100755 index 00000000..93536b6d --- /dev/null +++ b/tests/run.sh @@ -0,0 +1,17 @@ +#!/bin/bash -x +# +# A wrapper for the shelltest test. Passes along options to shelltest. +# +# cabal install shelltestrunner + +cabal clean && cabal install && cabal sdist + +# I am not that good at shell scripting +# this for loop only operates on 1 file (as per tail -1) +for f in $(ls -1rt dist/*.tar.gz | tail -1) +do + tar -xzvf $f && cd `basename $f .tar.gz` + shelltest ../tests/scaffold.shelltest $@ + cd .. + rm -r `basename $f .tar.gz` +done diff --git a/tests/runscaffold.sh b/tests/runscaffold.sh index 6ec79864..03b40ced 100755 --- a/tests/runscaffold.sh +++ b/tests/runscaffold.sh @@ -1,3 +1,3 @@ #!/bin/bash -x - rm -rf foobar && runghc scaffold.hs init && cd foobar && cabal install && cabal install -fdevel && cd .. +rm -rf foobar && runghc scaffold.hs init && cd foobar && cabal install && cabal install -fdevel && cd .. diff --git a/tests/scaffold.shelltest b/tests/scaffold.shelltest index 16cd5be7..a35a8554 100644 --- a/tests/scaffold.shelltest +++ b/tests/scaffold.shelltest @@ -1,13 +1,4 @@ -# This uses shelltest -# -# cabal install shelltestrunner -# shelltest tests/scaffold.shelltest -# -# note that the first 2 lines setup this test but will also be counted as 2 tests. - -cabal clean && cabal install && cabal sdist - -for f in $(ls -1rt dist/*.tar.gz | tail -1); do tar -xzvf $f && cd `basename $f .tar.gz`; done +# Important! run with tests/run.sh rm -rf foobar && runghc scaffold.hs init && cd foobar && cabal install && cabal install -fdevel && cd .. <<<