ndmitchell / bake Goto Github PK
View Code? Open in Web Editor NEWUNMAINTAINED: Continuous integration server
License: Other
UNMAINTAINED: Continuous integration server
License: Other
I currently disable the complete Haddock doc check because lots of things fail. I should fix the docs and enable it.
Related to #8, I should use streaming to send and receive data with Bake, so I can work with much bigger test files. Currently the limit isn't that high - 10Mb is fine, but 30Mb is too much. I think the problem is going via Aeson, which isn't designed for streaming. Perhaps I should send all the JSON on the first line, then switch to just raw data, which I use proper conduit to stream.
Tricky to get rid of, so should make sure I'm doing it right.
Two related issues:
README.md
suggests that bake addpatch --name=cb3c2a71
should work, but it doesn't because a hash must be 40 chars long (see sha1
in src/Development/Bake/Git.hs
).addpatch
, rowPatch
in src/Development/Bake/Server/Web.hs
will prepend a quote to it, so the hash will fail the 40 char check in sha1
. After that I had to clean all bake files because it failed to start.Error messages:
Output: bake-test: SHA1 for Git must be 40 characters long, got "'ec1b02295770352e9f4c8ff2b675b1ada898f896"
bake-test: user error (Pattern match failure in do expression at src/Development/Bake/Server/Store.hs:116:9-98)
Steps to reproduce (in the bake source dir):
terminal1$ REPO=$(pwd) dist/build/bake-test/bake-test server
terminal2$ REPO=$(pwd) dist/build/bake-test/bake-test client
terminal3$ dist/build/bake-test/bake-test addpatch --name=$(git rev-parse HEAD)
I've tried changing both sha1
and rowPatch
, but neither seems to work. Unfortunately, I have to give up on this for today, but here are the patches. Not sure whether either is a good idea, so I'm just putting them here.
commit 3ad1d26314fb534bb1347658036015b9a525b65d
Author: Nikita Karetnikov <[email protected]>
Date: Thu Jul 9 18:32:09 2015 +0300
Do not prepend a quote to a hash on retry
This causes bake to fail because it expects a hash to be 40 characters
long.
diff --git a/src/Development/Bake/Server/Web.hs b/src/Development/Bake/Server/Web.hs
index 8d75f27..4b068d1 100644
--- a/src/Development/Bake/Server/Web.hs
+++ b/src/Development/Bake/Server/Web.hs
@@ -334,7 +334,7 @@ rowPatch Shower{..} mem@Memory{..} argsAdmin info = (code, [showTime time, state
if paAlive pi then
do br_; admin (DelPatch p) $ str_ "Delete"
else if isNothing $ paMerge pi then
- do br_; admin (AddPatch (paAuthor pi) $ toPatch $ '\'' : fromPatch p) $ str_ "Retry"
+ do br_; admin (AddPatch (paAuthor pi) p) $ str_ "Retry"
else
mempty
| otherwise = mempty
commit a173edc71188ded5dada2c8dfe61e55daf05c021
Author: Nikita Karetnikov <[email protected]>
Date: Thu Jul 9 18:50:34 2015 +0300
Do not check the length of a hash
diff --git a/src/Development/Bake/Git.hs b/src/Development/Bake/Git.hs
index 24f739c..a4c30f5 100644
--- a/src/Development/Bake/Git.hs
+++ b/src/Development/Bake/Git.hs
@@ -24,8 +24,9 @@ import Prelude
newtype SHA1 = SHA1 {fromSHA1 :: String} deriving (Show,Eq)
sha1 :: String -> SHA1
-sha1 x | length x /= 40 = error $ "SHA1 for Git must be 40 characters long, got " ++ show x
- | not $ all (`elem` "0123456789abcdef") x = error $ "SHA1 for Git must be all lower case hex, got " ++ show x
+sha1 x | not $ all (`elem` "0123456789abcdef'") x =
+ error $ "SHA1 for Git must be all lower case hex " ++
+ "or a quote character ('), got " ++ show x
| otherwise = SHA1 x
instance Stringy SHA1 where
We use multiple, small (generally package specific) git repositories. It would be ideal to see the collected status of these repositories from a single server. I realize the current design does not accommodate this approach, but I'm curious if there's a reason this type of approach is a bad idea or counter to the Bake philosophy.
If a client disappears then reappears with the same name, that should be treated as an entirely fresh client, and all their pending jobs should be timed out. Perhaps make client name a random string, with a pretty string to display too?
I'm on Bake 0.3 because I use stack and the said version is on
Hackage. I've modified the provided Example.hs
slightly (an aside:
I've read in some issue here that you recommend to run Bake outside
the project directory, but my version doesn't support that for now due
to a call to stack build
despite the fact that functions take a repo
argument, ignore this sloppiness).
For now, I just want to build the project with stack build
on
Compile
and call the test
executable on Run
. The code seems to
work, but some things I don't understand yet.
I ran bake server
and bake client
from the project root, made a
new branch, committed a patch, and ran bake addpatch
on that hash.
Then I looked at the server UI and there were no signs of activity, so
I committed another patch and added it to Bake (I gathered it might
trigger it or something). After a while, Bake started building and
testing the first patch. Why was there a delay? The build succeeded
according to the status message, so I expected it to be merged into
master
, which didn't happen. Here's the tail of the build log:
Registering Snowdrift-0.1.4...
Waited 0.00s to acquire the file lock /home/nikita/haskell/snowdrift/bake-step-git-4762652644488644249/.bake-lock
[BAKE-TIME] 13.47s (total of 13.53s): git fetch
Waited 0.00s to acquire the file lock /home/nikita/haskell/snowdrift/bake-step-git-4762652644488644249/.bake-lock
[BAKE-TIME] 0.19s (total of 13.71s): git checkout --force -B master e08749f1a95646702edc84c535ff87ce3e10e1bc
[BAKE-TIME] 0.62s (total of 14.33s): git merge a6fb84fcc4798fdcb1f46c60ff1aa5037c75fe3a
[BAKE-TIME] 5m35s (total of 5m49s): stepPrepare user action
[BAKE-TIME] 1.39s (total of 5m51s): tar -cf ../bake-step-git-4762652644488644249/../bake-step-point-3521543077975254953/result.tar -C ../bake-step-git-4762652644488644249/repo /home/nikita/haskell/snowdrift/dist/build/test/test
[BAKE-TIME] 0.15s (total of 5m51s): tar -xf ../bake-step-git-4762652644488644249/../bake-step-point-3521543077975254953/result.tar -C .
From /home/nikita/haskell/snowdrift
* [new branch] bake -> origin/bake
Reset branch 'master'
tar: Removing leading `/' from member names
Is my assumption incorrect, or did something go wrong?
The other two patches have been in the "Queued" status for 40 minutes
or so, nothing shows up on the server UI or at the logs. The client
(Thomas) has "None" at the "Running" field. What's the problem?
{-# LANGUAGE FlexibleInstances #-}
module Main where
import Prelude
import Control.Monad
import Data.List.Extra
import Data.Maybe
import Data.Tuple.Extra
import Development.Bake
import Development.Shake.Command
import System.Environment.Extra
import System.FilePath
data Platform = Linux {-| Windows-} deriving (Show,Read)
data Action = Compile | Run deriving (Show,Read)
instance Stringy (Platform, Action) where
stringyTo (a,b) = show a ++ " " ++ show b
stringyFrom = (read *** read) . word1
platforms :: [Platform]
platforms = [Linux{-,Windows-}]
main :: IO ()
main = do
let env = "REPO"
envError = "You need to set an environment variable named $"
++ env ++ " for the Git repo"
repo <- fromMaybe (error envError) `fmap` lookupEnv env
bake $
ovenPretty $
ovenStepGit (compile repo) repo "master" Nothing $
ovenNotifyStdout $
ovenTest (return allTests) (execute repo)
defaultOven{ovenServer=("127.0.0.1",5000)}
allTests :: [(Platform, Action)]
allTests = [(p,t) | p <- platforms, t <- [Compile,Run]]
exe :: FilePath -> FilePath
exe repo = repo </> "dist/build/test/test"
compile :: FilePath -> IO [FilePath]
compile repo = do unit $ cmd "stack build"; return [exe repo]
execute :: FilePath -> (Platform,Action) -> TestInfo (Platform,Action)
execute repo (p, Compile) =
require [show p] $ run $ void $ compile repo
execute repo (p, Run) =
depend [(p,Compile)] $ require [show p] $ run $ cmd $ exe repo
It is not clear to me which arguments to pass and what they mean...
I don't seem to be getting notifications when clients come or go.
I would like to add notes to git repository when bake has run, to store a summary of the build outcome and docker images ids that I generate from a given commit. I was thinking of overloading ovenUpdateState :: Maybe (state, [patch]) -> IO state
in Oven, as I think this is executed at the end of the run. Is this assumption correct? How do I retrieve the outcome of the tests at this stage?
Thanks for your help
The web page lists the most recent commit at the top. The email has the most recent at the bottom. Should be consistent. Still ideally want to send emails to the first person first though.
We would like our bake server to be able to handle multiple git branches with different workflows. Is it possible already and if so, what would be the best way to do that?
We run GC with a space factor of 20% and when the disk is getting full, we cannot even pass a single build as GC removes the latest build in bake-incremental.txt
which is then not usable by subsequent builds. GC should never remove directory pointed at bake-incremental.txt
nor currently in use directory.
Hi,
I have problems building with ghc-7.8.4 on a couple of different environments. First I tried on an old RH box (you probably know the one). I then tried on my nixos box using stack. In both of these cases I get:
/home/ben/dev/haskell/bake/src/General/HTML.hs:76:15:
No instance for (Eq
(WriterT Rope Data.Functor.Identity.Identity a))
arising from the 'deriving' clause of a data type declaration
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
When deriving the instance for (Eq (HTML_ a))
/home/ben/dev/haskell/bake/src/General/HTML.hs:76:18:
No instance for (Ord
(WriterT Rope Data.Functor.Identity.Identity a))
arising from the 'deriving' clause of a data type declaration
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
When deriving the instance for (Ord (HTML_ a))
This seems to be needing base-4.9.0.0 to work as base-4.7.0.1 doens't have the Ord1 instance for Identity.
The ghc environment on this machine seem... quirky... though.
Couldn't find an answer either in the docs or in the source (admittedly, didn't read too much into latter)
Let's imagine a scenario. I have a Haskell project that I want to test against multiple GHC versions. I also have a beefy server I can use for that. So I create multiple containers for each GHC version I want to test against, and set up bake client in each of those. For the sake of simplicity, let's assume I run bake server on host itself.
Now, I don't want to have containers running 24/7, but only when there's a build to do (assume that those start almost instantaneously compared to build time, so almost no overhead there). So, the question is, is there a way to bring up client instances on demand? (e.g. by shelling out some IO commands from server)
It seems that after a day build output disappears. When I click on patch/state link in admin I got the odd message:
bake-store/state-2/extra-long.html: openFile: does not exist (No such file or directory)
When I try to go back in time and retrieve link, it does not work either.
ovenUpdate
phaseCurrently on merge the server takes the state variable, sends emails, does the merge, then updates the state. That can mean there are 5 minutes when the user can visit the web page and it shows the code is not merged, and yet they have an email saying it was merged. Generally, emails should lag the web page.
Solution is probably to replace the emailNotify function in oven with one that queues things up and sends them after. At the same time I can refactor to make emailNotify total and then not worry about error handling.
When I start bake from scratch pointing it a freshly cloned bare git repository, it fails in the preparing step with the following odd messages:
Running CI server...
% GIT: Begin gitCheckout
% GIT: Begin gitInitMirror
error: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack size changed
warning: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack cannot be accessed
error: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack size changed
warning: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack cannot be accessed
error: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack size changed
warning: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack cannot be accessed
error: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack size changed
warning: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack cannot be accessed
error: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack size changed
warning: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack cannot be accessed
error: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack size changed
warning: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack cannot be accessed
error: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack size changed
warning: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack cannot be accessed
error: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack size changed
warning: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack cannot be accessed
error: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack size changed
warning: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack cannot be accessed
error: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack size changed
warning: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack cannot be accessed
error: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack size changed
warning: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack cannot be accessed
error: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack size changed
warning: packfile ./objects/pack/pack-4e334e50d18177148e5b9004ede64a2fac19b63a.pack cannot be accessed
I managed to tweak the given Example.hs
to suite my own "test", which for the moment is limited to compiling the application. One thing I am struggling with is the topology of server/clients and repositiories to deploy bake. From various experiments, I inferred that:
addpatch
command, server will merge those patches to "master" (by default) when tests are successfulREPO
they manage, meaning this repo is never touched directly by tests' execution.Clients are just slaves that are used to execute tests as directed by server, possibly depending on some specific OS configuration as done in Example.hs
or some other parameters. Which means that a given patch gets submitted to only one client for checking its correctness.
Am I correct?
I got the following recurring error with bake:
Running CI
-- Client start ------------------------------------------------------
Client: client1
Id: 1
Test: Prepare
State: 2c0d93c48129252d146ad78b88ada05a1ebbd0d1
Patches:
----------------------------------------------------------------------
-- Client stop -------------------------------------------------------
Client: client1
Id: 1
Result: Success
Duration: 2.61s
----------------------------------------------------------------------
-- Client start ------------------------------------------------------
Client: client1
Id: 2
Test: Dependencies
State: 2c0d93c48129252d146ad78b88ada05a1ebbd0d1
Patches:
----------------------------------------------------------------------
-- Client stop -------------------------------------------------------
Client: client1
Id: 2
Result: Success
Duration: 3.15s
----------------------------------------------------------------------
-- Client start ------------------------------------------------------
Client: client1
Id: 3
Test: Compile
State: 2c0d93c48129252d146ad78b88ada05a1ebbd0d1
Patches:
----------------------------------------------------------------------
-- Client stop -------------------------------------------------------
Client: client1
Id: 3
Result: Success
Duration: 24m13s
----------------------------------------------------------------------
ci: Incorrect code: ((5,0,0),"Internal Server Error ","http://server:5000/api/finish")
"endOfInput"
Should be: Branch submitted by person at time rejected due to...
I think you need to toggle something in Warp to get more than "Something went wrong".
As seen on the Stackage build server:
[13 of 27] Compiling General.Web ( src/General/Web.hs, dist/build/General/Web.o )
src/General/Web.hs:76:21: error:
Variable not in scope: conduitManagerSettings :: ManagerSettings
|
76 | m <- newManager conduitManagerSettings
| ^^^^^^^^^^^^^^^^^^^^^^
I was able to reproduce this build failure locally like so:
stack unpack bake-0.5 && cd bake-0.5
edit stack.yaml # add the following stack.yaml
stack build
# stack.yaml
resolver: nightly-2018-03-10
extra-deps:
- http-conduit-2.3.0
In Development.Bake.Server.Web
the following line adds a quote in front of patch name when hitting Retry
:
do br_; admin (AddPatch (paAuthor pi) $ toPatch $ '\'' : fromPatch p) $ str_ "Retry"
I understand this ensures Brain
enqueues the patch:
update mem@Memory{..} (AddPatch author p) =
if storeIsPatch store p then
return $ Left "patch has already been submitted"
else do
let queued = storeAlive store `Set.difference` Set.fromList (snd active)
supersede = filter (\old -> ovenSupersede oven old p) $ Set.toList queued
store <- storeUpdate store $ IUQueue p author : map IUSupersede supersede
return $ Right mem{store = store}
But this supernumerary quote prevents proper merging later on in the chain, AFAICT. How about creating a RetryPatch
command that will follow roughly same semantic than AddPatch
except it will not check the store?
There are two key incremental features required:
ovenIncremental
to always rebuild by trying to find someone in a "similar" state and rebuild starting from them.ovenGit
should use a local bake-repo-hash
file to store a local copy of the repo so it always clones from there after doing an update. The assumption should be the repo might be a very long way away.Given the design I doubt there are many space leaks, but it doesn't help to confirm it.
http://neilmitchell.blogspot.co.uk/2015/09/detecting-space-leaks.html
I guess everything is in the question but let's elaborate a bit:
I had a look at Development/Bake/Server/
code, more particularly at Brain
module but I must confess the code is a bit opaque for me. I would be interested in contributing that feature but not sure how/where to start.
I managed to get my own ci instance from bake up and running, properly packed in docker containers orchestrated with fig. So far so good... But when I try to push a patch for integration, I got the following somewhat mysterious error:
Preparing by copying from bake-test-7510837679507534341
% GIT: Begin gitCheckout
% GIT: Begin gitInitMirror
% GIT: Finish gitInitMirror
HEAD is now at 917f8b0 [ETET][WIP] start application server inside ETE tests
Already on 'master'
fatal: d734a23fefe6b141db58edf6f7124c115bcdfce4 - not something we can merge
ci: user error (Development.Shake.cmd, system command failed
Command: git merge d734a23fefe6b141db58edf6f7124c115bcdfce4
Current directory: /bake-test-6583846214312572754
Exit code: 128
Stderr:
fatal: d734a23fefe6b141db58edf6f7124c115bcdfce4 - not something we can merge
)
Looking at the details of the patch integration, I got this error:
% GIT: Begin gitPatchExtra Just
% GIT: Begin gitInitMirror
% GIT: Finish gitInitMirror
fatal: Invalid symmetric difference expression 917f8b0701905815cc09ba9588c5e1b4a5aea8a6...d734a23fefe6b141db58edf6f7124c115bcdfce4
ci: user error (Development.Shake.cmd, system command failed
Command: git diff 917f8b0701905815cc09ba9588c5e1b4a5aea8a6...d734a23fefe6b141db58edf6f7124c115bcdfce4
Current directory: /bake-git-5401199084002705030/mirror
Exit code: 128
Stderr:
fatal: Invalid symmetric difference expression 917f8b0701905815cc09ba9588c5e1b4a5aea8a6...d734a23fefe6b141db58edf6f7124c115bcdfce4
)
Any idea what am I doing wrong?
In my example it is running at full CPU, which means it isn't having time to actually spawn off jobs and run them, which is pretty sad. Takes my test CPU from 100% to about 30%.
I would like to be able to pass the currently built patch to one of the test actions I am running as part of a triggered build. I am having a hard time trying to find the right place to extract that information from. It seems to me it should be readily available somewhere in the environment so that I can just extract it but not sure how to do that. Out of the top of my head I was thinking of pattern matching over the actual command run but this does seem the best way to do it.
Help greatly appreciated.
Hello,
I am really interested in starting using bake for our continuous integration and deployment process, given that:
What I would like to do is something reminiscent of gerrit's workflow:
Thanks for your feedback
As seen on the stackage build server, building bake-0.4
:
[ 4 of 26] Compiling General.Extra ( src/General/Extra.hs, dist/build/General/Extra.o )
src/General/Extra.hs:16:5: error:
Ambiguous occurrence ‘eitherToMaybe’
It could refer to either ‘Data.Either.Extra.eitherToMaybe’,
imported from ‘Data.Either.Extra’ at src/General/Extra.hs:45:1-24
or ‘General.Extra.eitherToMaybe’,
defined at src/General/Extra.hs:116:1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.