1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors arrays combinators db db.tuples furnace.actions
4 http.server.responses kernel mason.platform mason.notify.server
5 math.order sequences sorting splitting xml.syntax xml.writer
6 io.pathnames io.encodings.utf8 io.files ;
9 : log-file ( -- path ) home "mason.log" append-path ;
11 : recent-events ( -- xml )
12 log-file utf8 file-lines 10 short tail* "\n" join [XML <pre><-></pre> XML] ;
14 : git-link ( id -- link )
15 [ "http://github.com/slavapestov/factor/commit/" prepend ] keep
16 [XML <a href=<->><-></a> XML] ;
18 : building ( builder string -- xml )
19 swap current-git-id>> git-link
20 [XML <-> for <-> XML] ;
22 : current-status ( builder -- xml )
24 { "dirty" [ drop "Dirty" ] }
25 { "clean" [ drop "Clean" ] }
26 { "starting" [ "Starting" building ] }
27 { "make-vm" [ "Compiling VM" building ] }
28 { "boot" [ "Bootstrapping" building ] }
29 { "test" [ "Testing" building ] }
33 : binaries-link ( builder -- link )
34 [ os>> ] [ cpu>> ] bi (platform) "http://downloads.factorcode.org/" prepend
35 dup [XML <a href=<->><-></a> XML] ;
37 : clean-image-link ( builder -- link )
38 [ os>> ] [ cpu>> ] bi (platform) "http://factorcode.org/images/clean/" prepend
39 dup [XML <a href=<->><-></a> XML] ;
41 : machine-table ( builder -- xml )
45 [ host-name>> "." split1 drop ]
47 [ last-git-id>> dup [ git-link ] when ]
48 [ clean-git-id>> dup [ git-link ] when ]
55 <tr><td>Host name:</td><td><-></td></tr>
56 <tr><td>Current status:</td><td><-></td></tr>
57 <tr><td>Last build:</td><td><-></td></tr>
58 <tr><td>Last clean build:</td><td><-></td></tr>
59 <tr><td>Binaries:</td><td><-></td></tr>
60 <tr><td>Clean images:</td><td><-></td></tr>
64 : machine-report ( -- xml )
65 builder new select-tuples
66 [ [ [ os>> ] [ cpu>> ] bi 2array ] compare ] sort
67 [ machine-table ] map ;
69 : build-farm-report ( -- xml )
74 <head><title>Factor build farm</title></head>
75 <body><h1>Recent events</h1><-> <h1>Machine status</h1><-></body>
79 : <build-farm-report-action> ( -- action )
82 mason-db [ build-farm-report xml>string ] with-db