Lets add support to Circle CI to make sure the code is tested regularly. The idea is to have Circle CI to build and run the tests so we can have confidence that the project is in a health state.
The first thing you will need is to create an account on the Circle CI website and add the project so Circle CI can start to monitor your repository and start the building process as soon as new commits arrive.
Having the account created and the project added, we need to create the configuration file - circle.yml - in the project’s root folder. This file will tell Circle CI about the project dependencies and what commands to run.
We will need to change the test-settings.yml and the TestImport.hs files so Yesod will handle settings with environment variables when running the tests.
First we tell Yesod that flora_test is the default test database and that it can be overwritten by the PGDATABASE environment variable.
--- a/config/test-settings.yml +++ b/config/test-settings.yml @@ -1,2 +1,2 @@ database: - database: flora_test + database: "_env:PGDATABASE:flora_test"
Secondly, we need to change the TestImport.hs file because it ignores environment variables by default.
diff --git a/test/TestImport.hs b/test/TestImport.hs index 625acce..ad76ec4 100644 --- a/test/TestImport.hs +++ b/test/TestImport.hs @@ -11,7 +11,7 @@ import Foundation as X import Model as X import Test.Hspec as X import Text.Shakespeare.Text (st) -import Yesod.Default.Config2 (ignoreEnv, loadAppSettings) +import Yesod.Default.Config2 (useEnv, loadAppSettings) import Yesod.Test as X runDB :: SqlPersistM a -> YesodExample App a @@ -28,7 +28,7 @@ withApp = before $ do settings <- loadAppSettings ["config/test-settings.yml", "config/settings.yml"]  - ignoreEnv + useEnv foundation <- makeFoundation settings wipeDB foundation logWare <- liftIO $ makeLogWare foundation
Now, every time you push a commit to github, Circle CI will build the project and run the tests.
You can access the Project settings -> Status badges menu in the Circle CI platform and generate a badge for you to put in your project README file. The badge will change as the last build build successfully or not.
This is how it looks like: