2
0
Fork 0
mirror of git://git.savannah.gnu.org/guix/guix-cuirass.git synced 2023-12-14 06:03:04 +01:00
Commit graph

92 commits

Author SHA1 Message Date
Mathieu Othacehe cbc462679d
Switch to PostegreSQL. 2021-01-11 12:28:13 +01:00
Mathieu Othacehe ca7a7ca989
Add remote build support.
* src/cuirass/remote.scm: New file.
* src/cuirass/remote-server.scm: New file.
* src/cuirass/remote-worker.scm: New file.
* bin/remote-server.in: New file.
* bin/remote-worker.in: New file.
* Makefile.am (bin_SCRIPTS): Add new binaries,
(dist_pkgmodule_DATA): add new files,
(EXTRA_DIST): add new binaries,
(bin/remote-server, bin/remote-worker): new targets.
* .gitignore: Add new binaries.
* bin/cuirass.in (%options): Add "--build-remote" option,
(show-help): document it,
(main): honor it.
* src/cuirass/base.scm (with-build-offload-thread): New macro,
(%build-remote?, %build-offload-channel): new parameters,
(make-build-offload-thread): new procedure,
(build-derivations/offload): new procedure,
(restart-builds): use it to offload builds when %build-remote? is set,
(build-packages): ditto.
2021-01-06 21:06:04 +01:00
Mathieu Othacehe ac2187ff6b
http: Add /api/evaluation route.
* src/cuirass/database.scm (db-get-evaluation): New procedure.
* src/cuirass/http.scm (url-handler): Add "/api/evaluation" route.
2020-12-07 15:34:29 +01:00
Mathieu Othacehe ad44a9bb02
http: Add evaluation field to hydra-build.
* src/cuirass/http.scm (build->hydra-build): Add "evaluation" field.
2020-12-07 15:13:09 +01:00
Mathieu Othacehe cb2c4e3d8f
Optimize build query.
Make sure that db-get-builds only performs one query and add build products to
the result. Also add indexes so that all "order" filters are covered.

Limit the maximum of build objects returned in "/api/latestbuilds" and
"/api/queue" to 1000.

Fixes: <https://issues.guix.gnu.org/43826>.

* src/sql/upgrade-15.sql: New file.
* Makefile (dist_sql_DATA): Add it.
* src/cuirass/database.scm (db-get-builds-by-search): Add "buildproducts" to
the returned build objects.
(db-get-builds): Remove unused filters. Join Outputs and BuildProducts table
in the query. Add "buildproducts" to the returned build objects.
* src/cuirass/http.scm (build->hydra-build): Use "buildproducts" from
"db-get-builds" procedure.
(url-handler): Forbid limit parameters greater than 1000 and use
"buildproducts" from "db-get-builds" procedure.
* src/schema.sql (Builds_stoptime, Builds_stoptime_id, Builds_status_ts_id):
New indexes.
2020-10-07 13:07:05 +02:00
Mathieu Othacehe 9a60cd6619
metrics: Order evaluation metrics by ascending evaluation id.
* src/cuirass/http.scm (metrics-page): Order 'average-eval-build-start-time
and 'evaluation-completion-speed metrics per ascending evaluation id.
2020-09-17 16:10:07 +02:00
Mathieu Othacehe bd4f4d680a
metrics: Display more metrics.
* src/cuirass/http.scm (url-handler): Move metric page creation to ...
(metrics-page): ... this new procedure. Pass average evaluation build start
time and evaluation completion speed to "global-metrics-content".
* src/cuirass/templates.scm (make-line-chart): Add "time-x-axes?",
"xaxes-labels", "x-label" and "y-label" arguents.
(global-metrics-content): Add "avg-eval-build-start-time" and
"eval-completion-speed" arguments. Create and display two new charts from
those metrics.
2020-09-17 10:13:14 +02:00
Mathieu Othacehe f3ab04aee4
metrics: Add 'percentage-failed-eval-per-spec support.
* src/cuirass/metrics.scm (db-percentage-failed-eval-per-spec): New procedure.
(%metrics): Add 'percentage-failure-10-last-eval-per-spec,
'percentage-failure-100-last-eval-per-spec and
'percentage-failed-eval-per-spec metrics.
(db-update-metrics): Add them.
* src/cuirass/templates.scm (global-metrics-content): Add
"percentage-failed-eval" argument. Use it to display the "percentage of failed
evaluations" table.
* src/cuirass/templates.scm (url-handler): Adapt accordingly.
2020-09-15 14:34:19 +02:00
Mathieu Othacehe 97ec7a2da5
metrics: Add 'new-derivations-per-day support.
* src/cuirass/metrics.scm (db-new-derivations-previous-day): New procedure.
(%metrics): Add 'new-derivations-per-day.
(db-update-metrics): Add it.
* src/cuirass/templates.scm (make-line-chart): Add support for multiple
datasets. Also add "interpolation?" and "legend?" options.
(global-metrics-content): Add "new-derivations-per-day" argument. Adapt
"Builds per day" chart so that it uses two datasets from
'new-derivations-per-day and 'builds-per-day metrics.
* src/cuirass/templates.scm (url-handler): Adapt accordingly.
2020-09-15 11:13:09 +02:00
Mathieu Othacehe f011d87456
metrics: Add pending builds support.
* src/cuirass/metrics.scm (db-pending-builds, db-current-day-timestamp): New
procedures.
(%metrics): Add 'pending-builds.
(db-update-metrics): Add it.
* src/cuirass/templates.scm (global-metrics-content): Add "pending-builds"
argument. Display pending builds in a line chart.
* src/cuirass/http.scm (url-handler): Adapt "global-metrics-content" call
accordingly.
2020-09-15 09:55:40 +02:00
Mathieu Othacehe 5a947e1841
metrics: Rename 'builds-previous-day to 'builds-per-day.
* src/cuirass/metrics.scm (%metrics): Rename 'builds-previous-day to
'builds-per-day.
(db-update-metrics): Adapt accordingly.
* src/cuirass/http.scm (url-handler): Ditto.
2020-09-15 09:47:04 +02:00
Mathieu Othacehe cd2d2512e6
metrics: Order by descending rowid by default.
* src/cuirass/metrics.scm (db-get-metrics-with-id): Order by descending rowid
by default.
* src/cuirass/http.scm (url-handler): Use the default order for
"db-get-metrics-with-id".
2020-09-15 09:16:11 +02:00
Mathieu Othacehe cf11b73db0
Add metrics support.
* Makefile.am: Add "upgrade-11.sql", "chart.js" and "metrics.js".
* bin/cuirass.in (main): Add 'metrics fiber.
* src/cuirass/http.scm (%file-white-list): Add "js/chart.js".
(url-handler): Add "/metrics" route.
* src/cuirass/metrics.scm: New file.
* src/cuirass/templates.scm (html-page): Add a "Global metrics" sub-menu to
"Status" dropdown menu.
(make-line-chart, global-metrics-content): New procedures.
* src/schema.sql (Metrics): New table.
* src/sql/upgrade-11.sql: New file.
* src/static/js/chart.js: New file.
2020-09-14 14:32:12 +02:00
Mathieu Othacehe b135a02bf2
Fix /specifications route.
Fixes <https://issues.guix.gnu.org/43163>.

* src/cuirass/http.scm (specification->json-object): New procedure,
(url-handler): use it for "/specifications" route to convert specification
objects into a representation suitable for json->scm.
* tests/http.scm ("/specifications"): Test the above route.
2020-09-02 10:43:22 +02:00
Mathieu Othacehe d250a95c46
http: Fix typo in request-parameters.
This is a follow-up of 2094d68053.

* src/cuirass/http.scm (request-parameters): Fix typo.
2020-08-03 15:36:03 +02:00
Mathieu Othacehe 2094d68053
http: Handle request parameters with no value.
Handle requests such as "/build/?nr" by ignoring parameters without any
associated value.

* src/cuirass/http.scm (request-parameters): Ignore silently parameters
without an associated value.
* tests/http.scm: Add a corresponding test case.
2020-08-03 15:27:00 +02:00
Mathieu Othacehe d3329551fe
http: Fix string concatenation.
This is a follow-up of 614ea05767.

* src/cuirass/http.scm (url-handler): Fix string concatenation.
2020-08-02 19:18:25 +02:00
Mathieu Othacehe 614ea05767
http: Rationalize build id conversion.
* src/cuirass/http.scm (url-handler): Handle the id -> number conversion
directly in the route declaration.
2020-08-02 18:39:35 +02:00
Mathieu Othacehe 59c974134f
http: Handle wrong build number on log route.
* src/cuirass/http.scm (url-handler): Handle erroneous id -> number conversion
on "/build/id/log/raw" route.
2020-08-02 18:34:19 +02:00
Mathieu Othacehe ce89a40ed8
http: Handle wrong build number on details route.
The request "/build/2465370mdb%22fx'ggx/details" causes a select query on the
whole Builds table, because failed "string->number" conversion is not handled.

* src/cuirass/http.scm (url-handler): Handle erroneous id -> number conversion
on "/build/id/details" route.
2020-08-02 18:30:37 +02:00
Mathieu Othacehe 769682924c
http: Handle wrong build number.
The request "/build/1234)" causes a select query on the whole Builds table,
because failed "string->number" conversion is not handled.

* src/cuirass/http.scm (url-handler): Handle erroneous id -> number conversion
on "/build/id" route.
2020-08-02 15:50:59 +02:00
Mathieu Othacehe e41327350d
http: Handle error on /download.
* src/cuirass/http.scm (url-handler): Handle the error case on /download
route.
2020-07-28 18:14:08 +02:00
Mathieu Othacehe 136a8295e4
Add "latest builds" support.
Add a "status" dropdown menu in the navigation bar. For now this menu only
contains one item, a link to the "latest builds" page at "/status" location.

* src/cuirass/database.scm (db-get-builds): Add support for 'started status.
* src/cuirass/http.scm (url-handler): Add "/status" route.
* src/cuirass/templates.scm (running-builds-table): New procedure,
(html-page): add a dropdown menu containing one item, a link to "/status"
route defined above.
* src/static/css/cuirass.css: Add new class to allow bootstrap dropdown menus
to work without javascript plugin.
2020-07-02 21:07:30 +02:00
Mathieu Othacehe 300f6253f6
http: Display gzipped log files in the browser.
This is a follow-up of 2280ae18eb. The gzipped
log files are supposed to be displayed directly in the browser and not
downloaded. Set "Content-Disposition" header to "inline" to ensure that.

* src/cuirass/http.scm (respond-gzipped-file): Set to "Content-Disposition" to
"inline".
2020-06-23 14:02:42 +02:00
Mathieu Othacehe 61cc56f6cc
http: Add /search/latest and /search/latest/<product-type> routes.
* src/cuirass/http.scm (url-handler): Add "/search/latest" and
"/search/latest/<product-type>" routes.
2020-06-21 12:56:50 +02:00
Mathieu Othacehe 3db603c191
http: Add build products support to the API.
* src/cuirass/http.scm (build->hydra-build)[build-products]: New variable,
added to "buildproducts" field.
* tests/http.scm (build-query-result): Adapt accordingly.
2020-06-14 18:45:38 +02:00
Mathieu Othacehe 2280ae18eb
cuirass: Use sendfiles instead of raw copies.
* src/cuirass/http.scm (respond-file): Send the file name as 'x-raw-file
header argument, instead of the raw file content,
(respond-gzipped-file): ditto. Also set 'content-disposition header.
* src/web/server/fiberized.scm (strip-headers, with-content-length): New procedures,
(client-loop): Check if 'x-raw-file is set. If it's the case, use sendfiles to
send the given file. Otherwise, keep the existing behaviour and send directly
the received bytevector.
2020-06-10 16:42:21 +02:00
Mathieu Othacehe f44618fc79
Add support for build products downloading.
* src/sql/upgrade-7.sql: New file.
* Makefile.am: Add it.
* src/cuirass/base.scm (create-build-outputs): New procedure,
(build-packages): call it,
(process-spec): add the new spec argument and pass it to create-build-outputs.
* src/cuirass/database.scm (db-add-build-product, db-get-build-product-path,
db-get-build-products): New exported procedures.
* src/cuirass/http.scm (respond-static-file): Move file sending to ...
(respond-file): ... this new procedure,
(url-handler): add a new "download/<id>" route, serving the requested file
with the new respond-file procedure. Also gather build products and pass them
to "build-details" for "build/<id>/details" route.
* src/cuirass/templates.scm (build-details): Honor the new "products" argument
to display all the build products associated to the given build.
* src/schema.sql (BuildProducts): New table,
(Specifications)[build_outputs]: new field.
* tests/database.scm: Add empty build-outputs spec.
* tests/http.scm: Ditto.
* examples/guix-jobs.scm: Ditto.
* examples/hello-git.scm: Ditto.
* examples/hello-singleton.scm: Ditto.
* examples/hello-subset.scm: Ditto.
* examples/random.scm: Ditto.
* doc/cuirass.texi (overview): Document it.
2020-06-10 16:42:21 +02:00
Ludovic Courtès c961de2f63 templates: Evaluation page shows each input and commit.
* src/cuirass/database.scm (db-get-inputs, db-get-checkouts): Export.
* src/cuirass/http.scm (evaluation-html-page): Pass #:checkouts and
 #:inputs to 'evaluation-build-table'.
* src/cuirass/templates.scm (evaluation-build-table): Add #:checkouts
and #:inputs.  Emit a table with "Input" and "Commit" columns.
2020-04-17 15:07:17 +02:00
Ricardo Wurmus 6aef31bd93
templates: Display search hints.
* src/static/css/cuirass.css: New file.
* Makefile.am (dist_css_DATA): Add it.
* src/cuirass/http.scm (%file-white-list): Add css/cuirass.css.
* src/cuirass/templates.scm (search-form): Add search-hints div.
(html-page): Load cuirass.css.
2020-04-15 19:54:09 +02:00
Ludovic Courtès a436895372 http: Move "/eval" page to (cuirass templates).
* src/cuirass/http.scm (url-handler): Move inline code for ('GET "eval" id)
to...
(evaluation-html-page): ... here.  New procedure.
* src/cuirass/templates.scm (evaluation-build-table): New procedure.
2020-02-24 00:09:22 +01:00
Christopher Baines 46f73b6b7c Support returning build information by output.
Being able to take a derivation and query the build information is useful, but
in cases where there are multiple derivations that produce the same outputs,
the probability of getting the data back from Cuirass is reduced.

This is because Cuirass might not have build the exact derivation you have,
but a different derivation that produces the same outputs (this can commonly
happen when a related fixed output derivation changes).

Cuirass doesn't store derivations if they produce the same outputs as a
derivation it already knows about, so it can't determine if this is the
case. Therefore, provide a way of querying build results by output, rather
than derivation.

The motivation behind this is to make it easier to import build information in
to the Guix Data Service.

* src/cuirass/database.scm (db-get-output): New procedure.
* src/cuirass/http.scm (respond-output-not-found): New procedure.
(request-path-components): Handle /output/… requests.
* doc/cuirass.texi (Build information): Mention that you can get build
information by output.
2020-01-16 08:33:03 +00:00
Ricardo Wurmus 647f3961fa
http: Add route for /admin.
* src/cuirass/http.scm (url-handler): Handle /admin route.
2019-10-30 13:00:14 +01:00
Ricardo Wurmus 918601d966
http: Handle specification deletion and addition.
* src/cuirass/http.scm (url-handler): Handle /admin/specifications/add,
/admin/specifications/delete/*, and /admin/specifications.
2019-10-30 09:21:37 +01:00
Ricardo Wurmus c88a7c006e
http: Be explicit about accepted HTTP methods.
* src/cuirass/http.scm (url-handler): Match on HTTP method.
2019-10-30 09:18:01 +01:00
Ludovic Courtès c8c34f8ee3 http: Serve evaluation logs at /eval/ID/log/raw.
* src/cuirass/base.scm (evaluation-log-file): Export.
* src/cuirass/http.scm (url-handler)[respond-gzipped-file]: New
procedure.
Add handler for /eval/ID/log/raw.
2019-10-23 15:37:15 +02:00
Christopher Baines 9acb0aa55b http: Support fetching builds by derivation.
There's a one to one mapping of build id to derivation, so allow querying by
derivation file name as well. I'm looking at this as I'm interested in getting
build information in to the Guix Data Service.

* src/cuirass/http.scm (url-handler): Support fetching builds by numeric id or
the derivation file name.
2019-10-02 08:16:54 +01:00
Ludovic Courtès 6cf84a43bb http: Pass 'build-search-results-table' a list, not a vector.
* src/cuirass/http.scm (url-handler): Call 'vector->list' on the result
of 'handle-builds-search-request', as expected by 'build-search-results-table'.
2019-08-27 10:12:12 +02:00
Ludovic Courtès 3d494b8973 http: Pass 'build-eval-table' a list, not a vector.
* src/cuirass/http.scm (url-handler): Call 'vector->list' on the result
of 'handle-builds-request', as expected by 'build-eval-table'.
2019-08-27 10:06:18 +02:00
Ricardo Wurmus 1cd2f9334d
http: Fix type error.
This is a follow-up to commit c6f4fa5f57.

* src/cuirass/http.scm (url-handler): SPECIFICATIONS-TABLE expects a list, not
a vector.
2019-08-27 00:38:08 +02:00
Ludovic Courtès c6f4fa5f57 Switch to Guile-JSON 3.x.
Guile-JSON 3.x is incompatible with Guile-JSON 1.x, which we relied on
until now: it maps JSON dictionaries to alists (instead of hash tables),
and JSON arrays to vectors (instead of lists).  This commit is about
adjusting all the existing code to this new mapping.

* src/cuirass/http.scm (evaluation->json-object): New procedure.
(handle-builds-request): Pass the result through 'list->vector'.
(handle-builds-search-request): Likewise.
(url-handler): Likewise for /jobsets, /specifications, /api/evaluations,
and /build.  For /api/evaluations, use 'evaluation->json-object'.
* src/cuirass/utils.scm (object->json-scm): Add 'vector?' case.
* tests/http.scm (hash-table-keys, hash-table=?): Remove.
(evaluations-query-result): Use vectors for JSON arrays.
("object->json-string"): Expects alists instead of hash tables.
("/build/1"): Use 'lset=' instead of 'hash-table=?'.
("/api/latestbuilds?nr=1&jobset=guix"): Likewise, and expect alists
instead of hash tables.
("/api/latestbuilds?nr=1&jobset=gnu"): Likewise.
("/api/evaluations?nr=1"): Likewise.
* README: Mention Guile-JSON 3.x.
2019-08-17 18:48:34 +02:00
Ludovic Courtès 92bdf3cda0 http: Import (ice-9 format).
* src/cuirass/http.scm: Add missing include of (ice-9 format).
2019-08-17 16:53:07 +02:00
Ricardo Wurmus 219506d5f9
cuirass: Restore search query.
* src/cuirass/templates.scm (search-form): Take the query as an argument and
set it as the value (unless #F).
(html-page): Optionally take a value for QUERY as an argument.
* src/cuirass/http.scm (url-handler): Let "search" handler pass QUERY to
HTML-PAGE.
2019-06-19 15:38:01 +02:00
Ricardo Wurmus efe7d36e64
http: Show number of builds.
* src/cuirass/database.scm (db-get-evaluation-summary): New procedure.
* src/cuirass/http.scm (url-handler): Display number of builds in tabs.
2019-06-19 10:22:51 +02:00
Ricardo Wurmus a11f7a4779
cuirass: Remove tabs for canceled, dependency failed, and other failed.
All of them are included in "failed".

* src/cuirass/http.scm (url-handler): Remove extraneous tabs.
2019-06-19 09:58:17 +02:00
Ricardo Wurmus 831d73874b
cuirass: Adjust query for scheduled builds.
* src/cuirass/http.scm (url-handler): Use "pending" instead of "scheduled".
2019-06-19 09:56:06 +02:00
Ricardo Wurmus 372d47b326
cuirass: Display builds in separate tabs.
* src/cuirass/http.scm (url-handler): Split result for "eval" page in tabs.
* src/cuirass/templates.scm (build-eval-table): Remove border from table head;
Remove lead paragraph.
2019-06-19 09:38:08 +02:00
Ricardo Wurmus 11f888abb8
http: Fix navigation URL for build details page.
* src/cuirass/http.scm (url-handler): Use "jobset" instead of "spec".
2019-06-19 00:13:54 +02:00
Ricardo Wurmus 5070d17e7e
http: Handle /build/<id>/details URL.
* src/cuirass/http.scm (url-handler): Add handler for /build/<id>/details.
* src/cuirass/templates.scm (build-details): New procedure.
2019-06-18 23:59:53 +02:00
Ricardo Wurmus 74b8945f2b
http: Gracefully handle missing query.
* src/cuirass/http.scm (url-handler): Skip computation of builds-id-min and
builds-id-max when query is missing.
2019-05-21 11:38:15 +02:00