bake-0.3: 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 -> IO ()

Tell an author some information contained in the string (usually an email)

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.

data SHA1 Source

Instances

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

-> Oven () () test

Normal oven

-> Oven SHA1 SHA1 test 

Oven creation for modules using git with the step strategy.

ovenNotifyAdd :: ([Author] -> 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) -> (Author -> [String]) -> Oven state patch test -> Oven state patch test Source

Email notifications when users should be notified about success/failure.

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

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

TestInfo members

data TestInfo test Source

Information about a test.

Instances

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