summaryrefslogtreecommitdiff
path: root/src/cuirass/utils.scm
Commit message (Collapse)AuthorAge
* Switch to Guile-JSON 3.x.Ludovic Courtès2019-08-17
| | | | | | | | | | | | | | | | | | | | | | | 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.
* database: Serialize all database accesses in a thread.Clément Lassieur2018-08-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes <https://bugs.gnu.org/32234>. * bin/cuirass.in (main): Keep only one WITH-DATABASE call around all fibers. Remove all DB arguments. * src/cuirass/base.scm (evaluate, update-build-statuses!, spawn-builds, handle-build-event, build-packages): Remove all DB arguments. (clear-build-queue, cancel-old-builds): Wrap in WITH-DB-CRITICAL-SECTION, remove all DB arguments. (restart-builds): Remove the NON-BLOCKING call, remove all DB arguments. (process-specs): Remove all DB arguments, remove the WITH-DATABASE call. * src/cuirass/database.scm (%db-channel): New parameter. (with-db-critical-section): New macro. (db-add-input, db-add-specification, db-get-inputs, db-get-specifications, db-add-evaluation, db-add-build, db-update-build-status!, db-get-outputs, db-get-builds, db-get-build, db-get-pending-derivations, db-get-stamp, db-add-stamp, db-get-evaluations, db-get-evaluations-build-summary, db-get-evaluations-id-min, db-get-evaluations-id-max, db-get-builds-min, db-get-builds-max): Wrap in WITH-DB-CRITICAL-SECTION, remove all DB arguments. (with-database): Wrap BODY in PARAMETERIZE form that sets %DB-CHANNEL to the channel returned by MAKE-CRITICAL-SECTION. * src/cuirass/http.scm (handle-build-request, handle-builds-request): Remove all DB arguments. (url-handler): Remove all DB arguments, remove the DB-CHANNEL state, remove the WITH-CRITICAL-SECTION calls. (run-cuirass-server): Remove the DB arguments, remove the MAKE-CRITICAL-SECTION call. * src/cuirass/utils.scm (make-critical-section): Replace SPAWN-FIBER with CALL-WITH-NEW-THREAD. Wrap body in PARAMETERIZE form that clears CURRENT-FIBER. * tests/database.scm (with-temporary-database, "db-add-specification", "db-add-build", "db-update-build-status!", "db-get-builds", "db-get-pending-derivations"): Remove the DB arguments. ("db-init"): Set the %DB-CHANNEL parameter to the channel returned by MAKE-CRITICAL-SECTION, and return #t. ("database"): Set %DB-CHANNEL to #f during cleanup. * tests/http.scm ("db-init"): Set the %DB-CHANNEL parameter to the channel returned by MAKE-CRITICAL-SECTION, and return #t. ("cuirass-run", "fill-db"): Remove the DB arguments. ("http"): Set %DB-CHANNEL to #f during cleanup.
* utils: Avoid deadlock when WITH-CRITICAL-SECTION calls are nested.Clément Lassieur2018-08-16
| | | | | | | | | | * src/cuirass/utils.scm (%critical-section-args): New parameter. (make-critical-section): Put ARGS into a parameter, so that CALL-WITH-CRITICAL-SECTION knows when it's called from the critical section. In that case it would just apply PROC to ARGS. (call-with-critical-section): If already in the critical section, apply PROC to %CRITICAL-SECTION-ARGS instead of sending the message through the critical section channel.
* utils: Prevent critical section clients to talk to each other.Clément Lassieur2018-07-27
| | | | | | | | | * src/cuirass/utils.scm (make-critical-section): Put the modified message to the REPLY channel that was part of the initial message. (call-with-critical-section): Create a REPLY channel, add it to the sent message, get the modified message from that channel. Co-authored-by: Ludovic Courtès <ludo@gnu.org>
* Add support for multiple inputs.Clément Lassieur2018-07-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Makefile.am (dist_sql_DATA): Add src/sql/upgrade-1.sql. * bin/cuirass.in (show-help, %options, main): Remove the LOAD-PATH option that was used afterwards as %GUIX-PACKAGE-PATH. * bin/evaluate.in (absolutize, input-checkout, spec-source, spec-load-path, spec-package-path, format-checkouts): New procedures. (%not-colon): Remove variable. (main): Take the load path, package path and PROC from the checkouts that result from the inputs. Format the checkouts before sending them to the procedure. Remove the LOAD-PATH argument. * doc/cuirass.texi (Overview, Database schema): Document the changes. * examples/{guix-jobs.scm, hello-git.scm, hello-singleton.scm, hello-subset.scm, random.scm}: Adapt to the new specification format. * examples/guix-track-git.scm (package->spec): Rename to PACKAGE->INPUT. (package->git-tracked): Replace FETCH-REPOSITORY with FETCH-INPUT and handle the new format of its return value. * examples/random-jobs.scm (make-random-jobs): Rename RANDOM to CHECKOUT. Rename the checkout from 'random (which is a specification) to 'cuirass (which is a checkout resulting from an input). * src/cuirass/base.scm (fetch-repository): Rename to fetch-input. Rename SPEC to INPUT. Return a checkout object instead of returning two values. (evaluate): Take a list of CHECKOUTS and COMMITS as arguments, instead of SOURCE. Remove TOKENIZE and LOAD-PATH. Pass the CHECKOUTS instead of the SOURCE to "evaluate". Remove %GUIX-PACKAGE-PATH. Build the EVAL object instead of getting it from "evaluate". (compile?, fetch-inputs, compile-checkouts): New procedures. (process-specs): Fetch all inputs instead of only fetching one repository. The result of that fetching operation is a list of CHECKOUTS whose COMMITS are used as a STAMP. (%guix-package-path, set-guix-package-path): Remove them. * src/cuirass/database.scm (db-add-input, db-get-inputs): New procedures. (db-add-specification, db-get-specifications): Adapt to the new specification format. Add/get all inputs as well. (db-add-evaluation): Rename REVISION to COMMITS. Store COMMITS as space separated commit hashes. (db-get-builds): Rename REPO_NAME to NAME. (db-get-stamp): Rename COMMIT to STAMP. Return #f when there is no STAMP. (db-add-stamp): Rename COMMIT to STAMP. Deal with DB-GET-STAMP's new return value. (db-get-evaluations): Rename REVISION to COMMITS. Tokenize COMMITS. * src/cuirass/utils.scm (%non-blocking): Export it. * src/schema.sql (Inputs): New table that refers to the Specifications table. (Specifications): Move input related fields to the Inputs table. Rename REPO_NAME to NAME. Rename ARGUMENTS to PROC_ARGS. Rename FILE to PROC_FILE. Add LOAD_PATH_INPUTS, PACKAGE_PATH_INPUTS and PROC_INPUT fields that refer to the Inputs table. (Stamps): Rename REPO_NAME to NAME. (Evaluations): Rename REPO_NAME to NAME. Rename REVISION to COMMITS. (Specifications_index): Replace with Inputs_index. * src/sql/upgrade-1.sql: New file. * tests/database.scm (example-spec, make-dummy-eval, sqlite-exec): Adapt to the new specifications format. Rename REVISION to COMMITS. * tests/http.scm (evaluations-query-result, fill-db): Idem.
* utils: Reset the Fiber dynamic environment in %NON-BLOCKING.Clément Lassieur2018-07-14
| | | | | | | | * src/cuirass/utils.scm (%non-blocking): Wrap body in PARAMETERIZE form that clears CURRENT-FIBER. So that PUT-MESSAGE doesn't try to suspend itself within CALL-WITH-NEW-THREAD. See https://lists.gnu.org/archive/html/guile-devel/2018-07/msg00009.html.
* utils: Add critical sections.Ludovic Courtès2018-04-02
| | | | | | | | | | | * src/cuirass/utils.scm (make-critical-section) (call-with-critical-section): New procedures. (with-critical-section): New macro. * src/cuirass/http.scm (with-database-access): Remove. (handle-build-request, handle-builds-request, url-handler): Use 'with-critical-section' instead of 'with-database-access'. (run-cuirass-server): Remove 'spawn-fiber' call. Use 'make-critical-section' instead.
* utils: Add 'unwind-protect'.Ludovic Courtès2018-03-19
| | | | * src/cuirass/utils.scm (unwind-protect): New macro.
* utils: 'non-blocking' forwards exceptions to the calling fiber.Ludovic Courtès2018-02-08
| | | | | * src/cuirass/utils.scm (%non-blocking): Forward exceptions to the calling fiber.
* cuirass: Add 'essential-task' and wrap the main fibers in it.Ludovic Courtès2018-01-27
| | | | | * src/cuirass/utils.scm (essential-task): New procedure. * bin/cuirass.in (main): Wrap each fiber in 'essential-task'.
* utils: Add 'bytevector-range'.Ludovic Courtès2018-01-26
| | | | | * src/cuirass/utils.scm (%weak-references): New variable. (bytevector-range): New procedure.
* utils: Add 'non-blocking' macro.Ludovic Courtès2018-01-26
| | | | | * src/cuirass/utils.scm (%non-blocking): New procedure. (non-blocking): New macro.
* Add a 'build-status' enumeration.Ludovic Courtès2018-01-23
| | | | | | | * 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.
* cuirass: add Hydra compatible HTTP API.Mathieu Othacehe2017-09-08
| | | | | | | | | | | | | * 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.
* cuirass: Stop λ/lambda mixing.Mathieu Othacehe2017-07-06
| | | | | | | | | | | | | * 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.
* utils: Remove useless procedures.Mathieu Othacehe2017-07-01
| | | | | | | | | | | * 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).
* repo: Add <repo> record datatype.Mathieu Lirzin2016-12-28
| | | | | | | * src/cuirass/utils.scm (call-with-temporary-directory): New procedure. * src/cuirass/repo.scm: Use it. New file. * tests/repo.scm: New tests. * Makefile.am (dist_pkgmodule_DATA, TESTS): Add them.
* utils: Add 'alist?' procedure.Mathieu Lirzin2016-07-30
| | | | | * src/cuirass/utils.scm (alist?): New procedure. * tests/utils.scm ("alist?"): New test.
* maint: Update file headers.Mathieu Lirzin2016-07-25
|
* cuirass: Move code from main to auxiliary procedures.Mathieu Lirzin2016-07-02
|
* λ all the things!Mathieu Lirzin2016-07-02
|
* Add (cuirass utils) module.Mathieu Lirzin2016-07-02
Move 'with-directory-excursion' here.