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

115 commits

Author SHA1 Message Date
Ludovic Courtès
9c96852c60 base: Extract 'read/non-blocking'.
* src/cuirass/base.scm (read/non-blocking): New procedure.
(evaluate): Use it instead of inline code.
2018-01-25 09:47:48 +01:00
Ludovic Courtès
8675d6309b database: 'db-update-build-status!' takes a #:log-file parameter.
* src/cuirass/database.scm (sqlite-exec): Use (ice-9 format).
(db-update-build-status!): Add #:log-file parameter and honor it.
* tests/database.scm ("database")["db-update-build-status!"]: Test it.
2018-01-24 23:41:24 +01:00
Ludovic Courtès
1d7f4f07d9 base: Be more verbose about restarted builds.
* src/cuirass/base.scm (handle-build-event): Remove unused 'log-port'
parameter.
(restart-builds): Wrap 'build-derivations' in 'guard'.  Add
'log-message' calls.
2018-01-24 14:09:28 +01:00
Ludovic Courtès
b349678589 ui: Bump copyright year in '--version' output.
* src/cuirass/ui.scm (show-version): Update year.
2018-01-24 14:02:53 +01:00
Ludovic Courtès
c89c117c12 http: /build: Include the derivation.
* src/cuirass/http.scm (build->hydra-build): Add #:derivation.
2018-01-24 14:01:45 +01:00
Ludovic Courtès
c62bb26e81 base: Populate the 'Outputs' table.
Fixes a regression introduced in
d7306a4f48 whereby 'register' would pass
the empty list as #:outputs to 'db-add-build'.

* src/cuirass/base.scm (build-packages)[register]: Always include
outputs.
2018-01-24 14:00:11 +01:00
Ludovic Courtès
74f3abfba3 http: /build: Gracefully handle empty output list.
* src/cuirass/http.scm (url-handler): Add case for empty #:outputs.
2018-01-24 13:59:28 +01:00
Ludovic Courtès
4306667a49 base: Always set 'keep-going' when opening the store.
Previously 'restart-builds' would lack it, for instance.

* src/cuirass/base.scm (process-specs): Move 'set-build-options' call
to...
(with-store): ... here.
2018-01-23 23:53:41 +01:00
Ludovic Courtès
d544f3e6ba cuirass: Fix scope mismatch.
Previously STORE would be closed on the first context switch, before
'restart-builds' has completed, leading to an error (writing to a closed
port).

* src/cuirass/base.scm (restart-builds): Remove 'store' parameter.  Wrap
body in 'with-store'.
* bin/cuirass.in (main): Adjust accordingly.
2018-01-23 23:45:24 +01:00
Ludovic Courtès
496b624dda http: Implement /api/queue.
* src/cuirass/http.scm (url-handler): Add /api/queue handler.
* tests/http.scm ("http"): Add a BUILD2 and DERIVATION2, and rename
BUILD and DERIVATION accordingly.
("/build/2", "/build/2/log/raw"): Rename to /42.
("/api/queue?nr=100"): New test.
2018-01-23 23:40:07 +01:00
Ludovic Courtès
dd30a1a25c base: Restart pending builds upfront.
* src/cuirass/database.scm (db-get-builds)[format-where-clause]:
Honor (status pending) filter.
* src/cuirass/base.scm (restart-builds): New procedure.
* bin/cuirass.in (main): Fetch pending builds.  Start fiber that invokes
'restart-builds' on them.
2018-01-23 23:40:07 +01:00
Ludovic Courtès
06b8af00fb http: /api/latestbuilds only returns finished builds.
* src/cuirass/database.scm (db-get-builds)[format-where-clause]:
Honor (status done) filter.
* src/cuirass/http.scm (url-handler): Always add (status done)
to the filters passed to 'handle-builds-request'.
2018-01-23 23:39:13 +01:00
Ludovic Courtès
6fb7118839 database: Use US spelling for "canceled".
* src/cuirass/database.scm (build-status): Use US spelling for
"canceled".
2018-01-23 23:39:13 +01:00
Ludovic Courtès
fdf47d6df3 base: Add missing argument.
* src/cuirass/base.scm (build-packages): In 'filter-map' call, add
missing argument to 'db-get-build'.
2018-01-23 22:22:22 +01:00
Ludovic Courtès
f1b3a12c1d base: Use 'log-message' some more.
* src/cuirass/base.scm (build-packages): Use 'log-message' instead of
'format'.
2018-01-23 18:31:35 +01:00
Ludovic Courtès
d7306a4f48 base: Update build status and start/stop time according to build log.
Now the database is updated as things are built, rather than after the
whole batch of derivation builds has completed.

* src/cuirass/base.scm (handle-build-event): Call
'db-update-build-status!'.
(build-packages)[register]: Set #:starttime and #:stoptime to 0.
Set #:status to 'scheduled'.
Define 'build-ids' and use it to determine the overall result.
2018-01-23 18:29:38 +01:00
Ludovic Courtès
fe0a98315d database: Add 'db-update-build-status!'.
* src/cuirass/database.scm (build-status): Add 'scheduled' and
'started'.
(db-add-build): Make sure #:timestamp, #:starttime, #:stoptime, and
 #:status are integers.
(db-update-build-status!): New procedure.
* tests/database.scm ("database")["db-update-build-status!"]: New test.
2018-01-23 18:17:31 +01:00
Ludovic Courtès
b0f1a438ff Add a 'build-status' enumeration.
* src/cuirass/utils.scm (define-enumeration): New macro.
* src/cuirass/database.scm (build-status): New macro.
* src/cuirass/base.scm (build-packages)[hydra-build-status]: Remove.
Use the 'build-status' macro instead.
2018-01-23 17:37:08 +01:00
Ludovic Courtès
f92ad7001f Fix scope mismatch.
* src/cuirass/base.scm (process-specs): Add new 'with-database' within
the fiber.
2018-01-23 09:31:11 +01:00
Ludovic Courtès
ee11ba1d93 Introduce concurrency with Fibers.
* README: Mark Fibers as required.
* configure.ac: Check for Guile 2.2 only.  Check for (fibers).
* bin/cuirass.in (main): Use (fibers).  Run 'process-specs' and web
server in separate fibers.
* src/cuirass/base.scm (with-store): New macro.
(non-blocking-port): New procedure.
(evaluate): Use 'non-blocking-port'.  Use 'read-string' followed by 'read'.
(process-specs): Move 'db-add-stamp' right after 'string=?' comparison.
Run evaluation and subsequent builds in a separate fiber.
* src/cuirass/http.scm (run-cuirass-server): Pass 'fibers as the second
argument to 'run-server'.  Use 'log-message' instead of 'format'.
* src/cuirass/database.scm (with-database): Remove 'dynamic-wind'.
2018-01-22 23:39:51 +01:00
Ludovic Courtès
f9481e2222 database: Change default file name to /var/run/cuirass/cuirass.db.
* src/cuirass/database.scm (%package-database): Change default file name
from /var/cuirass.db (or similar) to /var/run/cuirass/cuirass.db.
2018-01-22 14:51:14 +01:00
Ludovic Courtès
0d3225a08b Improve build event logging.
* src/cuirass/base.scm (handle-build-event): Add 'build-failed'; shorten
message for 'build-remote'.
2018-01-22 14:50:43 +01:00
Ludovic Courtès
47cd2d7470 Log activity of the main loop.
* src/cuirass/base.scm (process-specs): Add 'log-message' calls.
2018-01-22 13:30:03 +01:00
Ludovic Courtès
70f21349bd Add (cuirass logging) module.
* src/cuirass/logging.scm: New file.
* Makefile.am (dist_pkgmodule_DATA): Add it.
* src/cuirass/base.scm (handle-build-event): Use 'log-message' instead
of 'log'.
2018-01-22 13:29:55 +01:00
Ludovic Courtès
327d7be013 Initialize libgit's TLS certificate directory once and for all.
* src/cuirass/base.scm (prepare-git): New procedure.  Body moved from...
(process-specs): ... here.  Remove it.
* bin/cuirass.in (main): Call 'prepare-git'.
2018-01-22 13:16:10 +01:00
Ludovic Courtès
1f701262e1 Monitor and report build events.
* src/cuirass/base.scm (%newline): New variable.
(build-event-output-port, handle-build-event): New procedures.
(build-packages): Use 'handle-build-event'.
2018-01-22 10:11:37 +01:00
Ludovic Courtès
9588e4d4a7 http: /build/N/log/raw redirects to /log.
This moves log handling responsibility to 'guix publish'.

* src/cuirass/http.scm (handle-log-request): Remove.
(url-handler): Change /log/raw URI handler to return 302 to /log/OUTPUT.
* tests/http.scm (log-file-name): Remove, and remove code to create and
delete it.
("fill-db"): Change #:log value.
("/build/1/log/raw"): Expect 302.
2018-01-07 23:59:30 +01:00
Ludovic Courtès
60b6c6fcc5 database: Extend and test 'db-get-builds'.
* src/cuirass/database.scm (db-get-builds): Make 'order' a separate
filter.  Add 'format-limit-clause'.  Reverse OUTPUTS.
* tests/database.scm (make-dummy-eval, make-dummy-derivation)
(make-dummy-build): New procedures.
(with-temporary-database): New macro.
("database"): Use 'make-dummy-build'.
("db-get-builds"): New test.
2018-01-07 23:59:30 +01:00
Ludovic Courtès
9cfea9fe2e Do not mistakenly use 'GIT_SSL_CAINFO' as a directory name.
'GIT_SSL_CAINFO' designates a single-file certificate bundle, not a
directory; thus it must be passed as the second argument to
'set-tls-certificate-locations!'.

* src/cuirass/base.scm (process-specs): Pass $SSL_CERT_DIR as the first
argument to 'set-tls-certificate-locations!', and $GIT_SSL_CAINFO or
$SSL_CERT_FILE as the second argument.
2017-09-29 09:46:23 +02:00
Jan Nieuwenhuizen
2a4d493e28
cuirass: Add --listen command line option.
* bin/cuirass.in (show-help): Add help for --listen option.
(%options): Add listen option.
(main): Pass host to run-cuirass-server.
* doc/cuirass.texi (Invocation): Add --listen option.
* src/cuirass/http.scm (run-cuirass-server): Add named #:host parameter.
2017-09-18 21:57:05 +02:00
Jan Nieuwenhuizen
87ad259dba
base: Show feedback when build has finished.
* src/cuirass/base.scm (build-packages): Print some feedback when derivations
have been built.
2017-09-17 21:53:12 +02:00
Jan Nieuwenhuizen
88363faa83
base: Make working copy writable.
* src/cuirass/base.scm (copy-repository-cache): Make working copy writable.
Fixes guix .po build errors.
2017-09-17 21:47:28 +02:00
Mathieu Othacehe
8a7483a3bb
cuirass: add Hydra compatible HTTP API.
* doc/cuirass.texi (Sections)[Web API]: New section describing the HTTP API.
* src/cuirass/http.scm (spec->json-string): Move it to utils.scm and rename it
  object->json-string.
(object->json-scm): Move it utils.scm.
(handle-*-request): New helpers procedures.
(request-parameters): New procedure to parse a request query.
(url-handler): Add new API's.
* src/cuirass/utils.scm (object->json-scm, object->json-string): Exported
procedures moved from http.scm.
* tests/http.scm: Add various tests on new HTTP API.
2017-09-08 21:15:32 +02:00
Mathieu Othacehe
e550cb6a9a
cuirass: Store new information in database to prepare new HTTP API
integration.

* bin/evaluate.in (fill-job): New procedure.
(main): Use it to fill informations (nix-name, system) that will later be
added to database.
* doc/cuirass.texi (Database)[Derivation]: Add system and nix_name fields.
(Database)[Builds]: Add id, status, timestamp, starttime and stoptime
fields. Remove output field.
(Database)[Outputs]: New table describing the build outputs.
* src/cuirass/base.scm (build-packages): Add new fields to build object before
adding it to database.
* src/cuirass/database.scm (db-get-build, db-get-builds): New procedures to get
a build by id from database and a list of builds using filter parameters
respectively.
* src/schema.sql (Outputs) : New table.
(Derivations): Add system and nix_name columns.
(Builds): Remove output column and add id, status, timestamp, starttime and
stoptime columns.
2017-09-08 21:00:57 +02:00
Ricardo Wurmus
cf96567db7
base: Set certificate location.
* src/cuirass/base.scm (process-specs): Set certificate location to the value
in GIT_SSL_CAINFO or SSL_CERT_DIR.
2017-08-26 13:57:26 +02:00
Ludovic Courtès
72f2b6b77c database: 'db-add-build' is now idempotent.
Fixes <https://bugs.gnu.org/28094>.
Reported by Ricardo Wurmus <rekado@elephly.net>.

* src/cuirass/database.scm (SQLITE_CONSTRAINT)
(SQLITE_CONSTRAINT_PRIMARYKEY): New variables.
(db-add-build): Catch 'sqlite-error, and swallow
SQLITE_CONSTRAINT_PRIMARYKEY errors.
* tests/database.scm ("db-add-build"): New test.
2017-08-26 10:45:43 +02:00
Mathieu Othacehe
6f85bc04f3
cuirass: Fix Guile current-processor-count deprecation warnings.
When current-processor-count is used without (ice-9 threads) being used, Guile
complains with the following warning:

Import (ice-9 threads) to have access to `current-processor-count'.

* src/cuirass/base.scm: Use (ice-9 threads).
2017-08-02 15:34:54 +02:00
Mathieu Othacehe
a919c25328
base: Report git errors.
* src/cuirass/base.scm (report-git-error): New procedure.
(with-git-error-handling): New macro.
(process-specs): Use with-git-error-handling to catch and report git errors.
* build-aux/guix.scm (package)[inputs]: Add guile-git.
* configure.ac: Check for (git) module. Also check that (git) exports
git-error-message procedure.
2017-07-31 15:46:50 +02:00
Mathieu Othacehe
c6ee3d9b1a
base: Report evaluation error.
* src/cuirass/base.scm (&evaluation-error): New condition type.
(evaluate): Report an &evaluation-error if eof-object? is true on
data read from port. Otherwise, suppose that data are correct and keep things
going.
(process-specs): Catch &evaluation-error, report the error in the log and keep
going.
2017-07-30 12:35:56 +02:00
Mathieu Othacehe
efcef52883
cuirass: Add fallback parameter.
* src/cuirass/base.scm (%fallback?): New exported parameter.
(process-specs)[set-build-options]: Pass fallback parameter.
* bin/cuirass.in (%options): Add fallback.
(main): Set %fallback? parameter.
(show-help): Update.
2017-07-12 16:28:41 +02:00
Mathieu Othacehe
707b053024
database: Fix typo.
* src/cuirass/database.scm (db-get-stamp, db-add-stamp): Replace #:id
  by #:name. There is no #:id in specifications. Plus, the primary key
  of Specifications is #:name.
2017-07-12 16:28:41 +02:00
Mathieu Othacehe
56ac3e24ac
base: Fix time-monotonic Guile issue.
* src/cuirass/base.scm: Replace time-monotonic with time-tai with
  Guile 2.2, to avoid wrong evaluation durations.
2017-07-12 16:28:41 +02:00
Mathieu Othacehe
d7dc7cb92c
cuirass: Stop λ/lambda mixing.
* bin/cuirass.in: Replace λ by lambda.
* bin/evaluate.in: Ditto.
* build-aux/guix.scm: Ditto.
* examples/gnu-system.scm: Ditto.
* examples/guix-track-git.scm: Ditto.
* src/cuirass.scm: Ditto.
* src/cuirass/base.scm: Ditto.
* src/cuirass/database.scm: Ditto.
* src/cuirass/ui.scm: Ditto.
* src/cuirass/utils.scm: Remove λ* macro.
2017-07-06 10:03:16 +02:00
Mathieu Othacehe
4666142ca5
repo: Remove dead code.
* Makefile.am (dist_pkgmodule_DATA): Remove repo.scm,
(TESTS): Remove repo.scm.
* build-aux/guix.scm (package)[disable-repo-tests]: Remove phase.
* src/cuirass/repo.scm: Remove.
* tests/repo.scm: Remove.
2017-07-06 09:20:52 +02:00
Mathieu Othacehe
1b79b7bf6e
base: Use (guix git) module.
* src/cuirass/base.scm (copy-repository-cache) : New procedure.
(fetch-repository): Use latest-repository-commit to fetch git
repository instead of raw git system commands.
(process-specs): Use fetch-repository to get a store directory
containing the repository described in SPEC, add copy it to cache with
"copy-repository-cache".
* configure.ac: Check (guix git) module presence.
2017-07-05 13:52:18 +02:00
Mathieu Othacehe
f301378d94
utils: Remove useless procedures.
* src/cuirass/utils.scm (mkdir-p, make-user-module,
  call-with-temporary-directory, with-directory-excursion): Remove because
  already defined in guix.
* tests/utils (with-directory-excursion): Remove associated test.
* src/cuirass/base.scm: Use (guix build utils) to provide procedure removed
  from (cuirass utils).
* bin/evaluate.in: Ditto.
* bin/cuirass.in: Use "make-user-module" provided by (guix ui).
2017-07-01 18:47:18 +02:00
Mathieu Othacehe
706c80c6a0
repo: remove git-repo.
* src/cuirass/repo.scm (git-repo): Remove it.
* tests/repo.scm: Remove related tests.

git-repo is not used and it's usecases will be covered by (guix git).
2017-07-01 18:47:18 +02:00
Ludovic Courtès
7f8029d33c base: Send build output to the bit bucket.
Fixes a regression introduced in
a42cf16fec whereby build logs would go the
Cuirass' stderr.

* src/cuirass/base.scm (build-packages): Parameterize
'current-build-output-port' to a void output port.
2017-06-04 22:13:16 +02:00
Ludovic Courtès
a42cf16fec
base: Provide 'build-derivations' with the full list of derivations.
This improves parallelism when 'max-jobs' is large.

* src/cuirass/base.scm (build-packages): Rewrite to pass the complete
list of derivations to 'build-derivations' at once.  Handle multiple outputs.
* src/schema.sql (Builds): Make "output" part of the primary key.

Co-authored-by: Mathieu Lirzin <mthl@gnu.org>
2017-02-24 19:33:41 +01:00
Ludovic Courtès
8c811abb31
base: Remove unnecessary 'file-exists?' call.
* src/cuirass/base.scm (fetch-repository): Remove 'file-exists?' call
before 'mkdir-p'.
2017-02-24 19:32:22 +01:00