Commit Graph

198 Commits

Author SHA1 Message Date
Mathieu Othacehe 17e8759efe
Optimize Jobs table. 2021-04-14 15:05:00 +02:00
Mathieu Othacehe 7542d626dc
Add the evaluations absolute build summary.
* src/cuirass/database.scm (db-get-evaluations-absolute-summary): New
procedure.
* src/cuirass/http.scm (url-handler): Pass the evaluation absolute summary to
"evaluation-info-table".
* src/cuirass/templates.scm (evaluation-info-table): Adapt it.
* src/static/css/cuirass.css (job-abs): New section.
* tests/database.scm ("db-get-evaluations-absolute-summary"): New test.
2021-04-09 09:27:32 +02:00
Mathieu Othacehe d86c4edee7
Add specification period support.
* src/sql/upgrade-4.sql: New file.
* Makefile.am (dist_sql_DATA): Add it.
* src/schema.sql (Specifications)[period]: New field.
* src/cuirass/base.scm (process-specs): Honor the specification period.
* src/cuirass/database.scm (db-get-time-since-previous-build): Rename it into ...
(db-get-time-since-previous-eval): ... this new procedure.
* src/cuirass/specification.scm (<specification>)[period]: New field.
(specification->sexp, sexp->specification): Adapt accordingly.
* src/cuirass/templates.scm (specification-edit): Ditto.
* tests/database.scm ("db-get-time-since-previous-build"): Remame it into ...
("db-get-time-since-previous-eval"): ... this new procedure.
2021-04-08 15:37:43 +02:00
Mathieu Othacehe 245d0b5e5a
Add a jobs toggle button.
* src/cuirass/database.scm (db-get-specifications-summary): Return the latest
evaluation.
* src/cuirass/templates.scm (specifications-table): Add a monitor and a toggle
button.
2021-04-08 13:49:02 +02:00
Mathieu Othacehe 0ba0786741
Add specification job summary.
* src/cuirass/database.scm (db-get-specifications-summary): New procedure.
* tests/database.scm ("db-get-specifications-summary"): New test.
* src/cuirass/templates.scm (specifications-table): Add a summary argument.
* src/cuirass/http.scm (url-handler): Adapt it.
2021-04-08 11:56:37 +02:00
Mathieu Othacehe 2c3440de5c
Use the Build id as Jobs foreign key.
Join Build and Jobs tables using the build id instead of the build derivation
to speed queries.

* src/sql/upgrade-3.sql: New file.
* Makefile.am (dist_sql_DATA): Add it.
* src/schema.sql (Jobs)[derivation]: Replace it by ...
[build]: this new column.
* src/cuirass/database.scm (db-add-job, db-get-jobs): Adapt them.
2021-04-08 10:49:41 +02:00
Mathieu Othacehe 1b35a77856
Fix job insertion with existing outputs.
Different derivations may result in a same build output. If a job registers a
derivation D2 with the output O1, Cuirass may already have processed another
derivation D1 with the same O1 output.

In that case, the new job must point to the D1 derivation and not the D2
derivation, for which no build will be triggered.

* src/cuirass/database.scm (db-add-job): Fix it.
* tests/database.scm ("db-register-builds same-outputs", "db-get-jobs
same-outputs"): New tests.
2021-04-07 15:04:23 +02:00
Mathieu Othacehe bba1311478
Add jobs support.
Each evaluation registration produces a list of new jobs. Until now, only the
jobs which build outputs were not stored in the "Outputs" table were added to
the "Builds" table.

It means that Cuirass looses track of the job list associated to a given
evaluation.  This is problematic to provide the overall build status of an
evaluation or to find the evaluation providing the best build coverage.

Add a new "Jobs" table that stores the job list of each evaluation.  Also add
a new "/api/jobs" API to consult it.

* src/sql/upgrade-2.sql: New file.
* Makefile.am (dist_sql_DATA): Add it.
* src/schema.sql (Jobs): New table.
* src/cuirass/database.scm (db-add-job, db-get-jobs): New procedures.
(db-register-builds): Call db-add-job.
* src/cuirass/http.scm (url-handler): New "/api/jobs" route.
* tests/database.scm ("db-get-jobs", "db-get-jobs names"): New tests.
* doc/cuirass.texi (Web API, Database): Document it.
2021-04-06 15:18:55 +02:00
Mathieu Othacehe f5a2eeae18
Fix single checkout update.
When a new evaluation is triggered by a single channel update, the
matching specification can have other channels that are not updated. In that
case, "db-get-checkouts" will only return the checkout corresponding to the
channel update.

This cause "channel-instances->profile" to fail this way:

In guix/channels.scm:
   911:32  3 (channel-instances->derivation _)
   871:36  2 (channel-instances->manifest (#<<channel-instance> cha?>))
    759:6  1 (channel-instance-derivations (#<<channel-instance> ch?>))
In ice-9/boot-9.scm:
  1669:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1669:16: In procedure raise-exception:
ERROR:
  1. &message: "'guix' channel is lacking"
  2. &fix-hint: "Make sure your list of channels\ncontains one channel named @code{guix} providing the core of Guix."
  3. &error-location: #<<location> file: "guix/channels.scm" line: 557 column: 18>

Introduce a db-get-latest-checkout procedure that returns the last checkout of
a given channel. Use it to request the checkouts of all the channels before
creating the profile.

* src/cuirass/database.scm (db-get-latest-checkout): New procedure.
* tests/database.scm ("db-get-latest-checkout"): New test.
* src/cuirass/scripts/evaluate.scm (latest-checkouts): New procedure.
(cuirass-evaluate): Use it.
2021-03-25 17:42:09 +01:00
Mathieu Othacehe 2efa062a4a
Update copyrights. 2021-03-22 18:31:41 +01:00
Mathieu Othacehe 659e7479e5
Fix workers status page. 2021-03-12 17:33:29 +01:00
Mathieu Othacehe 6438742f99
Improve worker status page queries. 2021-03-12 17:07:52 +01:00
Mathieu Othacehe 82b8f825d8
Turn db-add-specification into db-add-or-update-specification. 2021-03-11 19:30:58 +01:00
Mathieu Othacehe e3c95014e3
database: Limit notifications to new failures and new successes. 2021-03-11 17:36:24 +01:00
Mathieu Othacehe aabeced62a
Send notifications in a separate thread. 2021-03-11 10:27:13 +01:00
Mathieu Othacehe e598f89445
Remove events support. 2021-03-11 10:26:36 +01:00
Mathieu Othacehe 9e3e9b691c
Use our own sexp->channel procedure.
The Guix version of sexp->channel doesn't support the branch field.

* src/cuirass/specification.scm (sexp->channel): New procedure.
* src/cuirass/database.scm (db-get-specifications): Use it.
2021-03-10 16:30:28 +01:00
Mathieu Othacehe d116dc36c3
database: Add db-cancel-pending-builds!.
* src/cuirass/database.scm (db-cancel-pending-builds!): New procedure.
* tests/database.scm ("db-cancel-pending-builds!"): New test.
2021-03-09 18:45:47 +01:00
Mathieu Othacehe 70394149af
database: Add db-retry-evaluation!.
* src/cuirass/database.scm (db-retry-evaluation!): New procedure.
* tests/database.scm ("db-retry-evaluation"): New test.
2021-03-09 18:31:18 +01:00
Mathieu Othacehe 265b134527
Save the default database.
* src/cuirass/database.scm (db-open): Save the default database in the
%package-database parameter.
2021-03-09 11:52:33 +01:00
Mathieu Othacehe 370ff7d8cd
Use default database parameters.
* src/cuirass/parameters.scm (%cuirass-database, %cuirass-host): New
parameters.
* src/cuirass/database.scm (db-open): Use them.
2021-03-09 07:37:29 +01:00
Mathieu Othacehe 37de70546b
Reset build timestamps on restart.
* src/cuirass/database.scm (db-restart-build!, db-restart-evaluation!): Reset
starttime and stoptime field.
2021-03-08 07:51:06 +01:00
Mathieu Othacehe 325edf2ffa
Rewrite evaluation. 2021-03-05 09:08:15 +01:00
Mathieu Othacehe f5287dc11e
Add with-transaction.
* src/cuirass/database.scm (with-transaction): New macro.
2021-03-03 08:39:02 +01:00
Mathieu Othacehe 30b6dbb293
database: Ignore duplicated BuildProducts.
* src/cuirass/database.scm (db-add-build-product): Ignore duplicated
BuildProducts.
2021-02-25 09:13:47 +01:00
Mathieu Othacehe 0b19e82adc
Restart the builds on unresponsive workers.
* src/cuirass/database.scm (db-remove-unresponsive-workers): Restart the
builds that are started on unresponsive workers.
* tests/database.scm ("db-remove-unresponsive-workers"): Test it.
2021-02-24 12:42:29 +01:00
Mathieu Othacehe 3e65617409
Fix db-get-specifications.
* src/schema.sql: Reorder fields.
* src/cuirass/database.scm (db-get-specifications): Ditto.
2021-02-22 11:12:00 +01:00
Mathieu Othacehe a0e12c382b
Make notifications field optional.
* src/cuirass/database.scm (db-add-specification): Make notifications field
optional.
2021-02-22 10:07:57 +01:00
Mathieu Othacehe 4495e08542
Add notifications support.
* src/cuirass/mail.scm: New file.
* src/cuirass/notification.scm: New file.
* src/sql/upgrade-5.sql: New file.
* Makefile.am (dist_pkgmodule_DATA, dist_sql_DATA): Add them.
* src/schema.sql (Specifications)[notifications]: New field.
* bin/cuirass.in: Wrap inside the "with-notification" macro.
* src/cuirass/remote-server.scm (remote-server): Ditto.
* src/cuirass/database.scm (db-add-specification): Add notifications field.
(db-get-specifications): Ditto.
(db-update-build-status!): Send notifications.
* tests/mail.sh: New file.
* tests/database.scm (mu-debug, tmp-mail): New variables.
(mailer): New procedure.
(example-spec): Add an email notification.
("mail-notification"): New test case.
2021-02-21 09:55:41 +01:00
Mathieu Othacehe 4a0cea2245
database: Add "db-restart-evaluation!" support.
* src/cuirass/database.scm (db-restart-evaluation!): New procedure.
* tests/database.scm (db-restart-evaluation!): New test.
2021-02-18 15:12:54 +01:00
Mathieu Othacehe 31342ff80f
database: Add db-restart-build! support.
* src/cuirass/database.scm (db-restart-build!): New procedure.
* tests/database.scm (db-restart-build!): New test.
2021-02-17 19:11:38 +01:00
Mathieu Othacehe a5f0a5f04d
Remove outdated commentary.
* src/cuirass/database.scm (db-register-builds): Remove commentary.
2021-02-14 15:32:49 +01:00
Mathieu Othacehe e77a0a94fe
database: Fix db-get-build-percentage query.
* src/cuirass/database.scm (db-get-build-percentage): Consider both successful
and failing builds.
2021-02-10 18:23:41 +01:00
Mathieu Othacehe 7aa1d9156a
Return worker last-seen field as integer.
* src/cuirass/database.scm (db-get-worker, db-get-workers): Return last-seen
field as integer.
2021-02-07 18:16:57 +01:00
Mathieu Othacehe 485ed9182b
Fix weather query.
* src/cuirass/database.scm (db-get-builds): Add missing parens.
2021-02-02 14:48:36 +01:00
Mathieu Othacehe 8bdc7ee535
Fix weather value.
* src/cuirass/database.scm (db-get-builds): Fix weather value.
* tests/http.scm (build-query-result): Adapt it.
2021-02-02 14:29:16 +01:00
Mathieu Othacehe 4f4d7ff7db
Move weather field to database.
* src/sql/upgrade-4.sql: New file.
* Makefile.am (dist_sql_DATA): Add it.
* src/schema.sql (Builds)[weather]: New field.
(Builds_weather_evaluation): New index.
* src/cuirass/database.scm (db-get-last-status): New procedure.
(db-update-build-status!): Use it and update the new weather field.
(db-get-builds): Adapt it.
* tests/http.scm (build-query-result): Ditto.
2021-02-02 11:56:28 +01:00
Mathieu Othacehe a57b066e4f
Add build history support.
* src/cuirass/database.scm (db-get-builds): Add "oldevaluation" filter.
* src/cuirass/templates.scm (build-details): Add "history" argument.
* src/cuirass/http.scm (url-handler): Adapt it.
2021-02-01 17:49:00 +01:00
Mathieu Othacehe d7282c05c0
Add build weather support.
* src/cuirass/database.scm (build-weather): New macro.
(build-status->weather): New procedure.
(db-get-builds): Return the build weather using the new procedure.
* src/cuirass/http.scm (build->hydra-build): Also return the weather.
* src/cuirass/templates.scm (weather-class, weather-title): New procedures.
(build-eval-table): Display the weather.
* tests/database.scm ("db-get-build weather"): New tests.
* tests/http.scm (build-query-result): Adapt it.
2021-02-01 14:27:24 +01:00
Mathieu Othacehe 54244e6e97
database: Fix "db-update-build-status!".
* src/cuirass/database.scm (db-update-build-status): Only consider evaluations
that happened before the current one. This is useful when updating the build
status of old evaluations.
2021-02-01 12:30:38 +01:00
Mathieu Othacehe 7697735fce
database: Fix "db-get-worker".
* src/cuirass/database.scm (db-get-worker): Handle the case where no worker
were found.
2021-02-01 12:22:56 +01:00
Mathieu Othacehe 74c1a94a4d
Introduce build "last_status" field.
* src/sql/upgrade-3.sql: New file.
* Makefile.am (dist_sql_DATA): Add it.
* src/schema.sql (Builds)[last_status]: New field.
* src/cuirass/database.scm (db-update-build-status!): Honor it.
(db-get-builds): Return it.
* tests/database.scm ("db-update-build-status!"): New test.
2021-02-01 11:45:10 +01:00
Mathieu Othacehe 158966dca0
Fix /api/latestbuilds ordering.
Evaluations are added sequentially to database but builds are not always
registered nor performed in order. This means that a build corresponding to an
older evaluation can be returned first if it was completed last. Order by
descending evaluation id to prevent it.

* src/cuirass/database.scm (db-get-builds): Add "evaluation" order.
* src/cuirass/http.scm (url-handler): Order latestbuilds by descending
evaluation number.
2021-01-31 21:09:17 +01:00
Mathieu Othacehe e9e0943945
Remove workers hash table.
* src/cuirass/database.scm (db-add-worker): Rename ...
(db-add-or-update-worker): ... into this new procedure.
(db-get-worker, db-remove-unresponsive-workers): New procedures.
* src/cuirass/remote-server.scm (%workers): Remove it.
(pop-build): Adapt it.
(remove-unresponsive-workers!): Remove it.
(read-worker-exp): Adapt it.
(zmq-start-proxy): Ditto.
* tests/database.scm ("db-add-worker"): Rename ...
("db-add-or-update-worker"): ... into this new test.
("db-get-worker", "db-remove-unresponsive-workers"): New tests.
2021-01-31 10:31:01 +01:00
Mathieu Othacehe 6838ec2eac
database: Prevent division by zero.
* src/cuirass/database.scm (db-get-build-percentage): Prevent division by zero.
2021-01-30 16:14:04 +01:00
Mathieu Othacehe 154653b4c8
database: Fix starttime update.
* src/cuirass/database.scm (db-update-build-status!): Set starttime when the
build status is "submitted".
2021-01-30 16:10:50 +01:00
Mathieu Othacehe 213683ad27
database: Add "db-get-build-percentage".
* src/cuirass/database.scm (db-get-build-percentage): New procedure.
* tests/database.scm ("db-get-build-percentage"): New test.
2021-01-30 14:23:29 +01:00
Mathieu Othacehe 1271b11725
Add machine field to Worker table.
* src/sql/upgrade-2.sql: New file.
* Makefile.am (dist_sql_DATA): Add it.
* src/schema.sql (Workers): Add "machine field".
* src/cuirass/database.scm (db-get-builds): Return "worker" field.
(db-add-worker): Honor new "machine" field.
(db-get-workers): Ditto.
* src/cuirass/remote-worker.scm (remote-worker): Adapt it.
* src/cuirass/remote.scm (<worker>)[machine]: New field.
(worker-machine): New procedure.
(worker->sexp, sexp->worker): Adapt accordingly.
(generate-worker-name): Ditto.
* tests/database.scm (%dummy-worker): Add "machine" field.
2021-01-30 14:18:59 +01:00
Mathieu Othacehe dea5707750
database: Fix search pagination.
* src/cuirass/database.scm (db-get-builds-by-search): Fix pagination.
2021-01-17 19:47:54 +01:00
Mathieu Othacehe e61e7a5ca4
Fix tests.
* tests/database.scm (db-init): Force database creation.
* tests/http.scm (db-init): Ditto.
* tests/metrics (db-init): Ditto.
2021-01-17 12:05:31 +01:00