This is an automated email from the git hooks/post-receive script. civodul pushed a commit to branch main in repository guix-cuirass.
The following commit(s) were added to refs/heads/main by this push: new b0a14e3 database: Mark new builds as ‘failed-dependency’ when appropriate. b0a14e3 is described below commit b0a14e3d84b7a0d3926793c6408678daa529962e Author: Ludovic Courtès <l...@gnu.org> AuthorDate: Wed Sep 25 15:07:28 2024 +0200 database: Mark new builds as ‘failed-dependency’ when appropriate. Previously, new builds would always start off as ‘scheduled’. With this change, they start as ‘failed-dependency’ when needed. This has become necessary since the periodic job was removed in 6cd1608e644a755dbbfd2937489061ed31eb8bbf. * src/cuirass/database.scm (db-mark-as-failed-if-dependencies-failed): New procedure. (db-add-build-dependencies): Call it. * tests/database.scm (make-dummy-build): Add #:dependencies and honor it. ("db-register-builds, failed dependencies"): New test. --- src/cuirass/database.scm | 21 ++++++++++++++++++++- tests/database.scm | 25 ++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm index aaf1be3..41a787e 100644 --- a/src/cuirass/database.scm +++ b/src/cuirass/database.scm @@ -1112,7 +1112,11 @@ INSERT INTO BuildDependencies (SELECT Builds.id, deps.id FROM Builds, (SELECT id FROM Builds WHERE derivation = ANY(" target ")) deps WHERE Builds.derivation = " source-derivation ") -ON CONFLICT ON CONSTRAINT builddependencies_pkey DO NOTHING;"))) +ON CONFLICT ON CONSTRAINT builddependencies_pkey DO NOTHING;")) + + ;; If SOURCE-DERIVATION has one or more failed dependencies, change its + ;; status accordingly. + (db-mark-as-failed-if-dependencies-failed source-derivation)) (define (db-get-build-dependencies build) "Return the list of the given BUILD dependencies." @@ -1197,6 +1201,21 @@ WHERE id = ANY(" (list->sql-array dependents) ");")))) ;; Recurse. (loop (append-map db-get-build-dependents dependents)))))) +(define (db-mark-as-failed-if-dependencies-failed drv) + "Mark the build of DRV as 'failed-dependency' if it has one or more failed +dependencies." + (with-db-connection db + (unless (zero? (exec-query/bind db " +UPDATE Builds SET status = " (build-status failed-dependency) " +FROM + (SELECT count(Builds.id) AS total FROM Builds + LEFT JOIN BuildDependencies AS bd ON bd.target = Builds.id + LEFT JOIN Builds AS source ON source.derivation = " drv " + WHERE bd.source = source.id AND Builds.status > 0) +AS faileddependencies +WHERE Builds.derivation = " drv " AND faileddependencies.total > 0;")) + (log-info "marked build of ~a as 'failed-dependency'" drv)))) + (define (db-register-builds builds specification) (define (previous-build outputs) ;; Return the previous build producing OUTPUTS or #f if there is none. diff --git a/tests/database.scm b/tests/database.scm index d3bcc60..51c11e2 100644 --- a/tests/database.scm +++ b/tests/database.scm @@ -101,7 +101,8 @@ (list (output (name "foo") (derivation drv) - (item (format #f "~a.output" drv)))))) + (item (format #f "~a.output" drv))))) + (dependencies '())) (build (derivation drv) (evaluation-id eval-id) (specification-name jobset) @@ -110,6 +111,7 @@ (nix-name "foo") (log "log") (outputs outputs) + (dependencies dependencies) (priority priority) (creation-time timestamp))) @@ -1094,6 +1096,27 @@ timestamp, checkouttime, evaltime) VALUES ('guix', 0, 0, 0, 0);") (build-current-status (db-get-build drv))))) + (test-equal "db-register-builds, failed dependencies" + (build-status failed-dependency) + (with-fibers + (let ((dep "/test-failed-dep-of-new-build.drv") + (drv "/test-new-build-with-failed-dep.drv")) + (db-register-builds + (list (make-dummy-build dep 2 #:job-name "test-failed-dep")) + (db-get-specification "guix")) + + (db-update-build-status! dep (build-status failed)) + + ;; Register a new build that depends on DEP. That new build should be + ;; marked as 'failed-dependency', not as 'scheduled'. + (db-register-builds + (list (make-dummy-build drv 4 + #:job-name "test-register-failed-deps" + #:dependencies (list dep))) + (db-get-specification "guix")) + + (build-current-status (db-get-build drv))))) + (test-equal "db-remove-old-evaluations" (delv 1 (map evaluation-id (db-get-evaluations 100))) (with-fibers