[PATCH Cuirass 0/3] Agit workflow support

  • Open
  • quality assurance status badge
Details
One participant
  • Romain GARBAGE
Owner
unassigned
Submitted by
Romain GARBAGE
Severity
normal

Debbugs page

Romain GARBAGE wrote 5 days ago
(address . guix-patches@gnu.org)
20250307105850.27870-1-romain.garbage@inria.fr
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
Romain GARBAGE wrote 5 days ago
[PATCH Cuirass 1/3] tests: common: Improve specif ications=?.
(address . 76809@debbugs.gnu.org)
20250307110025.12928-1-romain.garbage@inria.fr
* tests/common.scm (specifications=?): Add check for channel commit.
---
tests/common.scm | 4 ++++
1 file changed, 4 insertions(+)

Toggle diff (18 lines)
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
Romain GARBAGE wrote 5 days ago
[PATCH Cuirass 2/3] forgejo: Support for Agit workflow.
(address . 76809@debbugs.gnu.org)
20250307110025.12928-2-romain.garbage@inria.fr
This commit adds support for the Agit workflow (see
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(-)

Toggle diff (36 lines)
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
Romain GARBAGE wrote 5 days ago
[PATCH Cuirass 3/3] http: Update Forgejo jobset when PR is updated.
(address . 76809@debbugs.gnu.org)
20250307110025.12928-3-romain.garbage@inria.fr
* 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(-)

Toggle diff (88 lines)
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
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 76809@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 76809
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help