From 7b2f9e0de1ad2d320973b7aea132a8afcad8bece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Lassieur?= Date: Tue, 26 Jun 2018 11:18:23 +0200 Subject: Add support for multiple inputs. * 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. --- tests/database.scm | 39 +++++++++++++++++++++++++-------------- tests/http.scm | 26 +++++++++++++++----------- 2 files changed, 40 insertions(+), 25 deletions(-) (limited to 'tests') diff --git a/tests/database.scm b/tests/database.scm index e71c7f7..6ca9d1c 100644 --- a/tests/database.scm +++ b/tests/database.scm @@ -25,19 +25,30 @@ (define example-spec '((#:name . "guix") - (#:url . "git://git.savannah.gnu.org/guix.git") - (#:load-path . ".") - (#:file . "/tmp/gnu-system.scm") + (#:load-path-inputs . ("savannah")) + (#:package-path-inputs . ()) + (#:proc-input . "savannah") + (#:proc-file . "/tmp/gnu-system.scm") (#:proc . hydra-jobs) - (#:arguments (subset . "hello")) - (#:branch . "master") - (#:tag . #f) - (#:commit . #f) - (#:no-compile? . #f))) - -(define* (make-dummy-eval #:optional (revision "cabba3e")) + (#:proc-args (subset . "hello")) + (#:inputs . (((#:name . "savannah") + (#:url . "git://git.savannah.gnu.org/guix.git") + (#:load-path . ".") + (#:branch . "master") + (#:tag . #f) + (#:commit . #f) + (#:no-compile? . #f)) + ((#:name . "maintenance") + (#:url . "git://git.savannah.gnu.org/guix/maintenance.git") + (#:load-path . ".") + (#:branch . "master") + (#:tag . #f) + (#:commit . #f) + (#:no-compile? . #f)))))) + +(define* (make-dummy-eval #:optional (commits '("cabba3e 61730ea"))) `((#:specification . "guix") - (#:revision . ,revision))) + (#:commits . ,commits))) (define* (make-dummy-job #:optional (name "foo")) `((#:name . ,name) @@ -90,11 +101,11 @@ (test-assert "sqlite-exec" (begin (sqlite-exec (%db) "\ -INSERT INTO Evaluations (specification, revision) VALUES (1, 1);") +INSERT INTO Evaluations (specification, commits) VALUES (1, 1);") (sqlite-exec (%db) "\ -INSERT INTO Evaluations (specification, revision) VALUES (2, 2);") +INSERT INTO Evaluations (specification, commits) VALUES (2, 2);") (sqlite-exec (%db) "\ -INSERT INTO Evaluations (specification, revision) VALUES (3, 3);") +INSERT INTO Evaluations (specification, commits) VALUES (3, 3);") (sqlite-exec (%db) "SELECT * FROM Evaluations;"))) (test-equal "db-add-specification" diff --git a/tests/http.scm b/tests/http.scm index ba53887..e05fdc5 100644 --- a/tests/http.scm +++ b/tests/http.scm @@ -97,7 +97,7 @@ (define evaluations-query-result '((#:id . 2) (#:specification . "guix") - (#:revision . "fakesha2"))) + (#:commits . ("fakesha2" "fakesha3")))) (test-group-with-cleanup "http" (test-assert "object->json-string" @@ -171,21 +171,25 @@ (#:eval-id . 1))) (specification '((#:name . "guix") - (#:url . "git://git.savannah.gnu.org/guix.git") - (#:load-path . ".") - (#:file . "/tmp/gnu-system.scm") + (#:load-path-inputs . ("savannah")) + (#:package-path-inputs . ()) + (#:proc-input . "savannah") + (#:proc-file . "/tmp/gnu-system.scm") (#:proc . hydra-jobs) - (#:arguments (subset . "hello")) - (#:branch . "master") - (#:tag . #f) - (#:commit . #f) - (#:no-compile? . #f))) + (#:proc-args (subset . "hello")) + (#:inputs . (((#:name . "savannah") + (#:url . "git://git.savannah.gnu.org/guix.git") + (#:load-path . ".") + (#:branch . "master") + (#:tag . #f) + (#:commit . #f) + (#:no-compile? . #f)))))) (evaluation1 '((#:specification . "guix") - (#:revision . "fakesha1"))) + (#:commits . ("fakesha1" "fakesha3")))) (evaluation2 '((#:specification . "guix") - (#:revision . "fakesha2")))) + (#:commits . ("fakesha2" "fakesha3"))))) (db-add-build (%db) build1) (db-add-build (%db) build2) (db-add-derivation (%db) derivation1) -- cgit v1.2.3