guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/02: Support per repository configuration for fetching substitutes


From: Christopher Baines
Subject: 02/02: Support per repository configuration for fetching substitutes
Date: Fri, 9 Sep 2022 07:41:13 -0400 (EDT)

cbaines pushed a commit to branch master
in repository data-service.

commit ad39492cf066ba88bd0b31c68a6d7f6c2cda01db
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Fri Sep 9 12:39:38 2022 +0100

    Support per repository configuration for fetching substitutes
    
    This is so that data.qa.guix.gnu.org can be configured only to query the
    branches from the main repository.
---
 guix-data-service/model/git-repository.scm         |  9 +++++++
 guix-data-service/substitutes.scm                  | 31 +++++++++++-----------
 .../deploy/git_repositories_query_substitutes.sql  |  8 ++++++
 .../revert/git_repositories_query_substitutes.sql  |  7 +++++
 sqitch/sqitch.plan                                 |  1 +
 .../verify/git_repositories_query_substitutes.sql  |  7 +++++
 6 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/guix-data-service/model/git-repository.scm 
b/guix-data-service/model/git-repository.scm
index 35342f6..102dc43 100644
--- a/guix-data-service/model/git-repository.scm
+++ b/guix-data-service/model/git-repository.scm
@@ -22,6 +22,7 @@
   #:use-module (guix-data-service model utils)
   #:export (all-git-repositories
             select-git-repository
+            git-repository-query-substitutes?
             git-repository-id->url
             select-includes-and-excluded-branches-for-git-repository
             count-git-repositories-with-x-git-repo-header-values
@@ -57,6 +58,14 @@
            cgit_url_base
            (string=? fetch_with_authentication "t")))))
 
+(define (git-repository-query-substitutes? conn id)
+  (match (exec-query
+          conn
+          "SELECT query_substitutes FROM git_repositories WHERE id = $1"
+          (list (simple-format #f "~A" id)))
+    (((query_substitutes))
+     (string=? query_substitutes "t"))))
+
 (define (git-repository-id->url conn id)
   (match
       (exec-query
diff --git a/guix-data-service/substitutes.scm 
b/guix-data-service/substitutes.scm
index 953f693..87b6bbb 100644
--- a/guix-data-service/substitutes.scm
+++ b/guix-data-service/substitutes.scm
@@ -130,22 +130,23 @@
               (for-each
                (match-lambda
                  ((git-repository-id rest ...)
-                  (for-each
-                   (match-lambda
-                     ((branch-name rest ...)
-                      (and=> (latest-processed-commit-for-branch
-                              conn
-                              (number->string git-repository-id)
-                              branch-name)
-                             (lambda (commit)
-                               (query-build-server-substitutes
+                  (when (git-repository-query-substitutes? conn 
git-repository-id)
+                    (for-each
+                     (match-lambda
+                       ((branch-name rest ...)
+                        (and=> (latest-processed-commit-for-branch
                                 conn
-                                #f ;; All build servers
-                                (list commit)
-                                #f)))))
-                   (all-branches-with-most-recent-commit
-                    conn
-                    git-repository-id))))
+                                (number->string git-repository-id)
+                                branch-name)
+                               (lambda (commit)
+                                 (query-build-server-substitutes
+                                  conn
+                                  #f ;; All build servers
+                                  (list commit)
+                                  #f)))))
+                     (all-branches-with-most-recent-commit
+                      conn
+                      git-repository-id)))))
                (all-git-repositories conn))))
 
            (simple-format #t "finished checking substitutes, now sleeping\n")
diff --git a/sqitch/deploy/git_repositories_query_substitutes.sql 
b/sqitch/deploy/git_repositories_query_substitutes.sql
new file mode 100644
index 0000000..e7cdfc9
--- /dev/null
+++ b/sqitch/deploy/git_repositories_query_substitutes.sql
@@ -0,0 +1,8 @@
+-- Deploy guix-data-service:git_repositories_query_substitutes to pg
+
+BEGIN;
+
+ALTER TABLE git_repositories
+  ADD COLUMN query_substitutes boolean NOT NULL DEFAULT TRUE;
+
+COMMIT;
diff --git a/sqitch/revert/git_repositories_query_substitutes.sql 
b/sqitch/revert/git_repositories_query_substitutes.sql
new file mode 100644
index 0000000..9b3dc2b
--- /dev/null
+++ b/sqitch/revert/git_repositories_query_substitutes.sql
@@ -0,0 +1,7 @@
+-- Revert guix-data-service:git_repositories_query_substitutes from pg
+
+BEGIN;
+
+-- XXX Add DDLs here.
+
+COMMIT;
diff --git a/sqitch/sqitch.plan b/sqitch/sqitch.plan
index 6c6e2f1..5b7408b 100644
--- a/sqitch/sqitch.plan
+++ b/sqitch/sqitch.plan
@@ -87,3 +87,4 @@ git_branch_id 2022-05-23T18:11:14Z Chris <chris@felis> # Add 
git_branch.id
 partition_package_derivations_by_guix_revision_range 2022-05-23T18:20:37Z 
Chris <chris@felis> # Partition package_derivations_by_guix_revision_range
 package_range_index 2022-06-17T10:39:31Z Chris <chris@felis> # Add index on 
package_derivations_by_guix_revision_range.package_name
 fix_git_commits_duplicates 2022-06-17T10:39:50Z Chris <chris@felis> # Fix 
git_commits duplicates
+git_repositories_query_substitutes 2022-09-09T11:35:16Z Chris <chris@felis> # 
Add git_repositories.query_substitutes
diff --git a/sqitch/verify/git_repositories_query_substitutes.sql 
b/sqitch/verify/git_repositories_query_substitutes.sql
new file mode 100644
index 0000000..d01657e
--- /dev/null
+++ b/sqitch/verify/git_repositories_query_substitutes.sql
@@ -0,0 +1,7 @@
+-- Verify guix-data-service:git_repositories_query_substitutes on pg
+
+BEGIN;
+
+-- XXX Add verifications here.
+
+ROLLBACK;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]