GNU bug report logs - #76809
[PATCH Cuirass 0/3] Agit workflow support

Previous Next

Package: guix-patches;

Reported by: Romain GARBAGE <romain.garbage <at> inria.fr>

Date: Fri, 7 Mar 2025 11:00:01 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 76809 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#76809; Package guix-patches. (Fri, 07 Mar 2025 11:00:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Romain GARBAGE <romain.garbage <at> inria.fr>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Fri, 07 Mar 2025 11:00:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Romain GARBAGE <romain.garbage <at> inria.fr>
To: guix-patches <at> gnu.org
Cc: ludovic.courtes <at> inria.fr, Romain GARBAGE <romain.garbage <at> inria.fr>
Subject: [PATCH Cuirass 0/3] Agit workflow support
Date: Fri,  7 Mar 2025 11:57:02 +0100
This patch series add support for the Agit workflow in the Forgejo
subsystem.

Romain GARBAGE (3):
  tests: common: Improve specifications=?.
  forgejo: Support for Agit workflow.
  http: Update Forgejo jobset when PR is updated.

 src/cuirass/forges/forgejo.scm |  3 ++-
 src/cuirass/http.scm           | 14 ++++++-----
 tests/common.scm               |  4 ++++
 tests/forgejo.scm              |  2 +-
 tests/http.scm                 | 43 ++++++++++++++++++++++++++++++++++
 5 files changed, 58 insertions(+), 8 deletions(-)


base-commit: 520b2fdbd96e953fc2d4b56e78e52a81fc11e2b7
-- 
2.48.1





Information forwarded to guix-patches <at> gnu.org:
bug#76809; Package guix-patches. (Fri, 07 Mar 2025 11:01:02 GMT) Full text and rfc822 format available.

Message #8 received at 76809 <at> debbugs.gnu.org (full text, mbox):

From: Romain GARBAGE <romain.garbage <at> inria.fr>
To: 76809 <at> debbugs.gnu.org
Cc: ludovic.courtes <at> inria.fr, Romain GARBAGE <romain.garbage <at> inria.fr>
Subject: [PATCH Cuirass 1/3] tests: common: Improve specifications=?.
Date: Fri,  7 Mar 2025 12:00:23 +0100
* tests/common.scm (specifications=?): Add check for channel commit.
---
 tests/common.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/common.scm b/tests/common.scm
index 479fef3..4974812 100644
--- a/tests/common.scm
+++ b/tests/common.scm
@@ -149,5 +149,9 @@ Return the socket on success and #f on failure."
                     (specification-channels spec1))
                (map channel-branch
                     (specification-channels spec2)))
+       (equal? (map channel-commit
+                    (specification-channels spec1))
+               (map channel-commit
+                    (specification-channels spec2)))
        (equal? (specification-properties spec1)
                (specification-properties spec2))))

base-commit: 520b2fdbd96e953fc2d4b56e78e52a81fc11e2b7
-- 
2.48.1





Information forwarded to guix-patches <at> gnu.org:
bug#76809; Package guix-patches. (Fri, 07 Mar 2025 11:01:02 GMT) Full text and rfc822 format available.

Message #11 received at 76809 <at> debbugs.gnu.org (full text, mbox):

From: Romain GARBAGE <romain.garbage <at> inria.fr>
To: 76809 <at> debbugs.gnu.org
Cc: ludovic.courtes <at> inria.fr, Romain GARBAGE <romain.garbage <at> inria.fr>
Subject: [PATCH Cuirass 2/3] forgejo: Support for Agit workflow.
Date: Fri,  7 Mar 2025 12:00:24 +0100
This commit adds support for the Agit workflow (see
https://forgejo.org/docs/latest/user/agit-support/).
In this case the provided "ref" is not an existing branch and the channel
can't be fetched.

* src/cuirass/forges/forgejo.scm (forgejo-pull-request->specification): Build
channel from commit instead of branch.
* tests/forgejo.scm: Update test.
---
 src/cuirass/forges/forgejo.scm | 3 ++-
 tests/forgejo.scm              | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/cuirass/forges/forgejo.scm b/src/cuirass/forges/forgejo.scm
index 73ab609..40d1279 100644
--- a/src/cuirass/forges/forgejo.scm
+++ b/src/cuirass/forges/forgejo.scm
@@ -94,6 +94,7 @@
                         (forgejo-repository-reference-repository
                          (forgejo-pull-request-base pull-request))))
          (source-branch (forgejo-repository-reference-ref source-repo-reference))
+         (source-commit (forgejo-repository-reference-sha source-repo-reference))
          (source-url (forgejo-repository-url
                       (forgejo-repository-reference-repository source-repo-reference)))
          (id (forgejo-pull-request-number pull-request))
@@ -129,7 +130,7 @@
       (cons* (channel
               (name project-name)
               (url source-url)
-              (branch source-branch))
+              (commit source-commit))
              %default-channels))
      (priority priority)
      (period period)
diff --git a/tests/forgejo.scm b/tests/forgejo.scm
index 2718bb3..ba3675a 100644
--- a/tests/forgejo.scm
+++ b/tests/forgejo.scm
@@ -76,7 +76,7 @@
      (cons* (channel
              (name 'project-name)
              (url "https://forgejo.instance.test/source-repo/fork-name.git")
-             (branch "test-branch"))
+             (commit "582af40e8a059fa05c7048a7ac4f2eccbbd0183b"))
             %default-channels))
     (priority %default-jobset-options-priority)
     (period %default-jobset-options-period)
-- 
2.48.1





Information forwarded to guix-patches <at> gnu.org:
bug#76809; Package guix-patches. (Fri, 07 Mar 2025 11:01:03 GMT) Full text and rfc822 format available.

Message #14 received at 76809 <at> debbugs.gnu.org (full text, mbox):

From: Romain GARBAGE <romain.garbage <at> inria.fr>
To: 76809 <at> debbugs.gnu.org
Cc: ludovic.courtes <at> inria.fr, Romain GARBAGE <romain.garbage <at> inria.fr>
Subject: [PATCH Cuirass 3/3] http: Update Forgejo jobset when PR is updated.
Date: Fri,  7 Mar 2025 12:00:25 +0100
* src/cuirass/http.scm (url-handler): Update Forgejo jobset when PR is updated.
* tests/http.scm (forgejo-pull-request-json-update): New variable.
("/admin/forgejo/event updates a spec"): New test.
---
 src/cuirass/http.scm | 14 ++++++++------
 tests/http.scm       | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm
index cfb72e4..a826ef1 100644
--- a/src/cuirass/http.scm
+++ b/src/cuirass/http.scm
@@ -840,12 +840,14 @@ return DEFAULT."
                   ;; Pull request is updated.
                   ('synchronized
                    (if (db-get-specification spec-name)
-                       (if (call-bridge `(trigger-jobset ,(specification-name spec))
-                                        bridge)
-                           (respond-json (scm->json-string `((jobset . ,spec-name))))
-                           (begin
-                             (log-warning "evaluation hook disabled")
-                             (respond-json-with-error 400 "Evaluation hook disabled.")))
+                       (begin
+                         (db-add-or-update-specification spec)
+                         (if (call-bridge `(trigger-jobset ,spec-name)
+                                          bridge)
+                             (respond-json (scm->json-string `((jobset . ,spec-name))))
+                             (begin
+                               (log-warning "evaluation hook disabled for spec ~a" spec-name)
+                               (respond-json-with-error 400 "Evaluation hook disabled."))))
                        (respond-json-with-error 404 "Jobset not found."))))))
              (_ (respond-json-with-error 400 (format #f "Event type \"~a\" not supported." event-type))))
            (respond-json-with-error 400 "This API only supports JSON."))))
diff --git a/tests/http.scm b/tests/http.scm
index a57a4ab..ead4bf3 100644
--- a/tests/http.scm
+++ b/tests/http.scm
@@ -177,6 +177,36 @@
     }
   }")
 
+(define forgejo-pull-request-json-update
+  "{
+    \"action\": \"synchronized\",
+    \"pull_request\": {
+      \"number\": 1,
+      \"state\": \"open\",
+      \"url\": \"https://forgejo.instance.test/base-repo/pulls/1\",
+      \"base\": {
+        \"label\": \"base-label\",
+        \"ref\": \"base-branch\",
+        \"sha\": \"666af40e8a059fa05c7048a7ac4f2eccbbd0183b\",
+        \"repo\": {
+          \"name\": \"project-name\",
+          \"clone_url\": \"https://forgejo.instance.test/base-repo/project-name.git\",
+          \"html_url\": \"https://forgejo.instance.test/base-repo/project-name\"
+        }
+      },
+      \"head\": {
+        \"label\": \"test-label\",
+        \"ref\": \"test-branch\",
+        \"sha\": \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",
+        \"repo\": {
+          \"name\": \"fork-name\",
+          \"clone_url\": \"https://forgejo.instance.test/source-repo/fork-name.git\",
+          \"html_url\": \"https://forgejo.instance.test/source-repo/fork-name\"
+        }
+      }
+    }
+  }")
+
 (define forgejo-pull-request-json-close
   "{
     \"action\": \"closed\",
@@ -572,6 +602,19 @@
                                     forgejo-pull-request-json-open
                                     '((x-forgejo-event . "pull_request")))))
 
+   (test-assert "/admin/forgejo/event updates a spec"
+     (let* ((spec (forgejo-pull-request->specification
+               (forgejo-pull-request-event-pull-request
+                (json->forgejo-pull-request-event forgejo-pull-request-json-update))))
+            (spec-name (specification-name forgejo-pull-request-specification)))
+       (specifications=?
+        (pk 'expected spec)
+        (begin
+          (http-post-json (test-cuirass-uri "/admin/forgejo/event")
+                          forgejo-pull-request-json-update
+                          '((x-forgejo-event . "pull_request")))
+          (pk 'actual (db-get-specification spec-name))))))
+
    (test-assert "/admin/forgejo/event removes a spec from a closed pull request"
      (begin
        (http-post-json (test-cuirass-uri "/admin/forgejo/event")
-- 
2.48.1





This bug report was last modified 3 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.