From unknown Sun Jun 22 04:04:30 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#74769] [PATCH Cuirass 0/4] Forgejo event support Resent-From: Romain GARBAGE Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 10 Dec 2024 16:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 74769 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74769@debbugs.gnu.org Cc: ludovic.courtes@inria.fr, Romain GARBAGE X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.17338469295244 (code B ref -1); Tue, 10 Dec 2024 16:09:02 +0000 Received: (at submit) by debbugs.gnu.org; 10 Dec 2024 16:08:49 +0000 Received: from localhost ([127.0.0.1]:59200 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL2n2-0001MR-NG for submit@debbugs.gnu.org; Tue, 10 Dec 2024 11:08:49 -0500 Received: from lists.gnu.org ([209.51.188.17]:52872) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL2mz-0001M1-TG for submit@debbugs.gnu.org; Tue, 10 Dec 2024 11:08:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tL2my-0000E2-N3 for guix-patches@gnu.org; Tue, 10 Dec 2024 11:08:44 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tL2mv-0005CS-JI for guix-patches@gnu.org; Tue, 10 Dec 2024 11:08:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Rc/OOSTpAXdVlddawgIIuo5s+DSnF2BzM5Dy/lqV0Bw=; b=PITMtTTwB2ppEVw9R+EsVnugPSIWFvQJOj4pzNKMHYISRy90Wp25mKQy Ke9v7SaQEy53a6LnRhSIstjML+/SnzS5zCykrSylsGEkQyOc6wFsLeGby syASaj5g2DHu7z9DuJDQ89JFarl5IY+R21kiuWj4UH3WqWCkqNwg3d3Ih A=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=romain.garbage@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.12,222,1728943200"; d="scan'208";a="103964414" Received: from unknown (HELO guix-A102.bordeaux.inria.fr) ([193.50.110.191]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2024 17:08:37 +0100 From: Romain GARBAGE Date: Tue, 10 Dec 2024 17:01:04 +0100 Message-ID: <20241210160824.31748-1-romain.garbage@inria.fr> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=192.134.164.104; envelope-from=romain.garbage@inria.fr; helo=mail3-relais-sop.national.inria.fr X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This patch series adds support for Forgejo pull request events in Cuirass, as generated using the webhooks mechanism. The first patch refactors code to make it accessible from different test modules. The second patch adds the necessary record type definitions to parse the JSON data sent by Forgejo. The third patch improves Gitlab integration related http tests readability. The fourth patch adds Forgejo integration to Cuirass' web service. Romain GARBAGE (4): tests: Move procedure definition. forgejo: Add module for Forgejo JSON objects definition. tests: Explicit Gitlab endpoint related variables. http: Add admin/forgejo/event. Makefile.am | 2 + doc/cuirass.texi | 38 ++++++++++-- src/cuirass/forgejo.scm | 133 ++++++++++++++++++++++++++++++++++++++++ src/cuirass/http.scm | 62 +++++++++++++++++++ tests/common.scm | 30 ++++++++- tests/forgejo.scm | 79 ++++++++++++++++++++++++ tests/gitlab.scm | 24 -------- tests/http.scm | 114 ++++++++++++++++++++++++++++++---- 8 files changed, 440 insertions(+), 42 deletions(-) create mode 100644 src/cuirass/forgejo.scm create mode 100644 tests/forgejo.scm base-commit: e96f0887923d4d1cd4e35073fcffdb978d7e1e10 -- 2.46.0 From unknown Sun Jun 22 04:04:30 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#74769] [PATCH Cuirass 1/4] tests: Move procedure definition. References: <20241210160824.31748-1-romain.garbage@inria.fr> In-Reply-To: <20241210160824.31748-1-romain.garbage@inria.fr> Resent-From: Romain GARBAGE Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 10 Dec 2024 16:10:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74769 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74769@debbugs.gnu.org Cc: ludovic.courtes@inria.fr, Romain GARBAGE Received: via spool by 74769-submit@debbugs.gnu.org id=B74769.17338469905727 (code B ref 74769); Tue, 10 Dec 2024 16:10:03 +0000 Received: (at 74769) by debbugs.gnu.org; 10 Dec 2024 16:09:50 +0000 Received: from localhost ([127.0.0.1]:59206 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL2o1-0001UE-Ct for submit@debbugs.gnu.org; Tue, 10 Dec 2024 11:09:50 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:32084) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL2ny-0001TJ-Id for 74769@debbugs.gnu.org; Tue, 10 Dec 2024 11:09:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=SNm9hoixEYB9xCpt/5m/VDAQ1eQMm21+KbvaCLYwlQc=; b=WmwuChJ7vj0+gRs3H6YTApn8n1qbC6/oiTll8RRb33FSJNib+i0p2eiH AJBe0YbSf+lyzypV0uahjJMwCUOcZx3x2o0QlOxHL43fAPBYEyMJECfXT QlpdLsHT+Uyv2wNb9si//Z6mS0ed3CYu6UZRRauNJ6yM9qGPk5v+Al1HX U=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=romain.garbage@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.12,222,1728943200"; d="scan'208";a="103964548" Received: from unknown (HELO guix-A102.bordeaux.inria.fr) ([193.50.110.191]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2024 17:09:40 +0100 From: Romain GARBAGE Date: Tue, 10 Dec 2024 17:09:25 +0100 Message-ID: <20241210160929.14180-1-romain.garbage@inria.fr> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * tests/common.scm (specifications-equal?): New variable. * tests/gitlab.scm (specifications-equal?): Remove variable. --- tests/common.scm | 30 +++++++++++++++++++++++++++++- tests/gitlab.scm | 24 ------------------------ 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/tests/common.scm b/tests/common.scm index a807498..5054ea0 100644 --- a/tests/common.scm +++ b/tests/common.scm @@ -20,7 +20,9 @@ #:use-module ((cuirass base) #:select (%bridge-socket-file-name)) #:use-module (cuirass database) #:use-module (cuirass parameters) + #:use-module (cuirass specification) #:use-module (cuirass utils) + #:use-module (guix channels) #:use-module ((fibers scheduler) #:select (current-scheduler)) #:use-module (ice-9 popen) #:use-module (ice-9 rdelim) @@ -28,7 +30,8 @@ retry test-init-db! with-guix-daemon - wait-for-bridge)) + wait-for-bridge + specifications-equal?)) (define %db (make-parameter #f)) @@ -121,3 +124,28 @@ Return the socket on success and #f on failure." (sockaddr:path address) (strerror (system-error-errno args))) #f))))))) + +(define (specifications-equal? spec1 spec2) + "Return true if SPEC2 and SPEC2 are equivalent, false otherwise." + (and (eq? (specification-name spec1) + (specification-name spec2)) + (equal? (specification-build spec1) + (specification-build spec2)) + (= (specification-priority spec1) + (specification-priority spec2)) + (= (specification-period spec1) + (specification-period spec2)) + (equal? (specification-systems spec1) + (specification-systems spec2)) + (equal? (map channel-name + (specification-channels spec1)) + (map channel-name + (specification-channels spec2))) + (equal? (map channel-url + (specification-channels spec1)) + (map channel-url + (specification-channels spec2))) + (equal? (map channel-branch + (specification-channels spec1)) + (map channel-branch + (specification-channels spec2))))) diff --git a/tests/gitlab.scm b/tests/gitlab.scm index ca6cad5..adf94cc 100644 --- a/tests/gitlab.scm +++ b/tests/gitlab.scm @@ -157,30 +157,6 @@ } }") -(define (specifications-equal? spec1 spec2) - (and (eq? (specification-name spec1) - (specification-name spec2)) - (equal? (specification-build spec1) - (specification-build spec2)) - (= (specification-priority spec1) - (specification-priority spec2)) - (= (specification-period spec1) - (specification-period spec2)) - (equal? (specification-systems spec1) - (specification-systems spec2)) - (equal? (map channel-name - (specification-channels spec1)) - (map channel-name - (specification-channels spec2))) - (equal? (map channel-url - (specification-channels spec1)) - (map channel-url - (specification-channels spec2))) - (equal? (map channel-branch - (specification-channels spec1)) - (map channel-branch - (specification-channels spec2))))) - (test-assert "default-json" (specifications-equal? (let ((event (json->gitlab-event default-mr-json))) base-commit: e96f0887923d4d1cd4e35073fcffdb978d7e1e10 -- 2.46.0 From unknown Sun Jun 22 04:04:30 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#74769] [PATCH Cuirass 2/4] forgejo: Add module for Forgejo JSON objects definition. Resent-From: Romain GARBAGE Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 10 Dec 2024 16:10:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74769 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74769@debbugs.gnu.org Cc: ludovic.courtes@inria.fr, Romain GARBAGE Received: via spool by 74769-submit@debbugs.gnu.org id=B74769.17338469965784 (code B ref 74769); Tue, 10 Dec 2024 16:10:04 +0000 Received: (at 74769) by debbugs.gnu.org; 10 Dec 2024 16:09:56 +0000 Received: from localhost ([127.0.0.1]:59210 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL2o5-0001Uo-2r for submit@debbugs.gnu.org; Tue, 10 Dec 2024 11:09:56 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:32084) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL2nz-0001TJ-E1 for 74769@debbugs.gnu.org; Tue, 10 Dec 2024 11:09:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HCBMbFO+H0H3dcFuf2bOvFh5Gpu5S5Vi5RmSpRWW1go=; b=mmEZueDTMt99bLbIMML9Mh1k3WuHCQzFQqnL1lZVWAl3ubxxyKTl32CA nRFCXPL0+8nT219VgN8y215JrnJHBci0NxltEu4UGe1ALHaLcjAd8EJCV QcQ9gLmNi4IQeYakYe1HDPIHjrEsJGvdyNiOsQ1D9W+tMpnKr+C60Q134 U=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=romain.garbage@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.12,222,1728943200"; d="scan'208";a="103964549" Received: from unknown (HELO guix-A102.bordeaux.inria.fr) ([193.50.110.191]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2024 17:09:40 +0100 From: Romain GARBAGE Date: Tue, 10 Dec 2024 17:09:26 +0100 Message-ID: <20241210160929.14180-2-romain.garbage@inria.fr> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241210160929.14180-1-romain.garbage@inria.fr> References: <20241210160929.14180-1-romain.garbage@inria.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * Makefile.am: Add src/cuirass/forgejo.scm and tests/forgejo.scm. * src/cuirass/forgejo.scm: Add , , , and record types. (forgejo-pull-request->specification): New variable. * tests/forgejo.scm: Add tests. fixup tests --- Makefile.am | 2 + src/cuirass/forgejo.scm | 133 ++++++++++++++++++++++++++++++++++++++++ tests/forgejo.scm | 79 ++++++++++++++++++++++++ 3 files changed, 214 insertions(+) create mode 100644 src/cuirass/forgejo.scm create mode 100644 tests/forgejo.scm diff --git a/Makefile.am b/Makefile.am index 1123eb1..fca6b9f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,6 +52,7 @@ dist_pkgmodule_DATA = \ src/cuirass/store.scm \ src/cuirass/base.scm \ src/cuirass/database.scm \ + src/cuirass/forgejo.scm \ src/cuirass/gitlab.scm \ src/cuirass/http.scm \ src/cuirass/logging.scm \ @@ -167,6 +168,7 @@ TESTS = \ ## tests/basic.sh # takes too long to execute tests/store.scm \ tests/database.scm \ + tests/forgejo.scm \ tests/gitlab.scm \ tests/http.scm \ tests/metrics.scm \ diff --git a/src/cuirass/forgejo.scm b/src/cuirass/forgejo.scm new file mode 100644 index 0000000..9dda2c5 --- /dev/null +++ b/src/cuirass/forgejo.scm @@ -0,0 +1,133 @@ +;;; forgejo.scm -- Forgejo JSON mappings +;;; Copyright © 2024 Romain Garbage +;;; +;;; This file is part of Cuirass. +;;; +;;; Cuirass is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; Cuirass is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with Cuirass. If not, see . + +(define-module (cuirass forgejo) + #:use-module (cuirass specification) + #:use-module (json) + #:use-module (web http) + #:use-module (guix channels) + #:use-module (ice-9 match) + #:export (forgejo-pull-request-event-pull-request + forgejo-pull-request-event-action + json->forgejo-pull-request-event + + forgejo-repository-name + forgejo-repository-url + + json->forgejo-pull-request + + forgejo-pull-request->specification)) + +;;; Commentary: +;;; +;;; This module implements a subset of the Forgejo Webhook API described at +;;; . +;;; +;;; Code: + +;; This declares a specific header for internal consumption, specifically when +;; generating requests during tests. +(declare-opaque-header! "X-Forgejo-Event") + +(define-json-mapping + make-forgejo-repository + forgejo-repository? + json->forgejo-repository + (name forgejo-repository-name "name" + string->symbol) + (url forgejo-repository-url "clone_url")) + +;; This maps to the top level JSON object. +(define-json-mapping + make-forgejo-pull-request-event + forgejo-pull-request-event? + json->forgejo-pull-request-event + (action forgejo-pull-request-event-action "action" + string->symbol) + (pull-request forgejo-pull-request-event-pull-request "pull_request" + json->forgejo-pull-request)) + +(define-json-mapping + make-forgejo-pull-request + forgejo-pull-request? + json->forgejo-pull-request + (number forgejo-pull-request-number "number") + (base forgejo-pull-request-base "base" + json->forgejo-repository-reference) + (head forgejo-pull-request-head "head" + json->forgejo-repository-reference)) + +;; This mapping is used to define various JSON objects such as "base" or +;; "head". +(define-json-mapping + make-forgejo-repository-reference + forgejo-repository-reference? + json->forgejo-repository-reference + (label forgejo-repository-reference-label "label") + (ref forgejo-repository-reference-ref "ref") + (sha forgejo-repository-reference-sha "sha") + (repository forgejo-repository-reference-repository "repo" + json->forgejo-repository)) + +(define* (forgejo-pull-request->specification pull-request #:optional (cuirass-options #f)) + "Returns a SPECIFICATION built out of a FORGEJO-PULL-REQUEST." + (let* ((source-repo-reference (forgejo-pull-request-head pull-request)) + (project-name (forgejo-repository-name + (forgejo-repository-reference-repository + (forgejo-pull-request-base pull-request)))) + (source-branch (forgejo-repository-reference-ref source-repo-reference)) + (source-url (forgejo-repository-url + (forgejo-repository-reference-repository source-repo-reference))) + (id (forgejo-pull-request-number pull-request)) + (name-prefix (if (and cuirass-options + (jobset-options-name-prefix cuirass-options)) + (jobset-options-name-prefix cuirass-options) + 'forgejo-pull-requests)) + (spec-name (string->symbol + (format #f "~a-~a-~a-~a" name-prefix + project-name + source-branch + id))) + (build (if (and cuirass-options + (jobset-options-build cuirass-options)) + (jobset-options-build cuirass-options) + `(channels ,project-name))) + (period (if (and cuirass-options + (jobset-options-period cuirass-options)) + (jobset-options-period cuirass-options) + 3600)) + (priority (if (and cuirass-options + (jobset-options-priority cuirass-options)) + (jobset-options-priority cuirass-options) + 1)) + (systems (if (and cuirass-options + (jobset-options-systems cuirass-options)) + (jobset-options-systems cuirass-options) + (list "x86_64-linux")))) + (specification + (name spec-name) + (build build) + (channels + (cons* (channel + (name project-name) + (url source-url) + (branch source-branch)) + %default-channels)) + (priority priority) + (period period) + (systems systems)))) diff --git a/tests/forgejo.scm b/tests/forgejo.scm new file mode 100644 index 0000000..bb8f768 --- /dev/null +++ b/tests/forgejo.scm @@ -0,0 +1,79 @@ +;;; forgejo.scm -- tests for (cuirass forgejo) module +;;; Copyright © 2024 Romain GARBAGE +;;; +;;; This file is part of Cuirass. +;;; +;;; Cuirass is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; Cuirass is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with Cuirass. If not, see . + +(use-modules (cuirass forgejo) + (cuirass specification) + (cuirass utils) + (tests common) + (guix channels) + (json) + (fibers) + (squee) + (web uri) + (web client) + (web response) + (rnrs bytevectors) + (srfi srfi-1) + (srfi srfi-64) + (ice-9 threads) + (ice-9 match)) + +(define default-pull-request-json + "{ + \"action\": \"opened\", + \"pull_request\": { + \"number\": 1, + \"state\": \"open\", + \"base\": { + \"label\": \"base-label\", + \"ref\": \"base-branch\", + \"sha\": \"666af40e8a059fa05c7048a7ac4f2eccbbd0183b\", + \"repo\": { + \"name\": \"project-name\", + \"clone_url\": \"https://forgejo.instance.test/base-repo/project-name.git\" + } + }, + \"head\": { + \"label\": \"test-label\", + \"ref\": \"test-branch\", + \"sha\": \"582af40e8a059fa05c7048a7ac4f2eccbbd0183b\", + \"repo\": { + \"name\": \"fork-name\", + \"clone_url\": \"https://forgejo.instance.test/source-repo/fork-name.git\" + } + } + } + }") + +(test-assert "default-json" + (specifications-equal? + (let ((event (json->forgejo-pull-request-event default-pull-request-json))) + (forgejo-pull-request->specification + (forgejo-pull-request-event-pull-request event))) + (specification + (name 'forgejo-pull-requests-project-name-test-branch-1) + (build '(channels . (project-name))) + (channels + (cons* (channel + (name 'project-name) + (url "https://forgejo.instance.test/source-repo/fork-name.git") + (branch "test-branch")) + %default-channels)) + (priority 1) + (period 3600) + (systems (list "x86_64-linux"))))) -- 2.46.0 From unknown Sun Jun 22 04:04:30 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#74769] [PATCH Cuirass 3/4] tests: Explicit Gitlab endpoint related variables. Resent-From: Romain GARBAGE Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 10 Dec 2024 16:10:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74769 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74769@debbugs.gnu.org Cc: ludovic.courtes@inria.fr, Romain GARBAGE Received: via spool by 74769-submit@debbugs.gnu.org id=B74769.17338469965792 (code B ref 74769); Tue, 10 Dec 2024 16:10:06 +0000 Received: (at 74769) by debbugs.gnu.org; 10 Dec 2024 16:09:56 +0000 Received: from localhost ([127.0.0.1]:59212 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL2o8-0001VF-4b for submit@debbugs.gnu.org; Tue, 10 Dec 2024 11:09:56 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:32084) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL2o3-0001TJ-CI for 74769@debbugs.gnu.org; Tue, 10 Dec 2024 11:09:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TJJwp1j+lEv0QRkr3b5qR3WAeV3Kc1+vnZfhvyMLHp8=; b=pUgIKPDrHSA5WeqRu0XmneVWkvUHg+T44cY1N02jtDgbVfIQbh5NpEME oaXxEYiQMjg0b/Jmi2jztS1CWRe4UVT2mVwmjZUoT+xBp3kR/Y+CDh1Te J5j+TCrCmSm2zhdqKQqcEl6oO+WJoeEG1IVbiT9xpBybSrnG8h5fN3+MZ k=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=romain.garbage@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.12,222,1728943200"; d="scan'208";a="103964552" Received: from unknown (HELO guix-A102.bordeaux.inria.fr) ([193.50.110.191]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2024 17:09:40 +0100 From: Romain GARBAGE Date: Tue, 10 Dec 2024 17:09:27 +0100 Message-ID: <20241210160929.14180-3-romain.garbage@inria.fr> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241210160929.14180-1-romain.garbage@inria.fr> References: <20241210160929.14180-1-romain.garbage@inria.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * tests/http.scm: Rename mr-* variables to gitlab-merge-request-*. --- tests/http.scm | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/http.scm b/tests/http.scm index 7b8ab03..9712787 100644 --- a/tests/http.scm +++ b/tests/http.scm @@ -90,7 +90,7 @@ (channel . "packages") (directory . "dir2"))))))) -(define mr-json-open +(define gitlab-merge-request-json-open "{ \"event_type\": \"merge_request\", \"project\": { @@ -108,7 +108,7 @@ } }") -(define mr-json-close +(define gitlab-merge-request-json-close "{ \"event_type\": \"merge_request\", \"project\": { @@ -126,8 +126,8 @@ } }") -(define mr-spec - (let ((event (json->gitlab-event mr-json-open))) +(define gitlab-merge-request-spec + (let ((event (json->gitlab-event gitlab-merge-request-json-open))) (gitlab-merge-request->specification (gitlab-event-value event) (gitlab-event-project event)))) @@ -438,24 +438,24 @@ (specification-channels spec))))))) (test-equal "/admin/gitlab/event creates a spec from a new merge request" - (specification-name mr-spec) + (specification-name gitlab-merge-request-spec) (begin - (http-post-json (test-cuirass-uri "/admin/gitlab/event") mr-json-open) - (specification-name (db-get-specification (specification-name mr-spec))))) + (http-post-json (test-cuirass-uri "/admin/gitlab/event") gitlab-merge-request-json-open) + (specification-name (db-get-specification (specification-name gitlab-merge-request-spec))))) (test-equal "/admin/gitlab/event error when a merge request has already been created" 400 - (response-code (http-post-json (test-cuirass-uri "/admin/gitlab/event") mr-json-open))) + (response-code (http-post-json (test-cuirass-uri "/admin/gitlab/event") gitlab-merge-request-json-open))) (test-assert "/admin/gitlab/event removes a spec from a closed merge request" (begin - (http-post-json (test-cuirass-uri "/admin/gitlab/event") mr-json-close) - (not (db-get-specification (specification-name mr-spec))))) + (http-post-json (test-cuirass-uri "/admin/gitlab/event") gitlab-merge-request-json-close) + (not (db-get-specification (specification-name gitlab-merge-request-spec))))) (test-equal "/admin/gitlab/event error when a merge request has already been closed" 404 (response-code (http-post-json (test-cuirass-uri "/admin/gitlab/event") - mr-json-close))) + gitlab-merge-request-json-close))) (test-assert "db-close" (begin -- 2.46.0 From unknown Sun Jun 22 04:04:30 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#74769] [PATCH Cuirass 4/4] http: Add admin/forgejo/event. Resent-From: Romain GARBAGE Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 10 Dec 2024 16:10:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74769 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74769@debbugs.gnu.org Cc: ludovic.courtes@inria.fr, Romain GARBAGE Received: via spool by 74769-submit@debbugs.gnu.org id=B74769.17338469985812 (code B ref 74769); Tue, 10 Dec 2024 16:10:07 +0000 Received: (at 74769) by debbugs.gnu.org; 10 Dec 2024 16:09:58 +0000 Received: from localhost ([127.0.0.1]:59214 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL2o9-0001VN-Ka for submit@debbugs.gnu.org; Tue, 10 Dec 2024 11:09:58 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:32084) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL2o4-0001TJ-Ae for 74769@debbugs.gnu.org; Tue, 10 Dec 2024 11:09:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qI+CsIJ2GocqiGNyWBT0ZRymw9jOh4mnDHHKwu9FCVk=; b=K88Ux1JeXmz3PmSr3XMAKERA0gi5Ase3d2/MSkIp9Q8Q+fec5Bmfwte5 uQ5o32m5W95Ftg0QzhRJFutd5079GvqnbMnqlj7ZLhZabRzrMfOk/Tlq2 v5MhV+F6yymwP8gH/AX4Cv9iYc2j1QLD32FRo50aylQyiY8NeMiWP6g28 U=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=romain.garbage@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.12,222,1728943200"; d="scan'208";a="103964554" Received: from unknown (HELO guix-A102.bordeaux.inria.fr) ([193.50.110.191]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2024 17:09:41 +0100 From: Romain GARBAGE Date: Tue, 10 Dec 2024 17:09:28 +0100 Message-ID: <20241210160929.14180-4-romain.garbage@inria.fr> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241210160929.14180-1-romain.garbage@inria.fr> References: <20241210160929.14180-1-romain.garbage@inria.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * src/cuirass/http.scm (url-handler): Add "/admin/forgejo/event". * tests/http.scm: Add tests for the "/admin/forgejo/event" endpoint. * doc/cuirass.texi: Reorganize "Interfacing Cuirass..." section. Add documentation for the "/admin/forgejo/event" endpoint. --- doc/cuirass.texi | 38 ++++++++++++++++-- src/cuirass/http.scm | 62 +++++++++++++++++++++++++++++ tests/http.scm | 92 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 186 insertions(+), 6 deletions(-) diff --git a/doc/cuirass.texi b/doc/cuirass.texi index 13739c9..895d91f 100644 --- a/doc/cuirass.texi +++ b/doc/cuirass.texi @@ -1284,11 +1284,14 @@ This request accepts a mandatory parameter. Limit query result to nr elements. This parameter is @emph{mandatory}. @end table -@section Interfacing Cuirass with a GitLab Server +@section Interfacing Cuirass with a Git forge -Cuirass supports integration with GitLab through the @dfn{webhook} mechanism: -a POST request is sent by a GitLab instance whenever a specific event is -triggered. So far, Cuirass only support merge-request events. +Cuirass supports integration with various forges through the +@dfn{webhook} mechanism: a POST request is sent by the forge instance +whenever a specific event is triggered. So far, Cuirass only support +merge-request/pull-request events. + +@subsection Interfacing with a GitLab Server Sending a merge request event on the @code{/admin/gitlab/event} endpoint allows controlling a specific jobset related to the merge request @@ -1330,6 +1333,33 @@ A JSON list of strings. Each string must be a supported system, i.e. @code{"systems": [ "x86_64-linux", "aarch64-linux" ]} @end table +@subsection Interfacing with a Forgejo Server + +Sending a merge request event on the @code{/admin/forgejo/event} +endpoint allows controlling a specific jobset related to the merge +request content. This interface expect the JSON data to contain the +following keys: +@table @code +@item "action" +@item "pull_request.number" +@item "pull_request.state" +@item "pull_request.base.label" +@item "pull_request.base.ref" +@item "pull_request.base.sha" +@item "pull_request.base.repo.name" +@item "pull_request.base.repo.clone_url" +@item "pull_request.head.label" +@item "pull_request.head.ref" +@item "pull_request.head.sha" +@item "pull_request.head.repo.name" +@item "pull_request.head.repo.clone_url" +@end table + +The resulting jobset, named as +@code{forgejo-pull-requests-@var{pull_request}.@var{base}.@var{pull_request}.@var{name}-@var{pull_request}.@var{head}.@var{ref}-@var{pull_request}.@var{number}}, +is set to build the channel corresponding to the source branch in the +merge request data with a priority of 1. + @c ********************************************************************* @node Database @chapter Database schema diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm index 881e803..a9c3cda 100644 --- a/src/cuirass/http.scm +++ b/src/cuirass/http.scm @@ -27,6 +27,7 @@ #:use-module (cuirass config) #:use-module (cuirass database) #:use-module ((cuirass base) #:select (evaluation-log-file)) + #:use-module (cuirass forgejo) #:use-module (cuirass gitlab) #:use-module (cuirass metrics) #:use-module (cuirass utils) @@ -779,6 +780,67 @@ return DEFAULT." (event-type (respond-json-with-error 400 (format #f "Event type \"~a\" not supported." event-type)))) (respond-json-with-error 400 "This API only supports JSON.")))) + ;; Define an API for Forgejo events + (('POST "admin" "forgejo" "event") + (let* ((params (utf8->string body)) + (event-type (assoc-ref (request-headers request) 'x-forgejo-event)) + (content-type (assoc-ref (request-headers request) 'content-type)) + (json? (equal? (car content-type) + 'application/json))) + (if json? + (match event-type + ("pull_request" + (let* ((event (json->forgejo-pull-request-event params)) + (pull-request (forgejo-pull-request-event-pull-request event)) + (spec (forgejo-pull-request->specification pull-request)) + (spec-name (specification-name spec))) + (match (forgejo-pull-request-event-action event) + ;; New pull request. + ((or 'opened 'reopened) + (if (not (db-get-specification spec-name)) + (begin + (db-add-or-update-specification spec) + + (unless (call-bridge `(register-jobset ,spec-name) + bridge) + (log-warning + "cannot notify bridge of the addition of jobset '~a'" + spec-name)) + (respond + (build-response #:code 200 + #:headers + `((location . ,(string->uri-reference "/")))) + #:body "")) + (begin + (log-warning "jobset '~a' already exists" spec-name) + (respond-json-with-error 400 "Jobset already exists.")))) + ;; Closed or merged pull request. + ('closed + (if (db-get-specification spec-name) + (begin + (call-bridge `(remove-jobset ,spec-name) bridge) + (log-info "Removed jobset '~a'" spec-name) + (respond + (build-response #:code 200 + #:headers + `((location . ,(string->uri-reference "/")))) + #:body "")) + (begin + (log-warning "cannot find jobset '~a'" spec-name) + (respond-json-with-error 404 "Jobset not found.")))) + ;; 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."))) + (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.")))) + (('POST "admin" "specification" "add") (let* ((spec (body->specification body)) (name (specification-name spec))) diff --git a/tests/http.scm b/tests/http.scm index 9712787..9393043 100644 --- a/tests/http.scm +++ b/tests/http.scm @@ -22,6 +22,7 @@ (use-modules ((cuirass base) #:select (%bridge-socket-file-name)) (cuirass http) (cuirass database) + (cuirass forgejo) (cuirass gitlab) (cuirass specification) (cuirass utils) @@ -43,8 +44,9 @@ (call-with-values (lambda () (http-get uri)) (lambda (response body) body))) -(define (http-post-json uri body) - (http-post uri #:body body #:headers '((content-type application/json)))) +(define* (http-post-json uri body #:optional (extra-headers '())) + (http-post uri #:body body #:headers (append '((content-type application/json)) + extra-headers))) (define (wait-until-ready port) ;; Wait until the server is accepting connections. @@ -132,6 +134,65 @@ (gitlab-event-value event) (gitlab-event-project event)))) +(define forgejo-pull-request-json-open + "{ + \"action\": \"opened\", + \"pull_request\": { + \"number\": 1, + \"state\": \"open\", + \"base\": { + \"label\": \"base-label\", + \"ref\": \"base-branch\", + \"sha\": \"666af40e8a059fa05c7048a7ac4f2eccbbd0183b\", + \"repo\": { + \"name\": \"project-name\", + \"clone_url\": \"https://forgejo.instance.test/base-repo/project-name.git\" + } + }, + \"head\": { + \"label\": \"test-label\", + \"ref\": \"test-branch\", + \"sha\": \"582af40e8a059fa05c7048a7ac4f2eccbbd0183b\", + \"repo\": { + \"name\": \"fork-name\", + \"clone_url\": \"https://forgejo.instance.test/source-repo/fork-name.git\" + } + } + } + }") + +(define forgejo-pull-request-json-close + "{ + \"action\": \"closed\", + \"pull_request\": { + \"number\": 1, + \"state\": \"closed\", + \"base\": { + \"label\": \"base-label\", + \"ref\": \"base-branch\", + \"sha\": \"666af40e8a059fa05c7048a7ac4f2eccbbd0183b\", + \"repo\": { + \"name\": \"project-name\", + \"clone_url\": \"https://forgejo.instance.test/base-repo/project-name.git\" + } + }, + \"head\": { + \"label\": \"test-label\", + \"ref\": \"test-branch\", + \"sha\": \"582af40e8a059fa05c7048a7ac4f2eccbbd0183b\", + \"repo\": { + \"name\": \"fork-name\", + \"clone_url\": \"https://forgejo.instance.test/source-repo/fork-name.git\" + } + } + } + }") + +(define forgejo-pull-request-specification + (forgejo-pull-request->specification + (forgejo-pull-request-event-pull-request + (json->forgejo-pull-request-event forgejo-pull-request-json-open)))) + (define-syntax-rule (with-cuirass-register exp ...) (with-guix-daemon (let ((pid #f)) @@ -457,6 +518,33 @@ (response-code (http-post-json (test-cuirass-uri "/admin/gitlab/event") gitlab-merge-request-json-close))) + (test-equal "/admin/forgejo/event creates a spec from a new pull request" + (specification-name forgejo-pull-request-specification) + (begin + (http-post-json (test-cuirass-uri "/admin/forgejo/event") + forgejo-pull-request-json-open + '((x-forgejo-event . "pull_request"))) + (specification-name (db-get-specification (specification-name forgejo-pull-request-specification))))) + + (test-equal "/admin/forgejo/event error when a pull request has already been created" + 400 + (response-code (http-post-json (test-cuirass-uri "/admin/forgejo/event") + forgejo-pull-request-json-open + '((x-forgejo-event . "pull_request"))))) + + (test-assert "/admin/forgejo/event removes a spec from a closed pull request" + (begin + (http-post-json (test-cuirass-uri "/admin/forgejo/event") + forgejo-pull-request-json-close + '((x-forgejo-event . "pull_request"))) + (not (db-get-specification (specification-name forgejo-pull-request-specification))))) + + (test-equal "/admin/forgejo/event error when a pull request has already been closed" + 404 + (response-code (http-post-json (test-cuirass-uri "/admin/forgejo/event") + forgejo-pull-request-json-close + '((x-forgejo-event . "pull_request"))))) + (test-assert "db-close" (begin (db-close (%db)) -- 2.46.0 From unknown Sun Jun 22 04:04:30 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#74769] [PATCH Cuirass 2/4] forgejo: Add module for Forgejo JSON objects definition. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 12 Dec 2024 13:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74769 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Romain GARBAGE Cc: 74769@debbugs.gnu.org Received: via spool by 74769-submit@debbugs.gnu.org id=B74769.17340104653678 (code B ref 74769); Thu, 12 Dec 2024 13:35:02 +0000 Received: (at 74769) by debbugs.gnu.org; 12 Dec 2024 13:34:25 +0000 Received: from localhost ([127.0.0.1]:38205 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLjKe-0000xB-Mf for submit@debbugs.gnu.org; Thu, 12 Dec 2024 08:34:24 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:28785) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLjKb-0000wm-T9 for 74769@debbugs.gnu.org; Thu, 12 Dec 2024 08:34:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version:content-transfer-encoding; bh=c/nZ/OtR1R/1j+Kh962d47dxKm37PiK92U4IMJS42Og=; b=kNrOK4Vt5j2sO6Wu+NofH/kS4twNHZGItGmlbYYR3mIqrWRpj2VjZA1T fxcaBzJ/CQ/QWl6rn/kDFbEOYLNuwZZMyDdLkyOZ/pQKt40n9dbC3WRoF uQiRThaLtD1/TE4LZYDA1wnDuEG/nnNEBG5o00BoSUQd2RosWVYAu0cdD 4=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=ludovic.courtes@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.12,228,1728943200"; d="scan'208";a="104159160" Received: from unknown (HELO ribbon) ([193.50.110.52]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2024 14:34:12 +0100 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= In-Reply-To: <20241210160929.14180-2-romain.garbage@inria.fr> (Romain GARBAGE's message of "Tue, 10 Dec 2024 17:09:26 +0100") References: <20241210160929.14180-1-romain.garbage@inria.fr> <20241210160929.14180-2-romain.garbage@inria.fr> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Duodi 22 Frimaire an 233 de la =?UTF-8?Q?R=C3=A9volution,?= jour de la =?UTF-8?Q?Bruy=C3=A8re?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Thu, 12 Dec 2024 14:34:10 +0100 Message-ID: <87h6799ga5.fsf@inria.fr> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi! Very nice! :-) Romain GARBAGE skribis: > * Makefile.am: Add src/cuirass/forgejo.scm and tests/forgejo.scm. > * src/cuirass/forgejo.scm: Add , > , , > and record types. > (forgejo-pull-request->specification): New variable. > * tests/forgejo.scm: Add tests. > > fixup tests Leftover? One thing, though: > +(define* (forgejo-pull-request->specification pull-request #:optional (c= uirass-options #f)) > + "Returns a SPECIFICATION built out of a FORGEJO-PULL-REQUEST." > + (let* ((source-repo-reference (forgejo-pull-request-head pull-request)) > + (project-name (forgejo-repository-name > + (forgejo-repository-reference-repository > + (forgejo-pull-request-base pull-request)))) > + (source-branch (forgejo-repository-reference-ref source-repo-re= ference)) > + (source-url (forgejo-repository-url > + (forgejo-repository-reference-repository source-re= po-reference))) > + (id (forgejo-pull-request-number pull-request)) > + (name-prefix (if (and cuirass-options > + (jobset-options-name-prefix cuirass-optio= ns)) > + (jobset-options-name-prefix cuirass-options) The =E2=80=98jobset-options-*=E2=80=99 variables are unbound. I understand= the goal is to share as defined in (cuirass gitlab), but perhaps that should either be made clearly, or just left out for now. Thanks! Ludo=E2=80=99. From unknown Sun Jun 22 04:04:30 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#74769] [PATCH Cuirass v2 1/7] tests: Move procedure definition. References: <20241210160824.31748-1-romain.garbage@inria.fr> In-Reply-To: <20241210160824.31748-1-romain.garbage@inria.fr> Resent-From: Romain GARBAGE Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 12 Dec 2024 16:00:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74769 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74769@debbugs.gnu.org Cc: ludovic.courtes@inria.fr, Romain GARBAGE Received: via spool by 74769-submit@debbugs.gnu.org id=B74769.17340191553553 (code B ref 74769); Thu, 12 Dec 2024 16:00:03 +0000 Received: (at 74769) by debbugs.gnu.org; 12 Dec 2024 15:59:15 +0000 Received: from localhost ([127.0.0.1]:39975 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLlao-0000uq-2p for submit@debbugs.gnu.org; Thu, 12 Dec 2024 10:59:15 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:36970) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLlaj-0000u3-50 for 74769@debbugs.gnu.org; Thu, 12 Dec 2024 10:59:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=SNm9hoixEYB9xCpt/5m/VDAQ1eQMm21+KbvaCLYwlQc=; b=hVKnEOPgKwOxqTWQLEPA0FGjCZn7Yttkbf2/ofqudxOsn2KZLVmdAycc KtXJ7PzkX+F8qUcnkvHMBX4PJNLOPXB/oxaCgfJDa9a4UrZR+J8Xbs+2x t4xoNyMAPCu6wq+RPMkNeA8te1Bf9p3+W9/wFlvhhwSo9Jnqpmt+zo6az o=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=romain.garbage@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.12,229,1728943200"; d="scan'208";a="104178636" Received: from unknown (HELO guix-A102.bordeaux.inria.fr) ([193.50.110.191]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2024 16:58:58 +0100 From: Romain GARBAGE Date: Thu, 12 Dec 2024 16:57:49 +0100 Message-ID: <20241212155845.27344-1-romain.garbage@inria.fr> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * tests/common.scm (specifications-equal?): New variable. * tests/gitlab.scm (specifications-equal?): Remove variable. --- tests/common.scm | 30 +++++++++++++++++++++++++++++- tests/gitlab.scm | 24 ------------------------ 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/tests/common.scm b/tests/common.scm index a807498..5054ea0 100644 --- a/tests/common.scm +++ b/tests/common.scm @@ -20,7 +20,9 @@ #:use-module ((cuirass base) #:select (%bridge-socket-file-name)) #:use-module (cuirass database) #:use-module (cuirass parameters) + #:use-module (cuirass specification) #:use-module (cuirass utils) + #:use-module (guix channels) #:use-module ((fibers scheduler) #:select (current-scheduler)) #:use-module (ice-9 popen) #:use-module (ice-9 rdelim) @@ -28,7 +30,8 @@ retry test-init-db! with-guix-daemon - wait-for-bridge)) + wait-for-bridge + specifications-equal?)) (define %db (make-parameter #f)) @@ -121,3 +124,28 @@ Return the socket on success and #f on failure." (sockaddr:path address) (strerror (system-error-errno args))) #f))))))) + +(define (specifications-equal? spec1 spec2) + "Return true if SPEC2 and SPEC2 are equivalent, false otherwise." + (and (eq? (specification-name spec1) + (specification-name spec2)) + (equal? (specification-build spec1) + (specification-build spec2)) + (= (specification-priority spec1) + (specification-priority spec2)) + (= (specification-period spec1) + (specification-period spec2)) + (equal? (specification-systems spec1) + (specification-systems spec2)) + (equal? (map channel-name + (specification-channels spec1)) + (map channel-name + (specification-channels spec2))) + (equal? (map channel-url + (specification-channels spec1)) + (map channel-url + (specification-channels spec2))) + (equal? (map channel-branch + (specification-channels spec1)) + (map channel-branch + (specification-channels spec2))))) diff --git a/tests/gitlab.scm b/tests/gitlab.scm index ca6cad5..adf94cc 100644 --- a/tests/gitlab.scm +++ b/tests/gitlab.scm @@ -157,30 +157,6 @@ } }") -(define (specifications-equal? spec1 spec2) - (and (eq? (specification-name spec1) - (specification-name spec2)) - (equal? (specification-build spec1) - (specification-build spec2)) - (= (specification-priority spec1) - (specification-priority spec2)) - (= (specification-period spec1) - (specification-period spec2)) - (equal? (specification-systems spec1) - (specification-systems spec2)) - (equal? (map channel-name - (specification-channels spec1)) - (map channel-name - (specification-channels spec2))) - (equal? (map channel-url - (specification-channels spec1)) - (map channel-url - (specification-channels spec2))) - (equal? (map channel-branch - (specification-channels spec1)) - (map channel-branch - (specification-channels spec2))))) - (test-assert "default-json" (specifications-equal? (let ((event (json->gitlab-event default-mr-json))) base-commit: e96f0887923d4d1cd4e35073fcffdb978d7e1e10 -- 2.46.0 From unknown Sun Jun 22 04:04:30 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#74769] [PATCH Cuirass v2 2/7] tests: Rename specifications-equal? procedure. Resent-From: Romain GARBAGE Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 12 Dec 2024 16:00:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74769 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74769@debbugs.gnu.org Cc: ludovic.courtes@inria.fr, Romain GARBAGE Received: via spool by 74769-submit@debbugs.gnu.org id=B74769.17340191563561 (code B ref 74769); Thu, 12 Dec 2024 16:00:04 +0000 Received: (at 74769) by debbugs.gnu.org; 12 Dec 2024 15:59:16 +0000 Received: from localhost ([127.0.0.1]:39980 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLlat-0000vH-JZ for submit@debbugs.gnu.org; Thu, 12 Dec 2024 10:59:15 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:36970) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLlan-0000u3-Fo for 74769@debbugs.gnu.org; Thu, 12 Dec 2024 10:59:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oM/xlbMW47mn6WUZHG59yh0cGM5by5LgtssvEC8NynQ=; b=HKXqOvXpw/my+IAkUB7S49gZwC+kdcLjnIZ45tQRn+i3nxnLuZuUGQte TzKj+yJZal0oahr+OABS+n59oNi4DNQ4wRMdf2qcxUnjSUCxsI6wVPbkl yp1XG/ZahDVlLkczvO0ZCCSb7U4FUFbQwr61cIWKh7x8piziYe0JJoobG I=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=romain.garbage@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.12,229,1728943200"; d="scan'208";a="104178637" Received: from unknown (HELO guix-A102.bordeaux.inria.fr) ([193.50.110.191]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2024 16:58:58 +0100 From: Romain GARBAGE Date: Thu, 12 Dec 2024 16:57:50 +0100 Message-ID: <20241212155845.27344-2-romain.garbage@inria.fr> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241212155845.27344-1-romain.garbage@inria.fr> References: <20241212155845.27344-1-romain.garbage@inria.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * tests/common.scm (specifications=?): New variable. (specifications-equal?): Remove variable. * tests/gitlab.scm: Use new variable name. --- tests/common.scm | 4 ++-- tests/gitlab.scm | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/common.scm b/tests/common.scm index 5054ea0..488d8db 100644 --- a/tests/common.scm +++ b/tests/common.scm @@ -31,7 +31,7 @@ test-init-db! with-guix-daemon wait-for-bridge - specifications-equal?)) + specifications=?)) (define %db (make-parameter #f)) @@ -125,7 +125,7 @@ Return the socket on success and #f on failure." (strerror (system-error-errno args))) #f))))))) -(define (specifications-equal? spec1 spec2) +(define (specifications=? spec1 spec2) "Return true if SPEC2 and SPEC2 are equivalent, false otherwise." (and (eq? (specification-name spec1) (specification-name spec2)) diff --git a/tests/gitlab.scm b/tests/gitlab.scm index adf94cc..117a94d 100644 --- a/tests/gitlab.scm +++ b/tests/gitlab.scm @@ -158,7 +158,7 @@ }") (test-assert "default-json" - (specifications-equal? + (specifications=? (let ((event (json->gitlab-event default-mr-json))) (gitlab-merge-request->specification (gitlab-event-value event) @@ -177,7 +177,7 @@ (systems (list "x86_64-linux"))))) (test-assert "custom-json" - (specifications-equal? + (specifications=? (let ((event (json->gitlab-event custom-mr-json))) (gitlab-merge-request->specification (gitlab-event-value event) @@ -197,7 +197,7 @@ "aarch64-linux"))))) (test-assert "custom-json-multiple-packages" - (specifications-equal? + (specifications=? (let ((event (json->gitlab-event custom-mr-json-multiple-packages))) (gitlab-merge-request->specification (gitlab-event-value event) @@ -216,7 +216,7 @@ (systems (list "x86_64-linux"))))) (test-assert "custom-json-name-prefix" - (specifications-equal? + (specifications=? (let ((event (json->gitlab-event custom-mr-json-name-prefix))) (gitlab-merge-request->specification (gitlab-event-value event) @@ -235,7 +235,7 @@ (systems (list "x86_64-linux"))))) (test-assert "custom-json-build-all" - (specifications-equal? + (specifications=? (let ((event (json->gitlab-event custom-mr-json-build-all))) (gitlab-merge-request->specification (gitlab-event-value event) -- 2.46.0 From unknown Sun Jun 22 04:04:30 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#74769] [PATCH Cuirass v2 3/7] forges: Add module for common forges utilities. Resent-From: Romain GARBAGE Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 12 Dec 2024 16:00:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74769 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74769@debbugs.gnu.org Cc: ludovic.courtes@inria.fr, Romain GARBAGE Received: via spool by 74769-submit@debbugs.gnu.org id=B74769.17340191593588 (code B ref 74769); Thu, 12 Dec 2024 16:00:06 +0000 Received: (at 74769) by debbugs.gnu.org; 12 Dec 2024 15:59:19 +0000 Received: from localhost ([127.0.0.1]:39982 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLlau-0000vO-2l for submit@debbugs.gnu.org; Thu, 12 Dec 2024 10:59:19 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:36970) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLlao-0000u3-L6 for 74769@debbugs.gnu.org; Thu, 12 Dec 2024 10:59:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RE8lBaf/pTi8b5H510KVAwwBQqm/BYAxFMMjT/H7oIU=; b=eWZu37myBP+Ag44RN8GtY0e0gGE3Shsp8Yg5Z2Nbfnore9lEl5fNceY/ G1cPYUWF0VxLKIHI0cYXwV3MhpO+3GXzQcv3tux7ygwTxpTZtrVt2zAWJ Gn/30swDfeMnqRrCkOl9bZGxQ9Nr7R8xFnTR7HHG4Y4CJEDygsa9bORw5 g=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=romain.garbage@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.12,229,1728943200"; d="scan'208";a="104178640" Received: from unknown (HELO guix-A102.bordeaux.inria.fr) ([193.50.110.191]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2024 16:58:59 +0100 From: Romain GARBAGE Date: Thu, 12 Dec 2024 16:57:51 +0100 Message-ID: <20241212155845.27344-3-romain.garbage@inria.fr> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241212155845.27344-1-romain.garbage@inria.fr> References: <20241212155845.27344-1-romain.garbage@inria.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * Makefile.am: Update module list. * src/cuirass/forges.scm: New module. * src/cuirass/gitlab.scm: Moved to src/cuirass/forges/gitlab.scm. * src/cuirass/http.scm, tests/gitlab.scm, tests/http.scm: Update module header. --- Makefile.am | 3 +- src/cuirass/forges.scm | 73 +++++++++++++++++++++++++++++ src/cuirass/{ => forges}/gitlab.scm | 41 ++-------------- src/cuirass/http.scm | 2 +- tests/gitlab.scm | 2 +- tests/http.scm | 2 +- 6 files changed, 81 insertions(+), 42 deletions(-) create mode 100644 src/cuirass/forges.scm rename src/cuirass/{ => forges}/gitlab.scm (80%) diff --git a/Makefile.am b/Makefile.am index 1123eb1..2de3419 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,7 +52,8 @@ dist_pkgmodule_DATA = \ src/cuirass/store.scm \ src/cuirass/base.scm \ src/cuirass/database.scm \ - src/cuirass/gitlab.scm \ + src/cuirass/forges.scm \ + src/cuirass/forges/gitlab.scm \ src/cuirass/http.scm \ src/cuirass/logging.scm \ src/cuirass/mail.scm \ diff --git a/src/cuirass/forges.scm b/src/cuirass/forges.scm new file mode 100644 index 0000000..c05e266 --- /dev/null +++ b/src/cuirass/forges.scm @@ -0,0 +1,73 @@ +;;; forges.scm -- Common forges utilities +;;; Copyright © 2024 Romain Garbage +;;; +;;; This file is part of Cuirass. +;;; +;;; Cuirass is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; Cuirass is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with Cuirass. If not, see . + +(define-module (cuirass forges) + #:use-module (cuirass specification) + #:use-module (json) + #:use-module (ice-9 match) + #:export (make-jobset-options + jobset-options? + json->jobset-options + jobset-options-name-prefix + jobset-options-build + jobset-options-period + jobset-options-priority + jobset-options-systems)) + +;;; Commentary: +;;; +;;; This module implements objects and default values used in the various +;;; forges modules. +;;; +;;; Code: + +;; This mapping defines a specific JSON dictionary used for tweaking Cuirass +;; options. It is not included in the JSON data sent by default by Gitlab and +;; must be used through the custom template mechanism (see documentation). +(define-json-mapping + make-jobset-options + jobset-options? + json->jobset-options + (name-prefix jobset-options-name-prefix "name_prefix" + (lambda (v) + (if (unspecified? v) + #f + (string->symbol v)))) + (build jobset-options-build "build" + (match-lambda + ((? unspecified?) + #f) + (((key . val) _ ...) + (cons (string->symbol key) (vector->list val))) + (str + (string->symbol str)))) + (period jobset-options-period "period" + (lambda (v) + (if (unspecified? v) + #f + v))) + (priority jobset-options-priority "priority" + (lambda (v) + (if (unspecified? v) + #f + v))) + (systems jobset-options-systems "systems" + (lambda (v) + (if (unspecified? v) + #f + (vector->list v))))) diff --git a/src/cuirass/gitlab.scm b/src/cuirass/forges/gitlab.scm similarity index 80% rename from src/cuirass/gitlab.scm rename to src/cuirass/forges/gitlab.scm index fcb93bb..56e875a 100644 --- a/src/cuirass/gitlab.scm +++ b/src/cuirass/forges/gitlab.scm @@ -1,5 +1,5 @@ ;;;; gitlab.scm -- Gitlab JSON mappings -;;; Copyright © 2024 Romain Garbage +;;; Copyright © 2024 Romain Garbage ;;; ;;; This file is part of Cuirass. ;;; @@ -16,7 +16,8 @@ ;;; You should have received a copy of the GNU General Public License ;;; along with Cuirass. If not, see . -(define-module (cuirass gitlab) +(define-module (cuirass forges gitlab) + #:use-module (cuirass forges) #:use-module (cuirass specification) #:use-module (json) #:use-module (guix channels) @@ -60,42 +61,6 @@ (name gitlab-project-name "name" string->symbol)) -;; This mapping defines a specific JSON dictionary used for tweaking Cuirass -;; options. It is not included in the JSON data sent by default by Gitlab and -;; must be used through the custom template mechanism (see documentation). -(define-json-mapping - make-jobset-options - jobset-options? - json->jobset-options - (name-prefix jobset-options-name-prefix "name_prefix" - (lambda (v) - (if (unspecified? v) - #f - (string->symbol v)))) - (build jobset-options-build "build" - (match-lambda - ((? unspecified?) - #f) - (((key . val) _ ...) - (cons (string->symbol key) (vector->list val))) - (str - (string->symbol str)))) - (period jobset-options-period "period" - (lambda (v) - (if (unspecified? v) - #f - v))) - (priority jobset-options-priority "priority" - (lambda (v) - (if (unspecified? v) - #f - v))) - (systems jobset-options-systems "systems" - (lambda (v) - (if (unspecified? v) - #f - (vector->list v))))) - (define-json-mapping make-gitlab-merge-request gitlab-merge-request? diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm index 881e803..8ea929f 100644 --- a/src/cuirass/http.scm +++ b/src/cuirass/http.scm @@ -27,7 +27,7 @@ #:use-module (cuirass config) #:use-module (cuirass database) #:use-module ((cuirass base) #:select (evaluation-log-file)) - #:use-module (cuirass gitlab) + #:use-module (cuirass forges gitlab) #:use-module (cuirass metrics) #:use-module (cuirass utils) #:use-module (cuirass logging) diff --git a/tests/gitlab.scm b/tests/gitlab.scm index 117a94d..df221bf 100644 --- a/tests/gitlab.scm +++ b/tests/gitlab.scm @@ -16,7 +16,7 @@ ;;; You should have received a copy of the GNU General Public License ;;; along with Cuirass. If not, see . -(use-modules (cuirass gitlab) +(use-modules (cuirass forges gitlab) (cuirass specification) (cuirass utils) (tests common) diff --git a/tests/http.scm b/tests/http.scm index 7b8ab03..541f30d 100644 --- a/tests/http.scm +++ b/tests/http.scm @@ -22,7 +22,7 @@ (use-modules ((cuirass base) #:select (%bridge-socket-file-name)) (cuirass http) (cuirass database) - (cuirass gitlab) + (cuirass forges gitlab) (cuirass specification) (cuirass utils) (tests common) -- 2.46.0 From unknown Sun Jun 22 04:04:30 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#74769] [PATCH Cuirass v2 4/7] forges: Define default values for specifications. Resent-From: Romain GARBAGE Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 12 Dec 2024 16:00:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74769 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74769@debbugs.gnu.org Cc: ludovic.courtes@inria.fr, Romain GARBAGE Received: via spool by 74769-submit@debbugs.gnu.org id=B74769.17340191603597 (code B ref 74769); Thu, 12 Dec 2024 16:00:07 +0000 Received: (at 74769) by debbugs.gnu.org; 12 Dec 2024 15:59:20 +0000 Received: from localhost ([127.0.0.1]:39986 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLlax-0000vp-L3 for submit@debbugs.gnu.org; Thu, 12 Dec 2024 10:59:20 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:36970) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLlaq-0000u3-CG for 74769@debbugs.gnu.org; Thu, 12 Dec 2024 10:59:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=48mp6pe0MYg4VAS8We11BI6B0263e24mgz3A2ArOdfM=; b=HUrPmCmWLVkrO+CRAh3bC2iPQdccrL/o3vswikREWfYJ11biD181kOC4 VP46+7DtGfufUWcgX3aZ3JDEa/hKQQIc5IHsAgcSy6sHhv7cqpw0CDoyn ZfI25A69ApKnIivv1gjxaX0bJeJW8sHLTdc4rpX+WXPErTDkD8ub/WyZx I=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=romain.garbage@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.12,229,1728943200"; d="scan'208";a="104178642" Received: from unknown (HELO guix-A102.bordeaux.inria.fr) ([193.50.110.191]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2024 16:58:59 +0100 From: Romain GARBAGE Date: Thu, 12 Dec 2024 16:57:52 +0100 Message-ID: <20241212155845.27344-4-romain.garbage@inria.fr> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241212155845.27344-1-romain.garbage@inria.fr> References: <20241212155845.27344-1-romain.garbage@inria.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * src/cuirass/forges.scm (%default-jobset-options-period, %default-jobset-options-priority, %default-jobset-options-systems): New variables. * src/cuirass/forges/gitlab.scm (gitlab-merge-request->specification), tests/gitlab.scm: Change hardcoded values to variables defined in the forges module. --- src/cuirass/forges.scm | 16 +++++++++++++++- src/cuirass/forges/gitlab.scm | 6 +++--- tests/gitlab.scm | 21 +++++++++++---------- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/cuirass/forges.scm b/src/cuirass/forges.scm index c05e266..56f4876 100644 --- a/src/cuirass/forges.scm +++ b/src/cuirass/forges.scm @@ -20,7 +20,11 @@ #:use-module (cuirass specification) #:use-module (json) #:use-module (ice-9 match) - #:export (make-jobset-options + #:export (%default-jobset-options-period + %default-jobset-options-priority + %default-jobset-options-systems + + make-jobset-options jobset-options? json->jobset-options jobset-options-name-prefix @@ -36,6 +40,16 @@ ;;; ;;; Code: +;; Default polling period for jobsets created using a forge module. +(define %default-jobset-options-period 3600) + +;; Default priority for jobsets created using a forge module. +(define %default-jobset-options-priority 5) + +;; Default target systems for jobsets created using a forge module. +(define %default-jobset-options-systems + (list "x86_64-linux")) + ;; This mapping defines a specific JSON dictionary used for tweaking Cuirass ;; options. It is not included in the JSON data sent by default by Gitlab and ;; must be used through the custom template mechanism (see documentation). diff --git a/src/cuirass/forges/gitlab.scm b/src/cuirass/forges/gitlab.scm index 56e875a..de2216f 100644 --- a/src/cuirass/forges/gitlab.scm +++ b/src/cuirass/forges/gitlab.scm @@ -123,15 +123,15 @@ (period (if (and cuirass-options (jobset-options-period cuirass-options)) (jobset-options-period cuirass-options) - 3600)) + %default-jobset-options-period)) (priority (if (and cuirass-options (jobset-options-priority cuirass-options)) (jobset-options-priority cuirass-options) - 1)) + %default-jobset-options-priority)) (systems (if (and cuirass-options (jobset-options-systems cuirass-options)) (jobset-options-systems cuirass-options) - (list "x86_64-linux")))) + %default-jobset-options-systems))) (specification (name spec-name) (build build) diff --git a/tests/gitlab.scm b/tests/gitlab.scm index df221bf..3409413 100644 --- a/tests/gitlab.scm +++ b/tests/gitlab.scm @@ -16,7 +16,8 @@ ;;; You should have received a copy of the GNU General Public License ;;; along with Cuirass. If not, see . -(use-modules (cuirass forges gitlab) +(use-modules (cuirass forges) + (cuirass forges gitlab) (cuirass specification) (cuirass utils) (tests common) @@ -172,9 +173,9 @@ (url "https://gitlab.instance.test/source-repo/fork-name.git") (branch "test-branch")) %default-channels)) - (priority 1) - (period 3600) - (systems (list "x86_64-linux"))))) + (priority %default-jobset-options-priority) + (period %default-jobset-options-period) + (systems %default-jobset-options-systems)))) (test-assert "custom-json" (specifications=? @@ -211,9 +212,9 @@ (url "https://gitlab.instance.test/source-repo/fork-name.git") (branch "test-branch")) %default-channels)) - (priority 1) - (period 3600) - (systems (list "x86_64-linux"))))) + (priority %default-jobset-options-priority) + (period %default-jobset-options-period) + (systems %default-jobset-options-systems)))) (test-assert "custom-json-name-prefix" (specifications=? @@ -230,9 +231,9 @@ (url "https://gitlab.instance.test/source-repo/fork-name.git") (branch "test-branch")) %default-channels)) - (priority 1) - (period 3600) - (systems (list "x86_64-linux"))))) + (priority %default-jobset-options-priority) + (period %default-jobset-options-period) + (systems %default-jobset-options-systems)))) (test-assert "custom-json-build-all" (specifications=? -- 2.46.0 From unknown Sun Jun 22 04:04:30 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#74769] [PATCH Cuirass v2 5/7] forgejo: Add module for Forgejo JSON objects definition. Resent-From: Romain GARBAGE Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 12 Dec 2024 16:00:11 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74769 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74769@debbugs.gnu.org Cc: ludovic.courtes@inria.fr, Romain GARBAGE Received: via spool by 74769-submit@debbugs.gnu.org id=B74769.17340191633604 (code B ref 74769); Thu, 12 Dec 2024 16:00:11 +0000 Received: (at 74769) by debbugs.gnu.org; 12 Dec 2024 15:59:23 +0000 Received: from localhost ([127.0.0.1]:39988 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLlay-0000vy-IJ for submit@debbugs.gnu.org; Thu, 12 Dec 2024 10:59:23 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:36970) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLlar-0000u3-BL for 74769@debbugs.gnu.org; Thu, 12 Dec 2024 10:59:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uuJaLNiXzxtTAja5nmSzgKWlJIWvV0W0ssew0kdhAjk=; b=Ohpbv40UMtm9xcGotqIcb2fWkkIxmMvKxFtDSCHl6MkSgXdjJVvD1wYW NYpyfrFwba80UNwv4gowgYXTFMw5L+Leiu7Fu953aMvdA4Aaj/z/dN1/i HSsmlwDe8xVKrtVV1uRXHNObFA6PeRWfQ38m+u4D91p+3ywRrv9M5JWOv M=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=romain.garbage@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.12,229,1728943200"; d="scan'208";a="104178645" Received: from unknown (HELO guix-A102.bordeaux.inria.fr) ([193.50.110.191]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2024 16:58:59 +0100 From: Romain GARBAGE Date: Thu, 12 Dec 2024 16:57:53 +0100 Message-ID: <20241212155845.27344-5-romain.garbage@inria.fr> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241212155845.27344-1-romain.garbage@inria.fr> References: <20241212155845.27344-1-romain.garbage@inria.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * Makefile.am: Add src/cuirass/forges/forgejo.scm and tests/forgejo.scm. * src/cuirass/forges/forgejo.scm: Add , , , and record types. (forgejo-pull-request->specification): New variable. * tests/forgejo.scm: Add tests. --- Makefile.am | 2 + src/cuirass/forges/forgejo.scm | 134 +++++++++++++++++++++++++++++++++ tests/forgejo.scm | 80 ++++++++++++++++++++ 3 files changed, 216 insertions(+) create mode 100644 src/cuirass/forges/forgejo.scm create mode 100644 tests/forgejo.scm diff --git a/Makefile.am b/Makefile.am index 2de3419..f38703e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -53,6 +53,7 @@ dist_pkgmodule_DATA = \ src/cuirass/base.scm \ src/cuirass/database.scm \ src/cuirass/forges.scm \ + src/cuirass/forges/forgejo.scm \ src/cuirass/forges/gitlab.scm \ src/cuirass/http.scm \ src/cuirass/logging.scm \ @@ -168,6 +169,7 @@ TESTS = \ ## tests/basic.sh # takes too long to execute tests/store.scm \ tests/database.scm \ + tests/forgejo.scm \ tests/gitlab.scm \ tests/http.scm \ tests/metrics.scm \ diff --git a/src/cuirass/forges/forgejo.scm b/src/cuirass/forges/forgejo.scm new file mode 100644 index 0000000..11133f4 --- /dev/null +++ b/src/cuirass/forges/forgejo.scm @@ -0,0 +1,134 @@ +;;; forgejo.scm -- Forgejo JSON mappings +;;; Copyright © 2024 Romain Garbage +;;; +;;; This file is part of Cuirass. +;;; +;;; Cuirass is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; Cuirass is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with Cuirass. If not, see . + +(define-module (cuirass forges forgejo) + #:use-module (cuirass specification) + #:use-module (cuirass forges) + #:use-module (json) + #:use-module (web http) + #:use-module (guix channels) + #:use-module (ice-9 match) + #:export (forgejo-pull-request-event-pull-request + forgejo-pull-request-event-action + json->forgejo-pull-request-event + + forgejo-repository-name + forgejo-repository-url + + json->forgejo-pull-request + + forgejo-pull-request->specification)) + +;;; Commentary: +;;; +;;; This module implements a subset of the Forgejo Webhook API described at +;;; . +;;; +;;; Code: + +;; This declares a specific header for internal consumption, specifically when +;; generating requests during tests. +(declare-opaque-header! "X-Forgejo-Event") + +(define-json-mapping + make-forgejo-repository + forgejo-repository? + json->forgejo-repository + (name forgejo-repository-name "name" + string->symbol) + (url forgejo-repository-url "clone_url")) + +;; This maps to the top level JSON object. +(define-json-mapping + make-forgejo-pull-request-event + forgejo-pull-request-event? + json->forgejo-pull-request-event + (action forgejo-pull-request-event-action "action" + string->symbol) + (pull-request forgejo-pull-request-event-pull-request "pull_request" + json->forgejo-pull-request)) + +(define-json-mapping + make-forgejo-pull-request + forgejo-pull-request? + json->forgejo-pull-request + (number forgejo-pull-request-number "number") + (base forgejo-pull-request-base "base" + json->forgejo-repository-reference) + (head forgejo-pull-request-head "head" + json->forgejo-repository-reference)) + +;; This mapping is used to define various JSON objects such as "base" or +;; "head". +(define-json-mapping + make-forgejo-repository-reference + forgejo-repository-reference? + json->forgejo-repository-reference + (label forgejo-repository-reference-label "label") + (ref forgejo-repository-reference-ref "ref") + (sha forgejo-repository-reference-sha "sha") + (repository forgejo-repository-reference-repository "repo" + json->forgejo-repository)) + +(define* (forgejo-pull-request->specification pull-request #:optional (cuirass-options #f)) + "Returns a SPECIFICATION built out of a FORGEJO-PULL-REQUEST." + (let* ((source-repo-reference (forgejo-pull-request-head pull-request)) + (project-name (forgejo-repository-name + (forgejo-repository-reference-repository + (forgejo-pull-request-base pull-request)))) + (source-branch (forgejo-repository-reference-ref source-repo-reference)) + (source-url (forgejo-repository-url + (forgejo-repository-reference-repository source-repo-reference))) + (id (forgejo-pull-request-number pull-request)) + (name-prefix (if (and cuirass-options + (jobset-options-name-prefix cuirass-options)) + (jobset-options-name-prefix cuirass-options) + 'forgejo-pull-requests)) + (spec-name (string->symbol + (format #f "~a-~a-~a-~a" name-prefix + project-name + source-branch + id))) + (build (if (and cuirass-options + (jobset-options-build cuirass-options)) + (jobset-options-build cuirass-options) + `(channels ,project-name))) + (period (if (and cuirass-options + (jobset-options-period cuirass-options)) + (jobset-options-period cuirass-options) + %default-jobset-options-period)) + (priority (if (and cuirass-options + (jobset-options-priority cuirass-options)) + (jobset-options-priority cuirass-options) + %default-jobset-options-priority)) + (systems (if (and cuirass-options + (jobset-options-systems cuirass-options)) + (jobset-options-systems cuirass-options) + %default-jobset-options-systems))) + (specification + (name spec-name) + (build build) + (channels + (cons* (channel + (name project-name) + (url source-url) + (branch source-branch)) + %default-channels)) + (priority priority) + (period period) + (systems systems)))) diff --git a/tests/forgejo.scm b/tests/forgejo.scm new file mode 100644 index 0000000..fb3e99f --- /dev/null +++ b/tests/forgejo.scm @@ -0,0 +1,80 @@ +;;; forgejo.scm -- tests for (cuirass forgejo) module +;;; Copyright © 2024 Romain GARBAGE +;;; +;;; This file is part of Cuirass. +;;; +;;; Cuirass is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; Cuirass is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with Cuirass. If not, see . + +(use-modules (cuirass forges) + (cuirass forges forgejo) + (cuirass specification) + (cuirass utils) + (tests common) + (guix channels) + (json) + (fibers) + (squee) + (web uri) + (web client) + (web response) + (rnrs bytevectors) + (srfi srfi-1) + (srfi srfi-64) + (ice-9 threads) + (ice-9 match)) + +(define default-pull-request-json + "{ + \"action\": \"opened\", + \"pull_request\": { + \"number\": 1, + \"state\": \"open\", + \"base\": { + \"label\": \"base-label\", + \"ref\": \"base-branch\", + \"sha\": \"666af40e8a059fa05c7048a7ac4f2eccbbd0183b\", + \"repo\": { + \"name\": \"project-name\", + \"clone_url\": \"https://forgejo.instance.test/base-repo/project-name.git\" + } + }, + \"head\": { + \"label\": \"test-label\", + \"ref\": \"test-branch\", + \"sha\": \"582af40e8a059fa05c7048a7ac4f2eccbbd0183b\", + \"repo\": { + \"name\": \"fork-name\", + \"clone_url\": \"https://forgejo.instance.test/source-repo/fork-name.git\" + } + } + } + }") + +(test-assert "default-json" + (specifications=? + (let ((event (json->forgejo-pull-request-event default-pull-request-json))) + (forgejo-pull-request->specification + (forgejo-pull-request-event-pull-request event))) + (specification + (name 'forgejo-pull-requests-project-name-test-branch-1) + (build '(channels . (project-name))) + (channels + (cons* (channel + (name 'project-name) + (url "https://forgejo.instance.test/source-repo/fork-name.git") + (branch "test-branch")) + %default-channels)) + (priority %default-jobset-options-priority) + (period %default-jobset-options-period) + (systems %default-jobset-options-systems)))) -- 2.46.0 From unknown Sun Jun 22 04:04:30 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#74769] [PATCH Cuirass v2 6/7] tests: Explicit Gitlab endpoint related variables. Resent-From: Romain GARBAGE Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 12 Dec 2024 16:00:12 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74769 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74769@debbugs.gnu.org Cc: ludovic.courtes@inria.fr, Romain GARBAGE Received: via spool by 74769-submit@debbugs.gnu.org id=B74769.17340191643613 (code B ref 74769); Thu, 12 Dec 2024 16:00:12 +0000 Received: (at 74769) by debbugs.gnu.org; 12 Dec 2024 15:59:24 +0000 Received: from localhost ([127.0.0.1]:39990 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLlb1-0000wA-Ij for submit@debbugs.gnu.org; Thu, 12 Dec 2024 10:59:23 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:36991) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLlat-0000uw-WB for 74769@debbugs.gnu.org; Thu, 12 Dec 2024 10:59:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0NRF0wq1TUSJTCaXcadUmInUaUDl9Db5F1Yau5qrAPc=; b=gbYAOy7ltiUixgGaanKrvLTOpumoWUir4g7PXXOfTIUJ6mNwEZP++0gj cq887sxu+R+N8OxmgtS9C/IzOJQlY6XGazP2/pIozKyLHLWut8MGIpBPF i3e497BHwIVY9K3h0BFJadZWnbbBWj4AIEX/edQHVVVZd5zoEu2XAI29q o=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=romain.garbage@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.12,229,1728943200"; d="scan'208";a="104178648" Received: from unknown (HELO guix-A102.bordeaux.inria.fr) ([193.50.110.191]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2024 16:58:59 +0100 From: Romain GARBAGE Date: Thu, 12 Dec 2024 16:57:54 +0100 Message-ID: <20241212155845.27344-6-romain.garbage@inria.fr> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241212155845.27344-1-romain.garbage@inria.fr> References: <20241212155845.27344-1-romain.garbage@inria.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * tests/http.scm: Rename mr-* variables to gitlab-merge-request-*. --- tests/http.scm | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/http.scm b/tests/http.scm index 541f30d..aa58e78 100644 --- a/tests/http.scm +++ b/tests/http.scm @@ -90,7 +90,7 @@ (channel . "packages") (directory . "dir2"))))))) -(define mr-json-open +(define gitlab-merge-request-json-open "{ \"event_type\": \"merge_request\", \"project\": { @@ -108,7 +108,7 @@ } }") -(define mr-json-close +(define gitlab-merge-request-json-close "{ \"event_type\": \"merge_request\", \"project\": { @@ -126,8 +126,8 @@ } }") -(define mr-spec - (let ((event (json->gitlab-event mr-json-open))) +(define gitlab-merge-request-spec + (let ((event (json->gitlab-event gitlab-merge-request-json-open))) (gitlab-merge-request->specification (gitlab-event-value event) (gitlab-event-project event)))) @@ -438,24 +438,24 @@ (specification-channels spec))))))) (test-equal "/admin/gitlab/event creates a spec from a new merge request" - (specification-name mr-spec) + (specification-name gitlab-merge-request-spec) (begin - (http-post-json (test-cuirass-uri "/admin/gitlab/event") mr-json-open) - (specification-name (db-get-specification (specification-name mr-spec))))) + (http-post-json (test-cuirass-uri "/admin/gitlab/event") gitlab-merge-request-json-open) + (specification-name (db-get-specification (specification-name gitlab-merge-request-spec))))) (test-equal "/admin/gitlab/event error when a merge request has already been created" 400 - (response-code (http-post-json (test-cuirass-uri "/admin/gitlab/event") mr-json-open))) + (response-code (http-post-json (test-cuirass-uri "/admin/gitlab/event") gitlab-merge-request-json-open))) (test-assert "/admin/gitlab/event removes a spec from a closed merge request" (begin - (http-post-json (test-cuirass-uri "/admin/gitlab/event") mr-json-close) - (not (db-get-specification (specification-name mr-spec))))) + (http-post-json (test-cuirass-uri "/admin/gitlab/event") gitlab-merge-request-json-close) + (not (db-get-specification (specification-name gitlab-merge-request-spec))))) (test-equal "/admin/gitlab/event error when a merge request has already been closed" 404 (response-code (http-post-json (test-cuirass-uri "/admin/gitlab/event") - mr-json-close))) + gitlab-merge-request-json-close))) (test-assert "db-close" (begin -- 2.46.0 From unknown Sun Jun 22 04:04:30 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#74769] [PATCH Cuirass v2 7/7] http: Add admin/forgejo/event. Resent-From: Romain GARBAGE Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 12 Dec 2024 16:00:13 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74769 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74769@debbugs.gnu.org Cc: ludovic.courtes@inria.fr, Romain GARBAGE Received: via spool by 74769-submit@debbugs.gnu.org id=B74769.17340191713631 (code B ref 74769); Thu, 12 Dec 2024 16:00:13 +0000 Received: (at 74769) by debbugs.gnu.org; 12 Dec 2024 15:59:31 +0000 Received: from localhost ([127.0.0.1]:39992 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLlb2-0000wE-2l for submit@debbugs.gnu.org; Thu, 12 Dec 2024 10:59:31 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:36970) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLlau-0000u3-Tc for 74769@debbugs.gnu.org; Thu, 12 Dec 2024 10:59:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MrIju8T3bCfkPTbYpJZFcb+Z9f0Qmy1WGoaBPwjI/0M=; b=cADQ0rw0jAkJTV03YTP0/ZbkLI+v5XHDMOXRXCOQ0T5VbiwhSzYGagrq xFhm3Hu8pHeO9pZDfbqAP8XkdwIq5lYeCpfITARy9wYEvdA4nK2H+IIBF NiPSIKVQxO5NLhYtZpDbaMrOoY+6yrBh4WakI+m1J0Ntfvx1b8iretmKq U=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=romain.garbage@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.12,229,1728943200"; d="scan'208";a="104178650" Received: from unknown (HELO guix-A102.bordeaux.inria.fr) ([193.50.110.191]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2024 16:58:59 +0100 From: Romain GARBAGE Date: Thu, 12 Dec 2024 16:57:55 +0100 Message-ID: <20241212155845.27344-7-romain.garbage@inria.fr> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241212155845.27344-1-romain.garbage@inria.fr> References: <20241212155845.27344-1-romain.garbage@inria.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * src/cuirass/http.scm (url-handler): Add "/admin/forgejo/event". * tests/http.scm: Add tests for the "/admin/forgejo/event" endpoint. * doc/cuirass.texi: Reorganize "Interfacing Cuirass..." section. Add documentation for the "/admin/forgejo/event" endpoint. --- doc/cuirass.texi | 38 ++++++++++++++++-- src/cuirass/http.scm | 64 +++++++++++++++++++++++++++++- tests/http.scm | 93 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 188 insertions(+), 7 deletions(-) diff --git a/doc/cuirass.texi b/doc/cuirass.texi index 13739c9..895d91f 100644 --- a/doc/cuirass.texi +++ b/doc/cuirass.texi @@ -1284,11 +1284,14 @@ This request accepts a mandatory parameter. Limit query result to nr elements. This parameter is @emph{mandatory}. @end table -@section Interfacing Cuirass with a GitLab Server +@section Interfacing Cuirass with a Git forge -Cuirass supports integration with GitLab through the @dfn{webhook} mechanism: -a POST request is sent by a GitLab instance whenever a specific event is -triggered. So far, Cuirass only support merge-request events. +Cuirass supports integration with various forges through the +@dfn{webhook} mechanism: a POST request is sent by the forge instance +whenever a specific event is triggered. So far, Cuirass only support +merge-request/pull-request events. + +@subsection Interfacing with a GitLab Server Sending a merge request event on the @code{/admin/gitlab/event} endpoint allows controlling a specific jobset related to the merge request @@ -1330,6 +1333,33 @@ A JSON list of strings. Each string must be a supported system, i.e. @code{"systems": [ "x86_64-linux", "aarch64-linux" ]} @end table +@subsection Interfacing with a Forgejo Server + +Sending a merge request event on the @code{/admin/forgejo/event} +endpoint allows controlling a specific jobset related to the merge +request content. This interface expect the JSON data to contain the +following keys: +@table @code +@item "action" +@item "pull_request.number" +@item "pull_request.state" +@item "pull_request.base.label" +@item "pull_request.base.ref" +@item "pull_request.base.sha" +@item "pull_request.base.repo.name" +@item "pull_request.base.repo.clone_url" +@item "pull_request.head.label" +@item "pull_request.head.ref" +@item "pull_request.head.sha" +@item "pull_request.head.repo.name" +@item "pull_request.head.repo.clone_url" +@end table + +The resulting jobset, named as +@code{forgejo-pull-requests-@var{pull_request}.@var{base}.@var{pull_request}.@var{name}-@var{pull_request}.@var{head}.@var{ref}-@var{pull_request}.@var{number}}, +is set to build the channel corresponding to the source branch in the +merge request data with a priority of 1. + @c ********************************************************************* @node Database @chapter Database schema diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm index 8ea929f..0a6bfae 100644 --- a/src/cuirass/http.scm +++ b/src/cuirass/http.scm @@ -5,7 +5,7 @@ ;;; Copyright © 2018 Clément Lassieur ;;; Copyright © 2018 Tatiana Sholokhova ;;; Copyright © 2019, 2020 Ricardo Wurmus -;;; Copyright © 2024 Romain Garbage +;;; Copyright © 2024 Romain Garbage ;;; ;;; This file is part of Cuirass. ;;; @@ -28,6 +28,7 @@ #:use-module (cuirass database) #:use-module ((cuirass base) #:select (evaluation-log-file)) #:use-module (cuirass forges gitlab) + #:use-module (cuirass forges forgejo) #:use-module (cuirass metrics) #:use-module (cuirass utils) #:use-module (cuirass logging) @@ -779,6 +780,67 @@ return DEFAULT." (event-type (respond-json-with-error 400 (format #f "Event type \"~a\" not supported." event-type)))) (respond-json-with-error 400 "This API only supports JSON.")))) + ;; Define an API for Forgejo events + (('POST "admin" "forgejo" "event") + (let* ((params (utf8->string body)) + (event-type (assoc-ref (request-headers request) 'x-forgejo-event)) + (content-type (assoc-ref (request-headers request) 'content-type)) + (json? (equal? (car content-type) + 'application/json))) + (if json? + (match event-type + ("pull_request" + (let* ((event (json->forgejo-pull-request-event params)) + (pull-request (forgejo-pull-request-event-pull-request event)) + (spec (forgejo-pull-request->specification pull-request)) + (spec-name (specification-name spec))) + (match (forgejo-pull-request-event-action event) + ;; New pull request. + ((or 'opened 'reopened) + (if (not (db-get-specification spec-name)) + (begin + (db-add-or-update-specification spec) + + (unless (call-bridge `(register-jobset ,spec-name) + bridge) + (log-warning + "cannot notify bridge of the addition of jobset '~a'" + spec-name)) + (respond + (build-response #:code 200 + #:headers + `((location . ,(string->uri-reference "/")))) + #:body "")) + (begin + (log-warning "jobset '~a' already exists" spec-name) + (respond-json-with-error 400 "Jobset already exists.")))) + ;; Closed or merged pull request. + ('closed + (if (db-get-specification spec-name) + (begin + (call-bridge `(remove-jobset ,spec-name) bridge) + (log-info "Removed jobset '~a'" spec-name) + (respond + (build-response #:code 200 + #:headers + `((location . ,(string->uri-reference "/")))) + #:body "")) + (begin + (log-warning "cannot find jobset '~a'" spec-name) + (respond-json-with-error 404 "Jobset not found.")))) + ;; 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."))) + (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.")))) + (('POST "admin" "specification" "add") (let* ((spec (body->specification body)) (name (specification-name spec))) diff --git a/tests/http.scm b/tests/http.scm index aa58e78..862e06b 100644 --- a/tests/http.scm +++ b/tests/http.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2017-2020, 2023-2024 Ludovic Courtès ;;; Copyright © 2017, 2020, 2021 Mathieu Othacehe ;;; Copyright © 2018 Clément Lassieur +;;; Copyright © 2024 Romain Garbage ;;; ;;; This file is part of Cuirass. ;;; @@ -22,6 +23,7 @@ (use-modules ((cuirass base) #:select (%bridge-socket-file-name)) (cuirass http) (cuirass database) + (cuirass forges forgejo) (cuirass forges gitlab) (cuirass specification) (cuirass utils) @@ -43,8 +45,9 @@ (call-with-values (lambda () (http-get uri)) (lambda (response body) body))) -(define (http-post-json uri body) - (http-post uri #:body body #:headers '((content-type application/json)))) +(define* (http-post-json uri body #:optional (extra-headers '())) + (http-post uri #:body body #:headers (append '((content-type application/json)) + extra-headers))) (define (wait-until-ready port) ;; Wait until the server is accepting connections. @@ -132,6 +135,65 @@ (gitlab-event-value event) (gitlab-event-project event)))) +(define forgejo-pull-request-json-open + "{ + \"action\": \"opened\", + \"pull_request\": { + \"number\": 1, + \"state\": \"open\", + \"base\": { + \"label\": \"base-label\", + \"ref\": \"base-branch\", + \"sha\": \"666af40e8a059fa05c7048a7ac4f2eccbbd0183b\", + \"repo\": { + \"name\": \"project-name\", + \"clone_url\": \"https://forgejo.instance.test/base-repo/project-name.git\" + } + }, + \"head\": { + \"label\": \"test-label\", + \"ref\": \"test-branch\", + \"sha\": \"582af40e8a059fa05c7048a7ac4f2eccbbd0183b\", + \"repo\": { + \"name\": \"fork-name\", + \"clone_url\": \"https://forgejo.instance.test/source-repo/fork-name.git\" + } + } + } + }") + +(define forgejo-pull-request-json-close + "{ + \"action\": \"closed\", + \"pull_request\": { + \"number\": 1, + \"state\": \"closed\", + \"base\": { + \"label\": \"base-label\", + \"ref\": \"base-branch\", + \"sha\": \"666af40e8a059fa05c7048a7ac4f2eccbbd0183b\", + \"repo\": { + \"name\": \"project-name\", + \"clone_url\": \"https://forgejo.instance.test/base-repo/project-name.git\" + } + }, + \"head\": { + \"label\": \"test-label\", + \"ref\": \"test-branch\", + \"sha\": \"582af40e8a059fa05c7048a7ac4f2eccbbd0183b\", + \"repo\": { + \"name\": \"fork-name\", + \"clone_url\": \"https://forgejo.instance.test/source-repo/fork-name.git\" + } + } + } + }") + +(define forgejo-pull-request-specification + (forgejo-pull-request->specification + (forgejo-pull-request-event-pull-request + (json->forgejo-pull-request-event forgejo-pull-request-json-open)))) + (define-syntax-rule (with-cuirass-register exp ...) (with-guix-daemon (let ((pid #f)) @@ -457,6 +519,33 @@ (response-code (http-post-json (test-cuirass-uri "/admin/gitlab/event") gitlab-merge-request-json-close))) + (test-equal "/admin/forgejo/event creates a spec from a new pull request" + (specification-name forgejo-pull-request-specification) + (begin + (http-post-json (test-cuirass-uri "/admin/forgejo/event") + forgejo-pull-request-json-open + '((x-forgejo-event . "pull_request"))) + (specification-name (db-get-specification (specification-name forgejo-pull-request-specification))))) + + (test-equal "/admin/forgejo/event error when a pull request has already been created" + 400 + (response-code (http-post-json (test-cuirass-uri "/admin/forgejo/event") + forgejo-pull-request-json-open + '((x-forgejo-event . "pull_request"))))) + + (test-assert "/admin/forgejo/event removes a spec from a closed pull request" + (begin + (http-post-json (test-cuirass-uri "/admin/forgejo/event") + forgejo-pull-request-json-close + '((x-forgejo-event . "pull_request"))) + (not (db-get-specification (specification-name forgejo-pull-request-specification))))) + + (test-equal "/admin/forgejo/event error when a pull request has already been closed" + 404 + (response-code (http-post-json (test-cuirass-uri "/admin/forgejo/event") + forgejo-pull-request-json-close + '((x-forgejo-event . "pull_request"))))) + (test-assert "db-close" (begin (db-close (%db)) -- 2.46.0 From unknown Sun Jun 22 04:04:30 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Romain GARBAGE Subject: bug#74769: closed (Re: [PATCH Cuirass v2 1/7] tests: Move procedure definition.) Message-ID: References: <87ed2b3n0v.fsf@inria.fr> <20241210160824.31748-1-romain.garbage@inria.fr> X-Gnu-PR-Message: they-closed 74769 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 74769@debbugs.gnu.org Date: Fri, 13 Dec 2024 10:18:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1734085082-21572-1" This is a multi-part message in MIME format... ------------=_1734085082-21572-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #74769: [PATCH Cuirass 0/4] Forgejo event support which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 74769@debbugs.gnu.org. --=20 74769: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D74769 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1734085082-21572-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 74769-done) by debbugs.gnu.org; 13 Dec 2024 10:17:53 +0000 Received: from localhost ([127.0.0.1]:41641 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tM2k1-0005bR-1v for submit@debbugs.gnu.org; Fri, 13 Dec 2024 05:17:53 -0500 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:15137) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tM2jt-0005as-8c for 74769-done@debbugs.gnu.org; Fri, 13 Dec 2024 05:17:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version:content-transfer-encoding; bh=yQgG+HDBlElhRH2gaVkx/7AoYaTqaovF0yUhDLAMzRw=; b=AIfX90rMNWuKiGOUBlwW4HGlcIe62vlLcpx0dLL6cQw75F7upZUKOD/7 EJY8jVmSH8Qrwc5VnQHwDK13nauqGkv6XLQXQ3k6Mko3U/SoA3tfeka4T VN9vWDF/emvF+c/4bG4JZJnV5g9LuGLNjIcqGt1pPHPXQXyej6vAqJT3a Y=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=ludovic.courtes@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.12,230,1728943200"; d="scan'208";a="199012362" Received: from unknown (HELO ribbon) ([193.50.110.52]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2024 11:17:21 +0100 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Romain GARBAGE Subject: Re: [PATCH Cuirass v2 1/7] tests: Move procedure definition. In-Reply-To: <20241212155845.27344-1-romain.garbage@inria.fr> (Romain GARBAGE's message of "Thu, 12 Dec 2024 16:57:49 +0100") References: <20241212155845.27344-1-romain.garbage@inria.fr> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Tridi 23 Frimaire an 233 de la =?utf-8?Q?R=C3=A9volu?= =?utf-8?Q?tion=2C?= jour du Roseau X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Fri, 13 Dec 2024 11:17:20 +0100 Message-ID: <87ed2b3n0v.fsf@inria.fr> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 74769-done Cc: 74769-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hello Romain, Applied and pushed v2, thank you! Looking forward to deploying it. :-) Ludo=E2=80=99. ------------=_1734085082-21572-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 10 Dec 2024 16:08:49 +0000 Received: from localhost ([127.0.0.1]:59200 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL2n2-0001MR-NG for submit@debbugs.gnu.org; Tue, 10 Dec 2024 11:08:49 -0500 Received: from lists.gnu.org ([209.51.188.17]:52872) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL2mz-0001M1-TG for submit@debbugs.gnu.org; Tue, 10 Dec 2024 11:08:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tL2my-0000E2-N3 for guix-patches@gnu.org; Tue, 10 Dec 2024 11:08:44 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tL2mv-0005CS-JI for guix-patches@gnu.org; Tue, 10 Dec 2024 11:08:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Rc/OOSTpAXdVlddawgIIuo5s+DSnF2BzM5Dy/lqV0Bw=; b=PITMtTTwB2ppEVw9R+EsVnugPSIWFvQJOj4pzNKMHYISRy90Wp25mKQy Ke9v7SaQEy53a6LnRhSIstjML+/SnzS5zCykrSylsGEkQyOc6wFsLeGby syASaj5g2DHu7z9DuJDQ89JFarl5IY+R21kiuWj4UH3WqWCkqNwg3d3Ih A=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=romain.garbage@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.12,222,1728943200"; d="scan'208";a="103964414" Received: from unknown (HELO guix-A102.bordeaux.inria.fr) ([193.50.110.191]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2024 17:08:37 +0100 From: Romain GARBAGE To: guix-patches@gnu.org Subject: [PATCH Cuirass 0/4] Forgejo event support Date: Tue, 10 Dec 2024 17:01:04 +0100 Message-ID: <20241210160824.31748-1-romain.garbage@inria.fr> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=192.134.164.104; envelope-from=romain.garbage@inria.fr; helo=mail3-relais-sop.national.inria.fr X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: ludovic.courtes@inria.fr, Romain GARBAGE X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This patch series adds support for Forgejo pull request events in Cuirass, as generated using the webhooks mechanism. The first patch refactors code to make it accessible from different test modules. The second patch adds the necessary record type definitions to parse the JSON data sent by Forgejo. The third patch improves Gitlab integration related http tests readability. The fourth patch adds Forgejo integration to Cuirass' web service. Romain GARBAGE (4): tests: Move procedure definition. forgejo: Add module for Forgejo JSON objects definition. tests: Explicit Gitlab endpoint related variables. http: Add admin/forgejo/event. Makefile.am | 2 + doc/cuirass.texi | 38 ++++++++++-- src/cuirass/forgejo.scm | 133 ++++++++++++++++++++++++++++++++++++++++ src/cuirass/http.scm | 62 +++++++++++++++++++ tests/common.scm | 30 ++++++++- tests/forgejo.scm | 79 ++++++++++++++++++++++++ tests/gitlab.scm | 24 -------- tests/http.scm | 114 ++++++++++++++++++++++++++++++---- 8 files changed, 440 insertions(+), 42 deletions(-) create mode 100644 src/cuirass/forgejo.scm create mode 100644 tests/forgejo.scm base-commit: e96f0887923d4d1cd4e35073fcffdb978d7e1e10 -- 2.46.0 ------------=_1734085082-21572-1--