1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2026-10-18 09:04:42 +00:00

31 Commits
0.9 ... 1.0

Author SHA1 Message Date
Oliver Giles
1a5292f141 remove old trigger command
it has been deprecated for a while now
2020-12-05 13:55:11 +13:00
Oliver Giles
ec237f475e deprecate custom css
replaced by custom index html page
2020-12-05 13:54:35 +13:00
Oliver Giles
5e64844440 frontend: "builds" -> "runs"
use consistent naming
2020-12-05 13:52:40 +13:00
Oliver Giles
c274e321df fetch average runtime as double, not int
only makes a difference for very short jobs, but nice
to have more accurate graphs
2020-12-05 13:51:25 +13:00
Oliver Giles
e442652e0a rpm packaging: list man pages 2020-12-05 13:49:13 +13:00
Oliver Giles
212cfaf8ab UserManual: laminard env vars with docker
explain how laminard uses environment variables and
recommend how to set them when using docker

resolves #136
2020-12-05 13:24:12 +13:00
Oliver Giles
b755a2ef9e edit manpages and cmakeize them
so that they will be installed in the correct place as part of
a normal build or packaging process.
2020-11-27 21:25:48 +13:00
Dmitry Bogatov
cafd0ddaee Write and install manpage for laminarc 2020-11-25 13:36:34 +13:00
Dmitry Bogatov
69df17d7bf Write and install manpage for laminard 2020-11-25 13:35:25 +13:00
Oliver Giles
308d679ea4 update vue and vue-router
to 2.6.12 and 3.4.8 respectively, as they are the versions available
in Debian. fix an exposed issue where the status handler attempted
to manipulate the DOM before vue had rendered it - such manipulations
need to be deferred with $nextTick().
2020-11-20 14:34:26 +13:00
Oliver Giles
b851c72d53 progress bar: fix initial delayed update
when the displayed frontend state changes, any progress bar
should begin in the initial correct state before smoothly
transitioning with time.
2020-11-20 14:08:02 +13:00
Oliver Giles
3e993d35a0 no badges for unfinished runs
do not attempt to generate badges for runs which have not
yet finished.

resolves #134
2020-11-13 14:02:00 +13:00
Oliver Giles
579c192d89 builds per day: fix dynamic update to wrong result
the wrong dataset was updated, causing the graph to increase
the number of failed builds when a build succeeded and vice-versa.
2020-11-13 14:00:59 +13:00
Oliver Giles
4fb95fcb4f allow contexts to specify accepted jobs
using a glob expression, the same way jobs can specify
contexts. This allows more flexibility in situations where
there are many jobs sharing limited contexts because it
may obviate the need to create a conf file for each job.

resolves #124
2020-11-13 13:47:02 +13:00
Oliver Giles
bd489bdbb0 frontend refactor
use a more modern style, reduce variable scopes where possible,
fix several minor bugs such as pagination and scales in chart
tooltips
2020-10-16 21:19:12 +13:00
Oliver Giles
c6b60646f6 rewrite gtest result formatting example 2020-10-09 20:17:33 +13:00
Oliver Giles
1ea9713536 implement wallboard view
resolves #51
2020-10-09 13:06:03 +13:00
Oliver Giles
746ab24676 move buildTimeDist chart to examples
too esoteric for the front page, converting it to an example
of querying laminar db directly and using gnuplot should provide
more value to those needing deeper insights into job behaviour.
2020-09-26 15:12:02 +12:00
Oliver Giles
9862affd98 fix warnings under clang++ 2020-09-26 11:33:36 +12:00
Oliver Giles
9974df21ce add example telegram notification 2020-09-26 09:03:21 +12:00
Oliver Giles
c774acbb98 add example email notification scripts 2020-09-26 08:53:17 +12:00
Oliver Giles
06a5f3d8ef assign run numbers at queue time
This allows build chains to be traced in the common case where
an upstream job calls `laminarc queue' instead of `laminarc start'.
Incomplete job runs now have database entries, which requires
some adjustments in queries. Queued jobs can now be viewed in
the frontend and there is a corresponding status icon.
2020-09-25 15:29:30 +12:00
Oliver Giles
6d2c0b208b fix LAST_RESULT env var
the variable was set too late to be passed to the forked
process.

resolves #131
2020-09-20 09:15:03 +12:00
Oliver Giles
4b62e6dbf3 fix colours of per-job build time graph 2020-09-19 15:22:01 +12:00
Oliver Giles
dc3e41fb28 prettier graphs 2020-09-04 13:21:29 +12:00
Oliver Giles
e74332595e build time graph: simplify success/failed color logic 2020-09-04 13:15:30 +12:00
Oliver Giles
a793a97424 fix time scales in graphs
these were not correct at all
2020-09-04 13:12:52 +12:00
Oliver Giles
4e9c4bfb04 run page: switch progress bar and nav buttons
the navigation buttons are more usable next to other
navigation elements. This is especially noticeable on
large monitors.
2020-09-04 13:10:09 +12:00
Oliver Giles
e29568f627 improve layout on large screens 2020-09-04 13:08:34 +12:00
Oliver Giles
4316eb8a00 sse endpoint: hint to reverse-proxy not to buffer
Similarly to 210787a3, and as discussed in #88 and #130, nginx
will buffer chunked transfer-encoding unless proxy_buffering
is turned off or the X-Accel-Buffering header is set to no.

resolves #130
2020-08-11 06:54:03 +12:00
Oliver Giles
8a4992e6af more aggressive, recursive kill on abort
some jobs may spawn child processes which change their process group
or session id, making the existing abort behavior of HUP-then-KILL to
the process group ineffective. Instead, if HUP to the process group
fails, recursively walk /proc and KILL anything with a ppid corresponding
to the leader process. This should keep working because the leader
process is a subreaper.

resolves #129
2020-08-08 12:03:55 +12:00
32 changed files with 1148 additions and 716 deletions

View File

@@ -83,10 +83,10 @@ add_custom_command(OUTPUT index_html_size.h
DEPENDS src/resources/index.html)
# Download 3rd-party frontend JS libs...
file(DOWNLOAD https://cdnjs.cloudflare.com/ajax/libs/vue/2.3.4/vue.min.js
js/vue.min.js EXPECTED_MD5 ae2fca1cfa0e31377819b1b0ffef704c)
file(DOWNLOAD https://cdnjs.cloudflare.com/ajax/libs/vue-router/2.7.0/vue-router.min.js
js/vue-router.min.js EXPECTED_MD5 5d3e35710dbe02de78c39e3e439b8d4e)
file(DOWNLOAD https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.12/vue.min.js
js/vue.min.js EXPECTED_MD5 fb192338844efe86ec759a40152fcb8e)
file(DOWNLOAD https://cdnjs.cloudflare.com/ajax/libs/vue-router/3.4.8/vue-router.min.js
js/vue-router.min.js EXPECTED_MD5 5f51d4dbbf68fd6725956a5a2b865f3b)
file(DOWNLOAD https://raw.githubusercontent.com/drudru/ansi_up/v1.3.0/ansi_up.js
js/ansi_up.js EXPECTED_MD5 158566dc1ff8f2804de972f7e841e2f6)
file(DOWNLOAD https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js
@@ -119,6 +119,19 @@ target_link_libraries(laminard capnp-rpc capnp kj-http kj-async kj pthread sqlit
add_executable(laminarc src/client.cpp src/version.cpp laminar.capnp.c++)
target_link_libraries(laminarc capnp-rpc capnp kj-async kj pthread)
## Manpages
macro(gzip SOURCE)
get_filename_component(OUT_FILE ${SOURCE} NAME)
add_custom_command(OUTPUT ${OUT_FILE}.gz
COMMAND gzip < ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE} > ${OUT_FILE}.gz
DEPENDS ${SOURCE})
endmacro()
add_custom_target(laminar-manpages ALL DEPENDS laminard.8.gz laminarc.1.gz)
gzip(etc/laminard.8)
gzip(etc/laminarc.1)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/laminard.8.gz DESTINATION share/man/man8)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/laminarc.1.gz DESTINATION share/man/man1)
## Tests
set(BUILD_TESTS FALSE CACHE BOOL "Build tests")
if(BUILD_TESTS)

View File

@@ -52,15 +52,17 @@ You can build an image that runs `laminard` by default, and contains `laminarc`
docker build [-t image:tag] -f docker/Dockerfile .
```
Keep in mind that this is meant to be used as a base image to build from, so it contains only the minimum packages required to run laminar. The only shell available by default is sh and it does not even have ssh or git. You can use this image to run a basic build server, but it is recommended that you build a custom image from this base to better suit your needs.
Keep in mind that this is meant to be used as a base image to build from, so it contains only the minimum packages required to run laminar. The only shell available by default is sh (so scripts with `#!/bin/bash` will fail to execute) and it does not have `ssh` or `git`. You can use this image to run a basic build server, but it is recommended that you build a custom image from this base to better suit your needs.
The container will execute `laminard` by default. To start a laminar server with docker you can simply run the image as a daemon.
The container will execute `laminard` by default. To start a laminar server with docker you can simply run the image as a daemon, for example:
```bash
docker run -d --name laminar_server -p 8080:8080 [-v laminardir|laminar.conf] laminar:latest
docker run -d --name laminar_server -p 8080:8080 -v path/to/laminardir:/var/lib/laminar --env-file path/to/laminar.conf laminar:latest
```
You can customize laminar and persist your data by mounting your laminar directory to `/var/lib/laminar` and/or mounting a custom configuration file to `/etc/laminar.conf`.
The [`-v` flag](https://docs.docker.com/storage/volumes/#choose-the--v-or---mount-flag) is necessary to persist job scripts and artefacts beyond the container lifetime.
The [`--env-file` flag](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file) is necessary to pass configuration from `laminar.conf` to `laminard` because `laminard` does not read `/etc/laminar.conf` directly but expects variables within to be exported by `systemd` or other process supervisor.
Executing `laminarc` may be done in any of the usual ways, for example:
@@ -127,30 +129,30 @@ chmod +x /var/lib/laminar/cfg/jobs/hello.run
# Triggering a run
When triggering a run, the job is first added to a queue of upcoming tasks. If the server is busy, the job may wait in this queue for a while. It will only be assigned a job number when it leaves this queue and starts executing. The job number may be useful to the client that triggers the run, so there are a few ways to trigger a run.
To add the `hello` job to the queue ("fire-and-forget"), execute
To queue execution of the `hello` job, run
```bash
laminarc queue hello
```
In this case, laminarc returns immediately, with its error code indicating whether adding the job to the queue was sucessful.
In this case, `laminarc` returns immediately, with its error code indicating whether adding the job to the queue was sucessful. The run number will be printed to standard output.
To queue the job and wait until it leaves the queue and starts executing, use
If the server is busy, a run may wait in the queue for some time. To have `laminarc` instead block until the run leaves the queue and starts executing, use
```bash
laminarc start hello
```
In this case, laminarc blocks until the job starts executing, or returns immediately if queueing failed. The run number will be printed to standard output.
In this case, `laminarc` blocks until the job starts executing, or returns immediately if queueing failed. The run number will be printed to standard output.
To launch and run the `hello` job to completion, execute
Finally, to launch and run the `hello` job to completion, execute
```bash
laminarc run hello
```
In this case, laminarc's return value indicates whether the run completed successfully.
In all cases, a started run means the `/var/lib/laminar/cfg/jobs/hello.run` script will be executed, with a working directory of `/var/lib/laminar/run/hello/1` (or current run number)
The result and log output should be visible in the Web UI at http://localhost:8080/jobs/hello/1
@@ -373,6 +375,8 @@ author_email=$(git show -s --format='%ae' $rev)
laminarc set RECIPIENTS $author_email
```
See [notify-email-pretty.sh](https://github.com/ohwgiles/laminar/blob/master/examples/notify-email-pretty.sh) and [notify-email-text-log.sh](https://github.com/ohwgiles/laminar/blob/master/examples/notify-email-text-log.sh).
---
# Helper scripts
@@ -502,13 +506,23 @@ EXECUTORS=1
## Associating a job with a context
When trying to start a job, laminar will wait until the job can be matched to a context which has at least one free executor. You can define which contexts the job will associate with by setting, for example,
When trying to start a job, laminar will wait until the job can be matched to a context which has at least one free executor. There are two ways to associate jobs and contexts. You can specify a comma-separated list of patterns `JOBS` in the context configuration file `/var/lib/laminar/cfg/contexts/CONTEXT.conf`:
```
JOBS=amd64-target-*,usage-monitor
```
This approach is often preferred when you have many jobs that need to share limited resources.
Alternatively, you can set
```
CONTEXTS=my-env-*,special_context
```
in `/var/lib/laminar/cfg/jobs/JOB.conf`. For each of the patterns in the comma-separated list `CONTEXTS`, Laminar will iterate over the known contexts and associate the run with the first context with free executors. Patterns are [glob expressions](http://man7.org/linux/man-pages/man7/glob.7.html).
in `/var/lib/laminar/cfg/jobs/JOB.conf`. This approach is often preferred when you have a small number of jobs that require exclusive access to an environment and you can supply alternative environments (e.g. target devices), because new contexts can be added without modifying the job configuration.
In both cases, Laminar will iterate over the known contexts and associate the run with the first matching context with free executors. Patterns are [glob expressions](http://man7.org/linux/man-pages/man7/glob.7.html).
If `CONTEXTS` is empty or absent (or if `JOB.conf` doesn't exist), laminar will behave as if `CONTEXTS=default` were defined.

71
etc/laminarc.1 Normal file
View File

@@ -0,0 +1,71 @@
.Dd Apr 04, 2019
.Dt LAMINARC 1
.Sh NAME
.Nm laminarc
\-
Laminar CI client application
.Sh SYNOPSIS
.Nm laminarc Li queue \fIJOB\fR [\fIPARAM=VALUE...\fR] ...
.Nm laminarc Li queue \fIJOB\fR [\fIPARAM=VALUE...\fR] ...
.Nm laminarc Li queue \fIJOB\fR [\fIPARAM=VALUE...\fR] ...
.Nm laminarc Li set \fIPARAM=VALUE...\fR
.Nm laminarc Li show-jobs
.Nm laminarc Li show-running
.Nm laminarc Li show-queued
.Nm laminarc Li abort \fIJOB\fR \fINUMBER\fR
.Sh DESCRIPTION
The
.Nm laminarc
program connects to a Laminar server and perform one of following operations:
.Bl -tag
.It Sy queue
adds job(s) (with optional parameters) to the queue and returns immediately.
.It Sy start
adds job(s) (with optional parameters) to the queue and returns when the jobs
begin execution.
.It Sy run
adds job(s) (with optional parameters) to the queue and returns when the jobs
complete execution. The exit code will be non-zero if any of the runs does
not complete successfully.
.It Sy set
sets one or more parameters to be exported as environment variables in subsequent
scripts for the run identified by the $JOB and $RUN environment variables.
This is primarily intended for use from within a job execution, where those
variables are already set by the server.
.It Sy show-jobs
list jobs known to the server.
.It Sy show-running
list the currently running jobs with their numbers.
.It Sy show-queued
list the names and numbers of the jobs waiting in the queue.
.It Sy abort
manually abort a currently running job by name and number.
.El
.Pp
The laminar server to connect to is read from the
.Ev LAMINAR_HOST
environment variable. If empty, it falls back to
.Ev LAMINAR_BIND_RPC
and finally defaults to
.Ad
unix-abstract:laminar.
.Sh ENVIRONMENT
.Bl -tag
.It Ev LAMINAR_HOST
address of server to connect. May be of the form
.Ad IP:PORT,
.Ad unix:PATH/TO/SOCKET or
.Ad unix-abstract:NAME
.It Ev LAMINAR_BIND_RPC
fallback server address variable. It is set by
.Nm laminard
during execution of scripts.
.El
.Sh SEE ALSO
.Xr laminard 8
.Sh AUTHORS
.An Oliver Giles
created Laminar CI.
.An Dmitry Bogatov
created this manual page for the Debian project (but it can be used
by others).

56
etc/laminard.8 Normal file
View File

@@ -0,0 +1,56 @@
.Dd Apr 03, 2019
.Dt LAMINARD 1
.Sh NAME
.Nm laminard
\-
Laminar CI server
.Sh SYNOPSIS
.Nm laminard Op Fl v
.Sh DESCRIPTION
Start Laminar CI server in the foreground. If option
.Fl v
is specified, verbose logging is enabled. Other aspects of
operation are controlled by environment variables.
.Sh ENVIRONMENT
.Bl -tag
.It Ev LAMINAR_HOME
Root location containing laminar configuration, database, build
workspaces and archive.
.Pp
Default: /var/lib/laminar
.It Ev LAMINAR_BIND_HTTP
Interface on which laminard will bind to serve the Web UI.
May be of the form IP:PORT, unix:PATH/TO/SOCKET or unix-abstract:NAME
.Pp
Default: *:8080
.It Ev LAMINAR_BIND_HRPC
Interface on which laminard will bind to accept RPC from laminarc.
May be of the form IP:PORT, unix:PATH/TO/SOCKET or unix-abstract:NAME
.Pp
Default: unix-abstract:laminar
.It Ev LAMINAR_TITLE
Page title to show in web frontend
.It Ev LAMINAR_KEEP_RUNDIRS
Setting this prevents the immediate deletion of job rundirs
$LAMINAR_HOME/run/$JOB/$RUN. Value should be an integer represeting
the number of rundirs to keep.
.Pp
Default: 0
.It Ev LAMINAR_ARCHIVE_URL
Base url used to request artifacts. Laminar can serve build artifacts
(and it will if you leave this unset), but it uses a very naive and
inefficient method. Best to let a real webserver handle serving those
requests.
.El
.Sh FILES
.Bl -tag
.It Pa /etc/laminar.conf
Variable assignments in this file are exported by systemd or other
init system before launching the system-wide installation of Laminar.
.El
.Sh AUTHORS
.An Oliver Giles
created Laminar CI.
.An Dmitry Bogatov
created this manual page for Debian project (but it can be used
by others).

View File

@@ -1,21 +0,0 @@
#!/bin/bash
cat <<EOF
<!doctype html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laminar</title>
<link href="/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="col-xs-12">
<h2>Test report for $lJobName #$lBuildNum</h2>
EOF
xsltproc "$(dirname ${BASH_SOURCE[0]})/testreport.xsl" "$1";
cat <<EOF
</div>
</body>
</html>
EOF

View File

@@ -1,42 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="no"/>
<xsl:template match="testsuite">
<h3>Test Suite: <xsl:value-of select="@name" /></h3>
<dl class="dl-horizontal">
<dt>Tests run:</dt><dd><xsl:value-of select="@tests" /></dd>
<dt>Failures:</dt><dd><xsl:value-of select="@failures" /></dd>
<dt>Errors:</dt><dd><xsl:value-of select="@errors" /></dd>
<dt>Elapsed time:</dt><dd><xsl:value-of select="@time" /></dd>
</dl>
<ul class="list-group">
<xsl:apply-templates select="testcase" />
</ul>
<xsl:apply-templates select="system-out" />
<xsl:apply-templates select="system-err" />
</xsl:template>
<xsl:template match="testcase">
<xsl:choose>
<xsl:when test="*">
<li class="list-group-item list-group-item-danger"><xsl:value-of select="@name" />
<xsl:apply-templates select="failure" />
</li>
</xsl:when>
<xsl:otherwise>
<li class="list-group-item list-group-item-success"><xsl:value-of select="@name" /></li>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="failure">
<pre>
<xsl:value-of select="@message"/>
</pre>
</xsl:template>
<xsl:template match="system-out"><h5>Standard output:</h5><pre><xsl:value-of select="." /></pre></xsl:template>
<xsl:template match="system-err"><h5>Standard error:</h5><pre><xsl:value-of select="." /></pre></xsl:template>
</xsl:stylesheet>

117
examples/format-test-results Executable file
View File

@@ -0,0 +1,117 @@
#!/bin/bash
# This example script takes the XML output of a gtest run and formats
# it as HTML. It can easily be adapted to other XML test output formats
# such as JUnit or CTest
# Prepare xml with ./path/to/test --gtest_output=xml:path/to/output.xml
# Usage: format-test-results test_result.xml > output.html
if [ ! -f "$1" ]; then
echo "File not found: \"$1\""
exit 1
fi
xsltproc --stringparam JOB $JOB --stringparam RUN $RUN <(cat <<\EOF
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" />
<xsl:template match="/">
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Test report for <xsl:value-of select="$JOB" /> #<xsl:value-of select="$RUN" /></title>
<style>
body { font-family: Helvetica Neue, Helvetica, Arial, sans-serif; }
label:hover { cursor: pointer; }
label:before { content: '+ ' }
input[type=checkbox].toggle-collapse { display: none; }
input[type=checkbox].toggle-collapse~.collapsible { display: none; }
input[type=checkbox].toggle-collapse:checked~.collapsible { display: block; }
code { white-space: pre-wrap; color: white; }
.failure { background-color: #c73030; color: white; }
table { min-width: 720px; border-collapse: collapse; }
td, th { padding: 5px; }
tr:nth-child(even) td { padding: 0; }
tr:nth-child(even) { border-bottom: 1px solid #b3abab; }
.testcase { padding: 5px; }
.testcase.success:before { content: '✔ '; color: green; }
</style>
</head>
<body>
<h1><xsl:value-of select="$JOB" /> #<xsl:value-of select="$RUN" /></h1>
<h2>Test Report</h2>
<table>
<thead>
<tr>
<th>Suite</th>
<th>Tests run</th>
<th>Failures</th>
<th>Errors</th>
<th>Elapsed time</th>
</tr>
</thead>
<xsl:apply-templates select="testsuites" />
</table>
</body>
</html>
</xsl:template>
<xsl:template match="testsuite">
<xsl:variable name="result">
<xsl:choose>
<xsl:when test="(@failures &gt; 0) or (@errors &gt; 0)">failure</xsl:when>
<xsl:otherwise>success</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<tr class="{$result}">
<td>
<label for="suite-{@name}"><xsl:value-of select="@name" /></label>
</td>
<td><xsl:value-of select="@tests" /></td>
<td><xsl:value-of select="@failures" /></td>
<td><xsl:value-of select="@errors" /></td>
<td><xsl:value-of select="@time" /></td>
</tr>
<tr class="toggle-target">
<td colspan="5">
<input class="toggle-collapse" id="suite-{@name}" type="checkbox" />
<div class="collapsible" style="padding-left: 15px;">
<xsl:apply-templates select="testcase" />
</div>
</td>
</tr>
</xsl:template>
<xsl:template match="testcase">
<xsl:choose>
<!-- has child nodes? -->
<xsl:when test="*">
<div class="testcase failure">
<xsl:value-of select="@name" /><br />
<xsl:apply-templates select="failure" />
</div>
</xsl:when>
<xsl:otherwise>
<div class="testcase success">
<xsl:value-of select="@name" />
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="failure">
<div style="padding: 5px; background-color: #313235">
<code>
<xsl:value-of select="@message"/>
</code>
</div>
</xsl:template>
</xsl:stylesheet>
EOF
) "$1"

55
examples/notify-email-pretty.sh Executable file
View File

@@ -0,0 +1,55 @@
#!/bin/bash -e
# IMPORTANT: change these to appropriate values, or fetch them, for example
# from the environment or from $(git show -s --format='%ae' $rev)
TO_EMAIL=engineering@example.com
FROM_EMAIL=laminar@example.com
LAMINAR_URL=${LAMINAR_BASE_URL:-http://localhost:8080}
LAMINAR_TITLE=${LAMINAR_TITLE:-Laminar CI}
if [[ $RESULT = "success" ]]; then
SVGICON=$(cat <<-EOF
<svg viewBox="0 0 100 100" width="24px">
<path fill="#74af77" d="m 23,46 c -6,0 -17,3 -17,11 0,8 9,30 12,32 3,2 14,5 20,-2 6,-6 24,-36
56,-71 5,-3 -9,-8 -23,-2 -13,6 -33,42 -41,47 -6,-3 -5,-12 -8,-15 z" />
</svg>
EOF
)
else
SVGICON=$(cat <<-EOF
<svg viewBox="0 0 100 100" width="24px">
<path fill="#883d3d" d="m 19,20 c 2,8 12,29 15,32 -5,5 -18,21 -21,26 2,3 8,15 11,18 4,-6 17,-21
21,-26 5,5 11,15 15,20 8,-2 15,-9 20,-15 -3,-3 -17,-18 -20,-24 3,-5 23,-26 30,-33 -3,-5 -8,-9
-12,-12 -6,5 -26,26 -29,30 -6,-8 -11,-15 -15,-23 -3,0 -12,5 -15,7 z" />
</svg>
EOF
)
fi
sendmail -t <<EOF
From: $FROM_EMAIL
To: $TO_EMAIL
Subject: $JOB #$RUN: $RESULT
Mime-Version: 1.0
Content-Type: text/html; charset=utf-8
<html lang="en">
<body bgcolor="#efefef" style="margin: 0; font-family: Helvetica Neue, Helvetica, Arial, sans-serif">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td align="center">
<table border="0" cellspacing="0" cellpadding="15" bgcolor="#ffffff">
<tr bgcolor="#2f3340">
<td style="font-size: 28px; color: #ffffff;">$LAMINAR_TITLE</td></tr>
<tr>
<td style="font-size: 26px">
$SVGICON
<a href="$LAMINAR_URL/jobs/$JOB/$RUN">$JOB #$RUN</a>
</td>
</tr>
</table>
</td></tr>
</table>
</body>
</html>
EOF

View File

@@ -0,0 +1,18 @@
#!/bin/bash -e
# IMPORTANT: change these to appropriate values, or fetch them, for example
# from the environment or from $(git show -s --format='%ae' $rev)
TO_EMAIL=engineering@example.com
FROM_EMAIL=laminar@example.com
LAMINAR_URL=${LAMINAR_BASE_URL:-http://localhost:8080}
sendmail -t <<EOF
From: $FROM_EMAIL
To: $TO_EMAIL
Subject: $JOB #$RUN: $RESULT
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
$(curl -s $LAMINAR_URL/log/$JOB/$RUN)
EOF

18
examples/notify-telegram.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash -e
# Sends a message from a specified bot to a specific telegram chat ID.
# See https://core.telegram.org/bots
# IMPORTANT: modify this to your real bot token and chat ID
BOT_TOKEN=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
CHAT_ID=10000000
LAMINAR_URL=${LAMINAR_BASE_URL:-http://localhost:8080}
[[ $(curl -sS https://api.telegram.org/bot$BOT_TOKEN/sendMessage \
-d chat_id=$CHAT_ID \
-d parse_mode=HTML \
-d text="<a href=\"$LAMINAR_URL/jobs/$JOB/$RUN\">$JOB #$RUN</a> $RESULT" \
| jq .ok) == true ]]

46
examples/plot-build-time-dist Executable file
View File

@@ -0,0 +1,46 @@
#!/usr/bin/env gnuplot
# Deeper insights can be obtained by querying Laminar's database directly.
# This example uses gnuplot to create a graph of the distribution of the
# average run time of jobs.
# The following will output a png...
set terminal pngcairo size 800,580 enhanced font 'Helvetica,10'
set output 'build-time-distribution.png'
# ..comment it out to use an interactive widget
# plot style
set tics font "Helvetica,10"
set title font "Helvetica,11"
set xtics nomirror
set ytics nomirror
set border 3 back lt 1 lc rgb "#808080"
set grid back lt 0 lc rgb "#d0d0d0" lw 0.5
set style line 1 lt 1 lc rgb "#7483af" lw 2
# Fetch the path to Laminar's sqlite database
db = system("echo $LAMINAR_HOME") . '/laminar.sqlite'
# Label the axes
set xtics ("<30s" 0, "30s-1m" 1, "1m-5m" 2, "5m-10m" 3, "10m-20m" 4, "20m-40m" 5, "40m-60m" 6, ">60m" 7)
set ylabel "Number of jobs"
set xlabel "Average run time"
set title "Distribution of average run times"
plot '< sqlite3 -separator $''\n'' ' . db . ' \
"WITH ba AS (SELECT name,AVG(completedAt-startedAt) a FROM builds GROUP BY name) SELECT \
COUNT(CASE WHEN a < 30 THEN 1 END), \
COUNT(CASE WHEN a >= 30 AND a < 60 THEN 1 END), \
COUNT(CASE WHEN a >= 60 AND a < 300 THEN 1 END), \
COUNT(CASE WHEN a >= 300 AND a < 600 THEN 1 END), \
COUNT(CASE WHEN a >= 600 AND a < 1200 THEN 1 END), \
COUNT(CASE WHEN a >= 1200 AND a < 2400 THEN 1 END), \
COUNT(CASE WHEN a >= 2400 AND a < 3600 THEN 1 END), \
COUNT(CASE WHEN a >= 3600 THEN 1 END) FROM ba;"' \
using 0:1 with linespoints title '' ls 1
# uncomment this if using an interactive window
#pause mouse close
# Release the output
set output

View File

@@ -68,6 +68,8 @@ make
%config(noreplace) %{_sysconfdir}/laminar.conf
%{_datarootdir}/bash-completion/completions/laminarc
%{_datarootdir}/zsh/site-functions/_laminarc
%{_mandir}/man8/laminard.8.gz
%{_mandir}/man1/laminarc.1.gz
%post
echo Creating laminar user with home in %{_sharedstatedir}/laminar

View File

@@ -65,6 +65,8 @@ make
%config(noreplace) %{_sysconfdir}/laminar.conf
%{_datarootdir}/bash-completion/completions/laminarc
%{_datarootdir}/zsh/site-functions/_laminarc
%{_mandir}/man8/laminard.8.gz
%{_mandir}/man1/laminarc.1.gz
%post
echo Creating laminar user with home in %{_sharedstatedir}/laminar

View File

@@ -147,13 +147,12 @@ int main(int argc, char** argv) {
if(resp.getResult() != LaminarCi::MethodResult::SUCCESS) {
fprintf(stderr, "Failed to queue job '%s'\n", argv[jobNameIndex]);
ret = EXIT_OPERATION_FAILED;
}
} else
printTriggerLink(argv[jobNameIndex], resp.getBuildNum());
}));
jobNameIndex += n + 1;
} while(jobNameIndex < argc);
} else if(strcmp(argv[1], "start") == 0 || strcmp(argv[1], "trigger") == 0) {
if(strcmp(argv[1], "trigger") == 0)
fprintf(stderr, "Warning: 'trigger' is deprecated, use 'queue' for the old behavior\n");
} else if(strcmp(argv[1], "start") == 0) {
if(argc < 3) {
fprintf(stderr, "Usage %s queue <jobName>\n", argv[0]);
return EXIT_BAD_ARGUMENT;

View File

@@ -1,5 +1,5 @@
///
/// Copyright 2015-2019 Oliver Giles
/// Copyright 2015-2020 Oliver Giles
///
/// This file is part of Laminar
///
@@ -19,16 +19,10 @@
#ifndef LAMINAR_CONTEXT_H_
#define LAMINAR_CONTEXT_H_
#include <fnmatch.h>
#include <string>
#include <set>
class Run;
// FNM_EXTMATCH isn't supported under musl
#if !defined(FNM_EXTMATCH)
#define FNM_EXTMATCH 0
#endif
// Represents a context within which a Run will be executed. Allows applying
// a certain environment to a set of Jobs, or setting a limit on the number
// of parallel Runs
@@ -39,17 +33,7 @@ public:
std::string name;
int numExecutors;
int busyExecutors = 0;
bool canQueue(std::set<std::string>& patterns) {
if(busyExecutors >= numExecutors)
return false;
for(std::string pattern : patterns) {
if(fnmatch(pattern.c_str(), name.c_str(), FNM_EXTMATCH) == 0)
return true;
}
return false;
}
std::set<std::string> jobPatterns;
};

View File

@@ -78,14 +78,14 @@ kj::Maybe<MonitorScope> fromUrl(std::string resource, char* query) {
return kj::mv(scope);
}
if(resource.substr(0, 5) != "/jobs")
return nullptr;
if(resource.length() == 5) {
if(resource == "/jobs" || resource == "/wallboard") {
scope.type = MonitorScope::ALL;
return kj::mv(scope);
}
if(resource.substr(0, 5) != "/jobs")
return nullptr;
resource = resource.substr(5);
size_t split = resource.find('/',1);
std::string job = resource.substr(1,split-1);
@@ -203,6 +203,8 @@ kj::Promise<void> Http::request(kj::HttpMethod method, kj::StringPtr url, const
if(is_sse) {
KJ_IF_MAYBE(s, fromUrl(url.cStr(), queryString)) {
responseHeaders.set(kj::HttpHeaderId::CONTENT_TYPE, "text/event-stream");
// Disables nginx reverse-proxy's buffering. Necessary for streamed events.
responseHeaders.add("X-Accel-Buffering", "no");
auto peer = kj::heap<WithSetRef<EventPeer>>(eventPeers);
peer->scope = *s;
std::string st = "data: " + laminar.getStatus(peer->scope) + "\n\n";
@@ -236,12 +238,6 @@ kj::Promise<void> Http::request(kj::HttpMethod method, kj::StringPtr url, const
return writeLogChunk(c, s);
}).attach(kj::mv(output)).attach(kj::mv(stream)).attach(kj::mv(lw));
}
} else if(url == "/custom/style.css") {
responseHeaders.set(kj::HttpHeaderId::CONTENT_TYPE, "text/css; charset=utf-8");
responseHeaders.add("Content-Transfer-Encoding", "binary");
std::string css = laminar.getCustomCss();
auto stream = response.send(200, "OK", responseHeaders, css.size());
return stream->write(css.data(), css.size()).attach(kj::mv(css)).attach(kj::mv(stream));
} else if(resources->handleRequest(url.cStr(), &start, &end, &content_type)) {
responseHeaders.set(kj::HttpHeaderId::CONTENT_TYPE, content_type);
responseHeaders.add("Content-Encoding", "gzip");

View File

@@ -1,5 +1,5 @@
///
/// Copyright 2019 Oliver Giles
/// Copyright 2019-2020 Oliver Giles
///
/// This file is part of Laminar
///
@@ -28,8 +28,8 @@
typedef unsigned int uint;
typedef unsigned long ulong;
struct Laminar;
struct Resources;
class Laminar;
class Resources;
struct LogWatcher;
struct EventPeer;

View File

@@ -2,7 +2,7 @@
interface LaminarCi {
queue @0 (jobName :Text, params :List(JobParam)) -> (result :MethodResult);
queue @0 (jobName :Text, params :List(JobParam)) -> (result :MethodResult, buildNum :UInt32);
start @1 (jobName :Text, params :List(JobParam)) -> (result :MethodResult, buildNum :UInt32);
run @2 (jobName :Text, params :List(JobParam)) -> (result :JobResult, buildNum :UInt32);
listQueued @3 () -> (result :List(Text));

View File

@@ -28,6 +28,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <fnmatch.h>
#include <fstream>
#include <zlib.h>
@@ -36,6 +37,11 @@
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>
// FNM_EXTMATCH isn't supported under musl
#if !defined(FNM_EXTMATCH)
#define FNM_EXTMATCH 0
#endif
// rapidjson::Writer with a StringBuffer is used a lot in Laminar for
// preparing JSON messages to send to HTTP clients. A small wrapper
// class here reduces verbosity later for this common use case.
@@ -67,7 +73,6 @@ inline kj::Path operator/(const std::string& p, const T& ext) {
typedef std::string str;
Laminar::Laminar(Server &server, Settings settings) :
settings(settings),
srv(server),
homePath(kj::Path::parse(&settings.home[1])),
fsHome(kj::newDiskFilesystem()->getRoot().openSubdir(homePath, kj::WriteMode::MODIFY)),
@@ -136,18 +141,9 @@ void Laminar::loadCustomizations() {
}
uint Laminar::latestRun(std::string job) {
auto it = activeJobs.byJobName().equal_range(job);
if(it.first == it.second) {
uint result = 0;
db->stmt("SELECT MAX(number) FROM builds WHERE name = ?")
.bind(job)
.fetch<uint>([&](uint x){
result = x;
});
return result;
} else {
return (*--it.second)->build;
}
if(auto it = buildNums.find(job); it != buildNums.end())
return it->second;
return 0;
}
bool Laminar::handleLogRequest(std::string name, uint num, std::string& output, bool& complete) {
@@ -231,35 +227,29 @@ std::string Laminar::getStatus(MonitorScope scope) {
j.set("time", time(nullptr));
j.startObject("data");
if(scope.type == MonitorScope::RUN) {
db->stmt("SELECT queuedAt,startedAt,completedAt,result,reason,parentJob,parentBuild FROM builds WHERE name = ? AND number = ?")
db->stmt("SELECT queuedAt,startedAt,completedAt,result,reason,parentJob,parentBuild,q.lr IS NOT NULL,q.lr FROM builds "
"LEFT JOIN (SELECT name n, MAX(number), completedAt-startedAt lr FROM builds WHERE result IS NOT NULL GROUP BY n) q ON q.n = name "
"WHERE name = ? AND number = ?")
.bind(scope.job, scope.num)
.fetch<time_t, time_t, time_t, int, std::string, std::string, uint>([&](time_t queued, time_t started, time_t completed, int result, std::string reason, std::string parentJob, uint parentBuild) {
j.set("queued", started-queued);
.fetch<time_t, time_t, time_t, int, std::string, std::string, uint, uint, uint>([&](time_t queued, time_t started, time_t completed, int result, std::string reason, std::string parentJob, uint parentBuild, uint lastRuntimeKnown, uint lastRuntime) {
j.set("queued", queued);
j.set("started", started);
j.set("completed", completed);
j.set("result", to_string(RunState(result)));
if(completed)
j.set("completed", completed);
j.set("result", to_string(completed ? RunState(result) : started ? RunState::RUNNING : RunState::QUEUED));
j.set("reason", reason);
j.startObject("upstream").set("name", parentJob).set("num", parentBuild).EndObject(2);
if(lastRuntimeKnown)
j.set("etc", started + lastRuntime);
});
if(const Run* run = activeRun(scope.job, scope.num)) {
j.set("queued", run->startedAt - run->queuedAt);
j.set("started", run->startedAt);
j.set("result", to_string(RunState::RUNNING));
j.set("reason", run->reason());
j.startObject("upstream").set("name", run->parentName).set("num", run->parentBuild).EndObject(2);
db->stmt("SELECT completedAt - startedAt FROM builds WHERE name = ? ORDER BY completedAt DESC LIMIT 1")
.bind(run->name)
.fetch<uint>([&](uint lastRuntime){
j.set("etc", run->startedAt + lastRuntime);
});
}
if(auto it = buildNums.find(scope.job); it != buildNums.end())
j.set("latestNum", int(it->second));
j.startArray("artifacts");
populateArtifacts(j, scope.job, scope.num);
j.EndArray();
} else if(scope.type == MonitorScope::JOB) {
const uint runsPerPage = 10;
const uint runsPerPage = 20;
j.startArray("recent");
// ORDER BY param cannot be bound
std::string order_by;
@@ -274,7 +264,8 @@ std::string Laminar::getStatus(MonitorScope scope) {
order_by = "(completedAt-startedAt) " + direction + ", number DESC";
else
order_by = "number DESC";
std::string stmt = "SELECT number,startedAt,completedAt,result,reason FROM builds WHERE name = ? ORDER BY "
std::string stmt = "SELECT number,startedAt,completedAt,result,reason FROM builds "
"WHERE name = ? AND result IS NOT NULL ORDER BY "
+ order_by + " LIMIT ?,?";
db->stmt(stmt.c_str())
.bind(scope.job, scope.page * runsPerPage, runsPerPage)
@@ -288,7 +279,7 @@ std::string Laminar::getStatus(MonitorScope scope) {
.EndObject();
});
j.EndArray();
db->stmt("SELECT COUNT(*),AVG(completedAt-startedAt) FROM builds WHERE name = ?")
db->stmt("SELECT COUNT(*),AVG(completedAt-startedAt) FROM builds WHERE name = ? AND result IS NOT NULL")
.bind(scope.job)
.fetch<uint,uint>([&](uint nRuns, uint averageRuntime){
j.set("averageRuntime", averageRuntime);
@@ -319,14 +310,17 @@ std::string Laminar::getStatus(MonitorScope scope) {
}
}
j.set("nQueued", nQueued);
db->stmt("SELECT number,startedAt FROM builds WHERE name = ? AND result = ? ORDER BY completedAt DESC LIMIT 1")
db->stmt("SELECT number,startedAt FROM builds WHERE name = ? AND result = ? "
"ORDER BY completedAt DESC LIMIT 1")
.bind(scope.job, int(RunState::SUCCESS))
.fetch<int,time_t>([&](int build, time_t started){
j.startObject("lastSuccess");
j.set("number", build).set("started", started);
j.EndObject();
});
db->stmt("SELECT number,startedAt FROM builds WHERE name = ? AND result <> ? ORDER BY completedAt DESC LIMIT 1")
db->stmt("SELECT number,startedAt FROM builds "
"WHERE name = ? AND result <> ? "
"ORDER BY completedAt DESC LIMIT 1")
.bind(scope.job, int(RunState::SUCCESS))
.fetch<int,time_t>([&](int build, time_t started){
j.startObject("lastFailed");
@@ -337,14 +331,17 @@ std::string Laminar::getStatus(MonitorScope scope) {
j.set("description", desc == jobDescriptions.end() ? "" : desc->second);
} else if(scope.type == MonitorScope::ALL) {
j.startArray("jobs");
db->stmt("SELECT name,number,startedAt,completedAt,result FROM builds b JOIN (SELECT name n,MAX(number) l FROM builds GROUP BY n) q ON b.name = q.n AND b.number = q.l")
.fetch<str,uint,time_t,time_t,int>([&](str name,uint number, time_t started, time_t completed, int result){
db->stmt("SELECT name,number,startedAt,completedAt,result,reason FROM builds b "
"JOIN (SELECT name n,MAX(number) latest FROM builds WHERE result IS NOT NULL GROUP BY n) q "
"ON b.name = q.n AND b.number = latest")
.fetch<str,uint,time_t,time_t,int,str>([&](str name,uint number, time_t started, time_t completed, int result, str reason){
j.StartObject();
j.set("name", name);
j.set("number", number);
j.set("result", to_string(RunState(result)));
j.set("started", started);
j.set("completed", completed);
j.set("reason", reason);
j.EndObject();
});
j.EndArray();
@@ -364,7 +361,7 @@ std::string Laminar::getStatus(MonitorScope scope) {
j.EndObject();
} else { // Home page
j.startArray("recent");
db->stmt("SELECT * FROM builds ORDER BY completedAt DESC LIMIT 15")
db->stmt("SELECT * FROM builds WHERE completedAt IS NOT NULL ORDER BY completedAt DESC LIMIT 20")
.fetch<str,uint,str,time_t,time_t,time_t,int>([&](str name,uint build,str context,time_t,time_t started,time_t completed,int result){
j.StartObject();
j.set("name", name)
@@ -383,7 +380,9 @@ std::string Laminar::getStatus(MonitorScope scope) {
j.set("number", run->build);
j.set("context", run->context->name);
j.set("started", run->startedAt);
db->stmt("SELECT completedAt - startedAt FROM builds WHERE name = ? ORDER BY completedAt DESC LIMIT 1")
db->stmt("SELECT completedAt - startedAt FROM builds "
"WHERE completedAt IS NOT NULL AND name = ? "
"ORDER BY completedAt DESC LIMIT 1")
.bind(run->name)
.fetch<uint>([&](uint lastRuntime){
j.set("etc", run->startedAt + lastRuntime);
@@ -428,7 +427,7 @@ std::string Laminar::getStatus(MonitorScope scope) {
j.startObject("timePerJob");
db->stmt("SELECT name, AVG(completedAt-startedAt) av FROM builds WHERE completedAt > ? GROUP BY name ORDER BY av DESC LIMIT 8")
.bind(time(nullptr) - 7 * 86400)
.fetch<str, uint>([&](str job, uint time){
.fetch<str, double>([&](str job, double time){
j.set(job.c_str(), time);
});
j.EndObject();
@@ -466,29 +465,6 @@ std::string Laminar::getStatus(MonitorScope scope) {
j.EndObject();
});
j.EndArray();
j.startArray("buildTimeDist");
db->stmt("WITH ba AS (SELECT name,AVG(completedAt-startedAt) a FROM builds GROUP BY name) SELECT "
"COUNT(CASE WHEN a < 30 THEN 1 END),"
"COUNT(CASE WHEN a >= 30 AND a < 60 THEN 1 END),"
"COUNT(CASE WHEN a >= 60 AND a < 300 THEN 1 END),"
"COUNT(CASE WHEN a >= 300 AND a < 600 THEN 1 END),"
"COUNT(CASE WHEN a >= 600 AND a < 1200 THEN 1 END),"
"COUNT(CASE WHEN a >= 1200 AND a < 2400 THEN 1 END),"
"COUNT(CASE WHEN a >= 2400 AND a < 3600 THEN 1 END),"
"COUNT(CASE WHEN a >= 3600 THEN 1 END) FROM ba")
.fetch<uint,uint,uint,uint,uint,uint,uint,uint>([&](uint c1, uint c2, uint c3, uint c4, uint c5, uint c6, uint c7, uint c8){
j.Int(c1);
j.Int(c2);
j.Int(c3);
j.Int(c4);
j.Int(c5);
j.Int(c6);
j.Int(c7);
j.Int(c8);
});
j.EndArray();
}
j.EndObject();
return j.str();
@@ -520,6 +496,16 @@ bool Laminar::loadConfiguration() {
context->name = name;
context->numExecutors = conf.get<int>("EXECUTORS", 6);
std::string jobPtns = conf.get<std::string>("JOBS");
std::set<std::string> jobPtnsList;
if(!jobPtns.empty()) {
std::istringstream iss(jobPtns);
std::string job;
while(std::getline(iss, job, ','))
jobPtnsList.insert(job);
}
context->jobPatterns.swap(jobPtnsList);
knownContexts.insert(name);
}
}
@@ -552,14 +538,20 @@ bool Laminar::loadConfiguration() {
std::string ctxPtns = conf.get<std::string>("CONTEXTS");
std::set<std::string> ctxPtnList;
if(!ctxPtns.empty()) {
std::istringstream iss(ctxPtns);
std::set<std::string> ctxPtnList;
std::string ctx;
while(std::getline(iss, ctx, ','))
ctxPtnList.insert(ctx);
jobContexts[jobName].swap(ctxPtnList);
}
// Must be present both here and in queueJob because otherwise if a context
// were created while a job is already queued, the default context would be
// dropped when the set of contexts is updated here.
if(ctxPtnList.empty())
ctxPtnList.insert("default");
jobContexts[jobName].swap(ctxPtnList);
std::string desc = conf.get<std::string>("DESCRIPTION");
if(!desc.empty()) {
jobDescriptions[jobName] = desc;
@@ -582,18 +574,23 @@ std::shared_ptr<Run> Laminar::queueJob(std::string name, ParamMap params) {
return nullptr;
}
// If the job has no contexts (maybe there is no .conf file at all), add the default context
// jobContexts[name] can be empty if there is no .conf file at all
if(jobContexts[name].empty())
jobContexts.at(name).insert("default");
std::shared_ptr<Run> run = std::make_shared<Run>(name, kj::mv(params), homePath.clone());
std::shared_ptr<Run> run = std::make_shared<Run>(name, ++buildNums[name], kj::mv(params), homePath.clone());
queuedJobs.push_back(run);
db->stmt("INSERT INTO builds(name,number,queuedAt,parentJob,parentBuild,reason) VALUES(?,?,?,?,?,?)")
.bind(run->name, run->build, run->queuedAt, run->parentName, run->parentBuild, run->reason())
.exec();
// notify clients
Json j;
j.set("type", "job_queued")
.startObject("data")
.set("name", name)
.set("number", run->build)
.EndObject();
http->notifyEvent(j.str(), name.c_str());
@@ -613,21 +610,48 @@ void Laminar::abortAll() {
}
}
bool Laminar::canQueue(const Context& ctx, const Run& run) const {
if(ctx.busyExecutors >= ctx.numExecutors)
return false;
// match may be jobs as defined by the context...
for(std::string p : ctx.jobPatterns) {
if(fnmatch(p.c_str(), run.name.c_str(), FNM_EXTMATCH) == 0)
return true;
}
// ...or context as defined by the job.
for(std::string p : jobContexts.at(run.name)) {
if(fnmatch(p.c_str(), ctx.name.c_str(), FNM_EXTMATCH) == 0)
return true;
}
return false;
}
bool Laminar::tryStartRun(std::shared_ptr<Run> run, int queueIndex) {
for(auto& sc : contexts) {
std::shared_ptr<Context> ctx = sc.second;
if(ctx->canQueue(jobContexts.at(run->name))) {
kj::Promise<RunState> onRunFinished = run->start(buildNums[run->name] + 1, ctx, *fsHome,[this](kj::Maybe<pid_t>& pid){return srv.onChildExit(pid);});
if(canQueue(*ctx, *run)) {
RunState lastResult = RunState::UNKNOWN;
ctx->busyExecutors++;
// set the last known result if exists
// set the last known result if exists. Runs which haven't started yet should
// have completedAt == NULL and thus be at the end of a DESC ordered query
db->stmt("SELECT result FROM builds WHERE name = ? ORDER BY completedAt DESC LIMIT 1")
.bind(run->name)
.fetch<int>([=](int result){
run->lastResult = RunState(result);
.fetch<int>([&](int result){
lastResult = RunState(result);
});
kj::Promise<RunState> onRunFinished = run->start(lastResult, ctx, *fsHome,[this](kj::Maybe<pid_t>& pid){return srv.onChildExit(pid);});
db->stmt("UPDATE builds SET node = ?, startedAt = ? WHERE name = ? AND number = ?")
.bind(ctx->name, run->startedAt, run->name, run->build)
.exec();
ctx->busyExecutors++;
kj::Promise<void> exec = srv.readDescriptor(run->output_fd, [this, run](const char*b, size_t n){
// handle log output
std::string s(b, n);
@@ -647,16 +671,13 @@ bool Laminar::tryStartRun(std::shared_ptr<Run> run, int queueIndex) {
srv.addTask(kj::mv(exec));
LLOG(INFO, "Started job", run->name, run->build, ctx->name);
// update next build number
buildNums[run->name]++;
// notify clients
Json j;
j.set("type", "job_started")
.startObject("data")
.set("queueIndex", queueIndex)
.set("name", run->name)
.set("queued", run->startedAt - run->queuedAt)
.set("queued", run->queuedAt)
.set("started", run->startedAt)
.set("number", run->build)
.set("reason", run->reason());
@@ -705,10 +726,8 @@ void Laminar::handleRunFinished(Run * r) {
}
}
std::string reason = r->reason();
db->stmt("INSERT INTO builds VALUES(?,?,?,?,?,?,?,?,?,?,?,?)")
.bind(r->name, r->build, ctx->name, r->queuedAt, r->startedAt, completedAt, int(r->result),
maybeZipped, logsize, r->parentName, r->parentBuild, reason)
db->stmt("UPDATE builds SET completedAt = ?, result = ?, output = ?, outputLen = ? WHERE name = ? AND number = ?")
.bind(completedAt, int(r->result), maybeZipped, logsize, r->name, r->build)
.exec();
// notify clients
@@ -717,7 +736,7 @@ void Laminar::handleRunFinished(Run * r) {
.startObject("data")
.set("name", r->name)
.set("number", r->build)
.set("queued", r->startedAt - r->queuedAt)
.set("queued", r->queuedAt)
.set("completed", completedAt)
.set("started", r->startedAt)
.set("result", to_string(r->result))
@@ -765,7 +784,7 @@ kj::Maybe<kj::Own<const kj::ReadableFile>> Laminar::getArtefact(std::string path
bool Laminar::handleBadgeRequest(std::string job, std::string &badge) {
RunState rs = RunState::UNKNOWN;
db->stmt("SELECT result FROM builds WHERE name = ? ORDER BY number DESC LIMIT 1")
db->stmt("SELECT result FROM builds WHERE name = ? AND result IS NOT NULL ORDER BY number DESC LIMIT 1")
.bind(job)
.fetch<int>([&](int result){
rs = RunState(result);
@@ -807,16 +826,3 @@ R"x(
return true;
}
// TODO: deprecate
std::string Laminar::getCustomCss() {
KJ_IF_MAYBE(cssFile, fsHome->tryOpenFile(kj::Path{"custom","style.css"})) {
static bool warningShown = false;
if(!warningShown) {
LLOG(WARNING, "Custom CSS has been deprecated and will be removed from a future release. Use a custom HTML template instead.");
warningShown = true;
}
return (*cssFile)->readAllText().cStr();
} else {
return std::string();
}
}

View File

@@ -1,5 +1,5 @@
///
/// Copyright 2015-2019 Oliver Giles
/// Copyright 2015-2020 Oliver Giles
///
/// This file is part of Laminar
///
@@ -31,7 +31,7 @@
// Context name to context object map
typedef std::unordered_map<std::string, std::shared_ptr<Context>> ContextMap;
struct Server;
class Server;
class Json;
class Http;
@@ -90,11 +90,6 @@ public:
// if the job is unknown.
bool handleBadgeRequest(std::string job, std::string& badge);
// Fetches the content of $LAMINAR_HOME/custom/style.css or an empty
// string. Ideally, this would instead be served by a proper web server
// which handles this url.
std::string getCustomCss();
// Aborts a single job
bool abort(std::string job, uint buildNum);
@@ -105,6 +100,7 @@ private:
bool loadConfiguration();
void loadCustomizations();
void assignNewJobs();
bool canQueue(const Context& ctx, const Run& run) const;
bool tryStartRun(std::shared_ptr<Run> run, int queueIndex);
void handleRunFinished(Run*);
// expects that Json has started an array
@@ -125,7 +121,6 @@ private:
std::unordered_map<std::string, std::string> jobGroups;
Settings settings;
RunSet activeJobs;
Database* db;
Server& srv;

View File

@@ -20,6 +20,7 @@
#include <string>
#include <unistd.h>
#include <queue>
#include <dirent.h>
#include <sys/prctl.h>
#include <sys/types.h>
#include <sys/wait.h>
@@ -45,6 +46,39 @@ struct Script {
bool runOnAbort;
};
static void aggressive_recursive_kill(pid_t parent) {
DIR* proc = opendir("/proc");
if(!proc)
return;
while(struct dirent* de = readdir(proc)) {
if(!isdigit(*de->d_name))
continue;
char status_file[640];
sprintf(status_file, "/proc/%s/status", de->d_name);
FILE* status_fp = fopen(status_file, "rb");
if(!status_fp)
continue;
char status_buffer[512];
int n = fread(status_buffer, 1, 512, status_fp);
if(char* p = (char*)memmem(status_buffer, n, "PPid:\t", 6)) {
pid_t ppid = strtol(p + 6, NULL, 10);
if(ppid == parent) {
pid_t pid = atoi(de->d_name);
aggressive_recursive_kill(pid);
fprintf(stderr, "[laminar] sending SIGKILL to pid %d\n", pid);
kill(pid, SIGKILL);
}
}
fclose(status_fp);
}
closedir(proc);
}
class Leader final : public kj::TaskSet::ErrorHandler {
public:
Leader(kj::AsyncIoContext& ioContext, kj::Filesystem& fs, const char* jobName, uint runNumber);
@@ -67,6 +101,7 @@ private:
pid_t currentScriptPid;
std::queue<Script> scripts;
int setEnvPipe[2];
bool aborting;
};
Leader::Leader(kj::AsyncIoContext &ioContext, kj::Filesystem &fs, const char *jobName, uint runNumber) :
@@ -76,7 +111,8 @@ Leader::Leader(kj::AsyncIoContext &ioContext, kj::Filesystem &fs, const char *jo
home(fs.getCurrent()),
rootPath(fs.getCurrentPath()),
jobName(jobName),
runNumber(runNumber)
runNumber(runNumber),
aborting(false)
{
tasks.add(ioContext.unixEventPort.onSignal(SIGTERM).then([this](siginfo_t) {
while(scripts.size() && (!scripts.front().runOnAbort))
@@ -84,8 +120,8 @@ Leader::Leader(kj::AsyncIoContext &ioContext, kj::Filesystem &fs, const char *jo
// TODO: probably shouldn't do this if we are already in a runOnAbort script
kill(-currentGroupId, SIGTERM);
return this->ioContext.provider->getTimer().afterDelay(2*kj::SECONDS).then([this]{
fprintf(stderr, "[laminar] sending SIGKILL to process group %d\n", currentGroupId);
kill(-currentGroupId, SIGKILL);
aborting = true;
aggressive_recursive_kill(getpid());
});
}));
@@ -223,14 +259,18 @@ kj::Promise<void> Leader::reapChildProcesses()
// waiting for is done
return reapChildProcesses();
}
// we were aborted by the primary process already, just wait until all
// SIGKILLs are processed
if(aborting) {
return reapChildProcesses();
}
// Otherwise, reparented orphans are on borrowed time
// TODO list wayward processes?
fprintf(stderr, "[laminar] sending SIGHUP to adopted child processes\n");
kill(-currentGroupId, SIGHUP);
return ioContext.provider->getTimer().afterDelay(5*kj::SECONDS).then([this]{
fprintf(stderr, "[laminar] sending SIGKILL to process group %d\n", currentGroupId);
// TODO: should we mark the job as failed if we had to kill reparented processes?
kill(-currentGroupId, SIGKILL);
aggressive_recursive_kill(getpid());
return reapChildProcesses();
}).exclusiveJoin(reapChildProcesses());
} else if(pid == currentScriptPid) {

View File

@@ -122,7 +122,7 @@ inline bool beginsWith(std::string haystack, const char* needle) {
bool Resources::handleRequest(std::string path, const char** start, const char** end, const char** content_type) {
// need to keep the list of "application links" synchronised with the angular
// application. We cannot return a 404 for any of these
auto it = beginsWith(path,"/jobs")
auto it = beginsWith(path,"/jobs") || path == "/wallboard"
? resources.find("/")
: resources.find(path);

View File

@@ -66,14 +66,11 @@
<div><canvas id="chartUtil"></canvas></div>
</div>
</div>
<div>
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 5px; padding: 5px;">
<div><canvas id="chartBpd"></canvas></div>
<div><canvas id="chartBpj"></canvas></div>
<div><canvas id="chartTpj"></canvas></div>
<div><canvas id="chartBuildTimeChanges"></canvas></div>
<div><canvas id="chartBuildTimeDist"></canvas></div>
</div>
<div id="page-home-plots">
<div><canvas id="chartBpd"></canvas></div>
<div><canvas id="chartBpj"></canvas></div>
<div><canvas id="chartTpj"></canvas></div>
<div><canvas id="chartBuildTimeChanges"></canvas></div>
</div>
</section>
</div></template>
@@ -84,7 +81,19 @@
<a v-show="ungrouped.length" :class="{'active':group==null}" href v-on:click.prevent="group = null">Ungrouped Jobs</a>
<a v-for="g in Object.keys(groups)" :class="{'active':g==group}" href v-on:click.prevent="group = g">{{g}}</a>
</div>
<input class="form-control" id="jobFilter" v-model="search" placeholder="Filter...">
<div style="display: grid; grid-auto-flow: column; align-items: center; gap: 15px">
<router-link :to="wallboardLink()" style="display: inherit;" title="Wallboard">
<svg width="18" viewBox="0 0 13 13">
<g fill="#728494">
<rect x="0" y="2" width="6" height="4" />
<rect x="0" y="7" width="6" height="4" />
<rect x="7" y="2" width="6" height="4" />
<rect x="7" y="7" width="6" height="4" />
</g>
</svg>
</router-link>
<input class="form-control" id="jobFilter" v-model="search" placeholder="Filter...">
</div>
</nav>
<table class="striped" id="job-list">
<tr v-for="job in filteredJobs()">
@@ -96,6 +105,14 @@
</table>
</div></template>
<template id="wallboard"><div class="wallboard">
<router-link :to="'/jobs/'+job.name+'/'+job.number" tag="div" v-for="job in wallboardJobs()" :data-result="job.result">
<span style="font-size: 36px; font-weight: bold;">{{job.name}} #{{job.number}}</span><br>
<span style="font-size: 30px;">{{formatDate(job.started)}}</span><br>
<span style="font-size: 26px;">{{job.reason}}</span>
</router-link>
</div></template>
<template id="job"><div id="page-job-main">
<div style="padding: 15px;">
<h2>{{$route.params.name}}</h2>
@@ -120,7 +137,8 @@
<th class="text-center vp-sm-hide">Reason <a class="sort" :class="(sort.field=='reason'?sort.order:'')" v-on:click="do_sort('reason')">&nbsp;</a></th>
</tr></thead>
<tr v-show="nQueued">
<td colspan="5"><i>{{nQueued}} run(s) queued</i></td>
<td style="width:1px"><span v-html="runIcon('queued')"></span></td>
<td colspan="4"><i>{{nQueued}} run(s) queued</i></td>
</tr>
<tr v-for="job in jobsRunning.concat(jobsRecent)" track-by="$index">
<td style="width:1px"><span v-html="runIcon(job.result)"></span></td>
@@ -140,25 +158,24 @@
<template id="run"><div style="display: grid; grid-template-rows: auto 1fr">
<div style="padding: 15px">
<div style="display: grid; grid-template-columns: auto 1fr 400px auto auto; gap: 5px; align-items: center">
<div style="display: grid; grid-template-columns: auto 25px auto auto 1fr 400px; gap: 5px; align-items: center">
<h2 style="white-space: nowrap"><span v-html="runIcon(job.result)"></span> {{$route.params.name}} #{{$route.params.number}}</h2>
<span></span>
<div><!-- extra div to preserve grid columns when v-show hides the progress bar -->
<div class="progress" v-show="job.result == 'running'">
<div class="progress-bar" :class="{overtime:job.overtime,indeterminate:!job.etc}" :style="job.etc && {width:job.progress+'%'}"></div>
</div>
</div>
<router-link :disabled="$route.params.number == 1" :to="'/jobs/'+$route.params.name+'/'+($route.params.number-1)" tag="button">&laquo;</router-link>
<router-link :disabled="$route.params.number == latestNum" :to="'/jobs/'+$route.params.name+'/'+(parseInt($route.params.number)+1)" tag="button">&raquo;</router-link>
<span></span>
<div class="progress" v-show="job.result == 'running'">
<div class="progress-bar" :class="{overtime:job.overtime,indeterminate:!job.etc}" :style="job.etc && {width:job.progress+'%'}"></div>
</div>
</div>
<div id="page-run-detail">
<dl>
<dt>Reason</dt><dd>{{job.reason}}</dd>
<dt v-show="job.upstream.num > 0">Upstream</dt><dd v-show="job.upstream.num > 0"><router-link :to="'/jobs/'+job.upstream.name">{{job.upstream.name}}</router-link> <router-link :to="'/jobs/'+job.upstream.name+'/'+job.upstream.num">#{{job.upstream.num}}</router-link></li></dd>
<dt>Queued for</dt><dd>{{job.queued}}s</dd>
<dt>Started</dt><dd>{{formatDate(job.started)}}</dd>
<dt>Queued for</dt><dd>{{formatDuration(job.queued, job.started ? job.started : Math.floor(Date.now()/1000))}}</dd>
<dt v-show="job.started">Started</dt><dd v-show="job.started">{{formatDate(job.started)}}</dd>
<dt v-show="runComplete(job)">Completed</dt><dd v-show="job.completed">{{formatDate(job.completed)}}</dd>
<dt>Duration</dt><dd>{{formatDuration(job.started, job.completed)}}</dd>
<dt v-show="job.started">Duration</dt><dd v-show="job.started">{{formatDuration(job.started, job.completed)}}</dd>
</dl>
<dl v-show="job.artifacts.length">
<dt>Artifacts</dt>

File diff suppressed because it is too large Load Diff

View File

@@ -84,7 +84,9 @@ canvas {
}
svg.success path { fill: var(--success); }
svg.failed path { fill: var(--failure); }
svg.running circle { stroke: var(--running); }
svg.running circle { stroke: var(--running); }
svg.queued circle { fill: var(--nav-fg); }
svg.queued path { stroke: white; }
/* sort indicators */
a.sort {
@@ -163,7 +165,6 @@ button:not([disabled]) { cursor: pointer; color: var(--main-fg); }
}
.progress-bar {
height: 100%;
width: 100%;
background-color: var(--running);
background-image: linear-gradient(45deg, transparent 35%, rgba(255,255,255,0.18) 35% 65%, transparent 65%);
background-size: 1rem;
@@ -177,6 +178,41 @@ button:not([disabled]) { cursor: pointer; color: var(--main-fg); }
from { background-position: 1rem 0; } to { background-position: 0 0; }
}
/* wallboard */
.wallboard {
display: flex;
flex-wrap: wrap-reverse;
flex-direction: row-reverse;
gap: 20px;
padding: 20px;
position: fixed;
height: 100%;
width: 100%;
overflow: auto;
background-color: #000
}
.wallboard > div {
padding: 30px;
flex-grow: 1;
background-color: var(--failure);
color: var(--nav-fg-light);
}
.wallboard > div:hover {
cursor: pointer;
}
.wallboard > div[data-result="running"] {
animation: wallboard-bg-fade 2s ease infinite;
}
@keyframes wallboard-bg-fade {
from { background-color: #4786ab; }
50% { background-color: #446597; }
to { background-color: #4786ab; }
}
.wallboard > div[data-result="success"] {
background-color: var(--success);
color: var(--main-fg);
}
/* connecting overlay */
#connecting-overlay {
position: fixed;
@@ -214,6 +250,8 @@ button:not([disabled]) { cursor: pointer; color: var(--main-fg); }
grid-template-columns: 1fr 1fr 1fr;
padding: 15px;
gap: 15px;
max-width: 1600px;
margin: auto;
text-align: center;
}
@media (max-width: 650px) {
@@ -221,6 +259,19 @@ button:not([disabled]) { cursor: pointer; color: var(--main-fg); }
grid-template-columns: 1fr;
}
}
#page-home-plots {
display: grid;
grid-template-columns: 1fr 1fr;
padding: 5px;
gap: 5px;
max-width: 1600px;
margin: auto;
}
@media (max-width: 1095px) {
#page-home-plots {
grid-template-columns: 1fr;
}
}
#page-job-main {
display: grid;
grid-template: auto 1fr / minmax(550px, 1fr) 1fr;

View File

@@ -53,10 +53,13 @@ public:
kj::Promise<void> queue(QueueContext context) override {
std::string jobName = context.getParams().getJobName();
LLOG(INFO, "RPC queue", jobName);
LaminarCi::MethodResult result = laminar.queueJob(jobName, params(context.getParams().getParams()))
? LaminarCi::MethodResult::SUCCESS
: LaminarCi::MethodResult::FAILED;
context.getResults().setResult(result);
std::shared_ptr<Run> run = laminar.queueJob(jobName, params(context.getParams().getParams()));
if(Run* r = run.get()) {
context.getResults().setResult(LaminarCi::MethodResult::SUCCESS);
context.getResults().setBuildNum(r->build);
} else {
context.getResults().setResult(LaminarCi::MethodResult::FAILED);
}
return kj::READY_NOW;
}

View File

@@ -1,5 +1,5 @@
///
/// Copyright 2019 Oliver Giles
/// Copyright 2019-2020 Oliver Giles
///
/// This file is part of Laminar
///
@@ -23,7 +23,7 @@
#include <capnp/rpc-twoparty.h>
#include <capnp/rpc.capnp.h>
struct Laminar;
class Laminar;
class Rpc {
public:

View File

@@ -33,7 +33,7 @@ inline kj::Path operator/(const kj::Path& p, const T& ext) {
std::string to_string(const RunState& rs) {
switch(rs) {
case RunState::PENDING: return "pending";
case RunState::QUEUED: return "queued";
case RunState::RUNNING: return "running";
case RunState::ABORTED: return "aborted";
case RunState::FAILED: return "failed";
@@ -44,10 +44,10 @@ std::string to_string(const RunState& rs) {
}
Run::Run(std::string name, ParamMap pm, kj::Path&& rootPath) :
Run::Run(std::string name, uint num, ParamMap pm, kj::Path&& rootPath) :
result(RunState::SUCCESS),
lastResult(RunState::UNKNOWN),
name(name),
build(num),
params(kj::mv(pm)),
queuedAt(time(nullptr)),
rootPath(kj::mv(rootPath)),
@@ -84,7 +84,7 @@ static void setEnvFromFile(const kj::Path& rootPath, kj::Path file) {
}
}
kj::Promise<RunState> Run::start(uint buildNum, std::shared_ptr<Context> ctx, const kj::Directory &fsHome, std::function<kj::Promise<int>(kj::Maybe<pid_t>&)> getPromise)
kj::Promise<RunState> Run::start(RunState lastResult, std::shared_ptr<Context> ctx, const kj::Directory &fsHome, std::function<kj::Promise<int>(kj::Maybe<pid_t>&)> getPromise)
{
kj::Path cfgDir{"cfg"};
@@ -131,7 +131,7 @@ kj::Promise<RunState> Run::start(uint buildNum, std::shared_ptr<Context> ctx, co
PATH.append(p);
}
std::string runNumStr = std::to_string(buildNum);
std::string runNumStr = std::to_string(build);
setenv("PATH", PATH.c_str(), true);
setenv("RUN", runNumStr.c_str(), true);
@@ -152,14 +152,13 @@ kj::Promise<RunState> Run::start(uint buildNum, std::shared_ptr<Context> ctx, co
// enough. Instead, we'll just exec ourselves and handle that in laminard's
// main() by calling leader_main()
char* procName;
if(asprintf(&procName, "{laminar} %s:%d", name.data(), buildNum) > 0)
if(asprintf(&procName, "{laminar} %s:%d", name.data(), build) > 0)
execl("/proc/self/exe", procName, NULL); // does not return
_exit(EXIT_FAILURE);
}
// All good, we've "started"
startedAt = time(nullptr);
build = buildNum;
context = ctx;
output_fd = plog[0];

View File

@@ -34,7 +34,7 @@ typedef unsigned int uint;
enum class RunState {
UNKNOWN,
PENDING,
QUEUED,
RUNNING,
ABORTED,
FAILED,
@@ -50,14 +50,14 @@ typedef std::unordered_map<std::string, std::string> ParamMap;
// Represents an execution of a job.
class Run {
public:
Run(std::string name, ParamMap params, kj::Path&& rootPath);
Run(std::string name, uint num, ParamMap params, kj::Path&& rootPath);
~Run();
// copying this class would be asking for trouble...
Run(const Run&) = delete;
Run& operator=(const Run&) = delete;
kj::Promise<RunState> start(uint buildNum, std::shared_ptr<Context> ctx, const kj::Directory &fsHome, std::function<kj::Promise<int>(kj::Maybe<pid_t>&)> getPromise);
kj::Promise<RunState> start(RunState lastResult, std::shared_ptr<Context> ctx, const kj::Directory &fsHome, std::function<kj::Promise<int>(kj::Maybe<pid_t>&)> getPromise);
// aborts this run
bool abort();
@@ -69,7 +69,6 @@ public:
std::shared_ptr<Context> context;
RunState result;
RunState lastResult;
std::string name;
std::string parentName;
int parentBuild = 0;

View File

@@ -95,7 +95,7 @@ kj::Promise<int> Server::onChildExit(kj::Maybe<pid_t> &pid) {
Server::PathWatcher& Server::watchPaths(std::function<void()> fn)
{
struct PathWatcherImpl : public PathWatcher {
struct PathWatcherImpl final : public PathWatcher {
PathWatcher& addPath(const char* path) override {
inotify_add_watch(fd, path, IN_ONLYDIR | IN_CLOSE_WRITE | IN_CREATE | IN_DELETE);
return *this;

View File

@@ -1,5 +1,5 @@
///
/// Copyright 2015-2017 Oliver Giles
/// Copyright 2015-2020 Oliver Giles
///
/// This file is part of Laminar
///
@@ -26,9 +26,9 @@
#include <functional>
#include <sys/types.h>
struct Laminar;
struct Http;
struct Rpc;
class Laminar;
class Http;
class Rpc;
// This class manages the program's asynchronous event loop
class Server final : public kj::TaskSet::ErrorHandler {

View File

@@ -45,7 +45,6 @@ TEST_F(LaminarFixture, EmptyStatusMessageStructure) {
EXPECT_TRUE(data.HasMember("resultChanged"));
EXPECT_TRUE(data.HasMember("lowPassRates"));
EXPECT_TRUE(data.HasMember("buildTimeChanges"));
EXPECT_TRUE(data.HasMember("buildTimeDist"));
}
TEST_F(LaminarFixture, JobNotifyHomePage) {