bake-0.5: Continuous integration system

Safe HaskellNone
LanguageHaskell2010

Development.Bake

Contents

Description

A continuous integration system. For an example of how to get started see https://github.com/ndmitchell/bake#readme.

Synopsis

Execute

bake :: (Stringy state, Stringy patch, Stringy test) => Oven state patch test -> IO () Source #

The entry point to the system. Usually you will define:

main = bake myOven

Where myOven defines details about the server. The program deals with command line arguments, run --help for details.

Central types

data Oven state patch test Source #

The central type defining a continuous integration system. Usually constructed with defaultOven then filled out with other Oven modifiers such as ovenGit and ovenTest.

The types are: state is the base state of the system (think HEAD on the master branch); patch is a change that is proposed (think a diff); test is the type of tests that are run.

All IO operations will be called in a direct subdirectory of the directory you start bake from. In particular: ovenInit will always be called single-threaded from bake-init; ovenUpdate will always be called single-threaded from bake-update-hash; ovenPatchExtra will always be called from bake-extra-hash; ovenPrepare and run will always be called from bake-test-hash.

Constructors

Oven 

Fields

  • ovenInit :: IO state

    Get an initial state

  • ovenUpdate :: state -> [patch] -> IO state

    Given a state, and a set of candiates that have passed, merge to create a new state

  • ovenPrepare :: state -> [patch] -> IO [test]

    Prepare a candidate to be run, produces the tests that must pass

  • ovenTestInfo :: test -> TestInfo test

    Produce information about a test

  • ovenNotify :: Author -> String -> String -> IO ()

    Tell an author some information. The first String is a subject line, the second an HTML fragment.

  • ovenPatchExtra :: state -> Maybe patch -> IO (String, String)

    Extra information about a patch, a single line (HTML span), and a longer chunk (HTML block)

  • ovenServer :: (Host, Port)

    Default server to use

  • ovenSupersede :: patch -> patch -> Bool

    Given two patches (first on submitted first) is the first now redundant

defaultOven :: Oven () () () Source #

The default oven, which doesn't do anything interesting. Usually the starting point.

class Stringy s where Source #

A type representing a translation between a value and a string, which can be produced by readShowStringy if the type has both Read and Show instances. The functions stringyTo and stringyFrom should be inverses of each other. The function stringyPretty shows a value in a way suitable for humans, and can discard uninteresting information.

Minimal complete definition

stringyTo, stringyFrom

Oven modifiers

ovenTest :: IO [test] -> (test -> TestInfo test) -> Oven state patch () -> Oven state patch test Source #

Given a Stringy for test, and a function that when run on a code base returns the list of tests that need running, and a function to populate a TestInfo, modify the Oven with a test type.

ovenGit :: String -> String -> Maybe FilePath -> Oven () () test -> Oven SHA1 SHA1 test Source #

Modify an Oven to work with the Git version control system. Requires the name of the repo (e.g. https://github.com/ndmitchell/bake.git) and the name of a branch (e.g. master). You can optionally give a path fragment which is used to clone into.

ovenStepGit Source #

Arguments

:: IO [FilePath]

Function that does a compile and returns the pieces that should be available at test time

-> String

Git repo you are using

-> String

Branch used as the initial starting point

-> Maybe FilePath

Path under which the git will be checked out

-> [String]

.gitignore patterns where build products live

-> Oven () () test

Normal oven

-> Oven SHA1 SHA1 test 

Oven creation for modules using git with the step strategy. Note that any files not in .gitignore will be removed at each step, so make sure your incremental build-products are properly ignored.

ovenNotifyAdd :: (Author -> String -> String -> IO ()) -> Oven state patch test -> Oven state patch test Source #

Add an additional notification to the list.

ovenNotifyStdout :: Oven state patch test -> Oven state patch test Source #

Produce notifications on stdout when users should be notified about success/failure.

ovenNotifyEmail :: (Host, Port) -> Oven state patch test -> Oven state patch test Source #

Send notifications using the given SMTP host/port.

ovenPretty :: Oven state patch test -> Oven state (Pretty patch) test Source #

Define an oven that allows foo=... annotations to be added to the strings. These can be used to annotate important information, e.g. instead of talking about Git SHA1's, you can talk about person=SHA1 or branch=SHA1.

ovenPrettyMerge :: Oven state (Pretty patch) test -> Oven state (Pretty patch) test Source #

An oven suitable for use with ovenPretty that supersedes patches which have the same pretty name.

ovenIncremental :: Oven state patch test -> Oven state patch test Source #

This requires a version of cp. On Windows, you can get that here: http://gnuwin32.sourceforge.net/packages/coreutils.htm

TestInfo members

data TestInfo test Source #

Information about a test.

Instances

Functor TestInfo Source # 

Methods

fmap :: (a -> b) -> TestInfo a -> TestInfo b #

(<$) :: a -> TestInfo b -> TestInfo a #

Monoid (TestInfo test) Source # 

Methods

mempty :: TestInfo test #

mappend :: TestInfo test -> TestInfo test -> TestInfo test #

mconcat :: [TestInfo test] -> TestInfo test #

run :: IO () -> TestInfo test Source #

The action associated with a test.

threads :: Int -> TestInfo test -> TestInfo test Source #

Change the number of threads a test requires, defaults to 1.

threadsAll :: TestInfo test -> TestInfo test Source #

Record that a test requires all available threads on a machine, typically used for the build step. Use getNumCapabilities to find out how many threads you were allocated.

depend :: [test] -> TestInfo test -> TestInfo test Source #

Require the following tests have been evaluated on this machine before this test is run. Typically used to require compilation before running most tests.

require :: [String] -> TestInfo test -> TestInfo test Source #

Is a particular client capable of running a test. Usually an OS check. To run a test must have all its requirements met. Clients can satisfy a requirement by passing --provide=... on the command line.

priority :: Int -> TestInfo test -> TestInfo test Source #

Set the priority of a test, those with higher priority are run first. Tests have a default priority of 0.

Operations

startServer :: (Stringy state, Stringy patch, Stringy test) => Port -> [Author] -> Seconds -> String -> Bool -> Oven state patch test -> IO () Source #

startClient :: (Stringy state, Stringy patch, Stringy test) => (Host, Port) -> Author -> String -> Int -> [String] -> Double -> Oven state patch test -> IO () Source #

garbageCollect Source #

Arguments

:: Integer

Minimum number of bytes you want free on the drive (use 0 if you don't want any)

-> Double

Ratio of the drive you want free, e.g. 0.25 to demand a quarter of the drive free (1 to delete everything you can)

-> Seconds

Minimum age to delete in seconds

-> [FilePath]

Directories containing Bake stuff

-> IO () 

Garbage collect enough files to satisfy the requirements.

Utility types

type Port = Int Source #