summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2025-11-10 10:19:48 +0000
committerChristopher Baines <mail@cbaines.net>2025-11-10 10:27:36 +0000
commitf7125fb55d06cc2ad6bcd86b8071ea079a9ca179 (patch)
tree2478c50d3eb1c81cca5af3e1f4bf326d01b8b2ad
parent9bf06d93a47db1200eabc055e64e832d6a5fd603 (diff)
gnu: Fix patchwork service test.
* gnu/packages/patchutils.scm (patchwork):[arguments]: Write version.txt, tweak some indentation, patch the STATICFILES_DIRS entry. [propagated-inputs]: Add python-tzdata. * gnu/services/web.scm (patchwork-settings-module-compiler): Don't set STATIC_ROOT on debug, as this clashes with STATICFILES_DIRS. (patchwork-django-admin-gexp): Fix. (patchwork-shepherd-services): Workaround issue referencing random-token. * gnu/tests/web.scm (patchwork-initial-database-setup-service): Don't use primitive-fork, as this doesn't work with newer shepherds. (run-patchwork-test): Check the setup runs. Change-Id: I7dfeb816b4f6c9070358d433fb7ca8faa1fbfd2a
-rw-r--r--gnu/packages/patchutils.scm32
-rw-r--r--gnu/services/web.scm17
-rw-r--r--gnu/tests/web.scm62
3 files changed, 64 insertions, 47 deletions
diff --git a/gnu/packages/patchutils.scm b/gnu/packages/patchutils.scm
index 540b85b41aa..2d17d9d57be 100644
--- a/gnu/packages/patchutils.scm
+++ b/gnu/packages/patchutils.scm
@@ -55,6 +55,7 @@
55 #:use-module (gnu packages less) 55 #:use-module (gnu packages less)
56 #:use-module (gnu packages mail) 56 #:use-module (gnu packages mail)
57 #:use-module (gnu packages text-editors) 57 #:use-module (gnu packages text-editors)
58 #:use-module (gnu packages time)
58 #:use-module (gnu packages ncurses) 59 #:use-module (gnu packages ncurses)
59 #:use-module (gnu packages ocaml) 60 #:use-module (gnu packages ocaml)
60 #:use-module (gnu packages package-management) 61 #:use-module (gnu packages package-management)
@@ -432,13 +433,20 @@ application = get_wsgi_application()\n") port)))))
432 (delete-file-recursively (string-append out-site-packages 433 (delete-file-recursively (string-append out-site-packages
433 "/patchwork/tests")) 434 "/patchwork/tests"))
434 435
436 (call-with-output-file
437 (string-append out-site-packages "/version.txt")
438 (lambda (port)
439 (display #$version port)
440 (newline port)))
441
435 ;; Install patchwork related tools 442 ;; Install patchwork related tools
436 (for-each (lambda (file) 443 (for-each
437 (install-file file 444 (lambda (file)
438 (string-append out "/bin"))) 445 (install-file file (string-append out "/bin")))
439 (list (string-append out-site-packages 446 (list
440 "/patchwork/bin/parsemail.sh") 447 (string-append out-site-packages
441 (string-append out-site-packages 448 "/patchwork/bin/parsemail.sh")
449 (string-append out-site-packages
442 "/patchwork/bin/parsemail-batch.sh"))) 450 "/patchwork/bin/parsemail-batch.sh")))
443 451
444 ;; Collect the static assets, this includes JavaScript, CSS and 452 ;; Collect the static assets, this includes JavaScript, CSS and
@@ -449,8 +457,15 @@ application = get_wsgi_application()\n") port)))))
449 ;; The intent here is that you can serve files from this 457 ;; The intent here is that you can serve files from this
450 ;; directory through a webserver, which is recommended when 458 ;; directory through a webserver, which is recommended when
451 ;; running Django applications. 459 ;; running Django applications.
452 (let ((static-root (string-append out 460 (let ((static-root
453 "/share/patchwork/htdocs"))) 461 (string-append out "/share/patchwork/htdocs")))
462 ;; Patch the STATICFILES_DIRS entry
463 (substitute* (string-append
464 out-site-packages
465 "/patchwork/settings/base.py")
466 (("os\\.path\\.join\\(ROOT\\_DIR, 'htdocs'\\)")
467 (string-append "'" static-root "'")))
468
454 (mkdir-p static-root) 469 (mkdir-p static-root)
455 (copy-file "patchwork/settings/production.example.py" 470 (copy-file "patchwork/settings/production.example.py"
456 "patchwork/settings/assets.py") 471 "patchwork/settings/assets.py")
@@ -496,6 +511,7 @@ if __name__ == \"__main__\":
496 (inputs (list python-wrapper)) 511 (inputs (list python-wrapper))
497 (propagated-inputs 512 (propagated-inputs
498 (list python-django 513 (list python-django
514 python-tzdata
499 ;; TODO: Make this configurable 515 ;; TODO: Make this configurable
500 python-psycopg2 516 python-psycopg2
501 python-mysqlclient 517 python-mysqlclient
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index ae33a25394d..9d314368ff9 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -1771,11 +1771,9 @@ DATABASES = {
1771 }, 1771 },
1772} 1772}
1773 1773
1774" #$(if debug? 1774" #$(if static-url
1775 #~(string-append "STATIC_ROOT = '" 1775 #~(string-append "STATIC_URL = '" #$static-url "'")
1776 #$(file-append patchwork "/share/patchwork/htdocs") 1776 "") "
1777 "'")
1778 #~(string-append "STATIC_URL = '" #$static-url "'")) "
1779 1777
1780STATICFILES_STORAGE = ( 1778STATICFILES_STORAGE = (
1781 'django.contrib.staticfiles.storage.StaticFilesStorage' 1779 'django.contrib.staticfiles.storage.StaticFilesStorage'
@@ -1840,7 +1838,7 @@ WSGIPassAuthorization On
1840 #~(lambda command 1838 #~(lambda command
1841 (zero? (spawn-command 1839 (zero? (spawn-command
1842 `(#$(file-append patchwork "/bin/patchwork-admin") 1840 `(#$(file-append patchwork "/bin/patchwork-admin")
1843 ,command) 1841 ,@command)
1844 #:user "httpd" 1842 #:user "httpd"
1845 #:group "httpd" 1843 #:group "httpd"
1846 #:environment-variables 1844 #:environment-variables
@@ -1864,10 +1862,9 @@ WSGIPassAuthorization On
1864 (with-extensions (list guile-gcrypt) 1862 (with-extensions (list guile-gcrypt)
1865 #~(let ((secret-key-file 1863 #~(let ((secret-key-file
1866 #$(patchwork-settings-module-secret-key-file 1864 #$(patchwork-settings-module-secret-key-file
1867 settings-module))) 1865 settings-module))
1868 (use-modules (guix build utils) 1866 (random-token
1869 (gcrypt random)) 1867 (@ (gcrypt random) random-token)))
1870
1871 (unless (file-exists? secret-key-file) 1868 (unless (file-exists? secret-key-file)
1872 (mkdir-p (dirname secret-key-file)) 1869 (mkdir-p (dirname secret-key-file))
1873 (call-with-output-file secret-key-file 1870 (call-with-output-file secret-key-file
diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm
index 419b5f0b5bf..47879aa08f7 100644
--- a/gnu/tests/web.scm
+++ b/gnu/tests/web.scm
@@ -609,40 +609,32 @@ HTTP-PORT, along with php-fpm."
609 609
610(define (patchwork-initial-database-setup-service configuration) 610(define (patchwork-initial-database-setup-service configuration)
611 (define start-gexp 611 (define start-gexp
612 #~(lambda () 612 #~(primitive-exit
613 (let ((pid (primitive-fork)) 613 (if (and
614 (postgres (getpwnam "postgres"))) 614 (zero?
615 (if (eq? pid 0) 615 (system* #$(file-append postgresql "/bin/createuser")
616 (dynamic-wind 616 #$(patchwork-database-configuration-user
617 (const #t) 617 configuration)))
618 (lambda () 618 (zero?
619 (setgid (passwd:gid postgres)) 619 (system* #$(file-append postgresql "/bin/createdb")
620 (setuid (passwd:uid postgres)) 620 "-O"
621 (primitive-exit 621 #$(patchwork-database-configuration-user
622 (if (and 622 configuration)
623 (zero? 623 #$(patchwork-database-configuration-name
624 (system* #$(file-append postgresql "/bin/createuser") 624 configuration))))
625 #$(patchwork-database-configuration-user 625 0
626 configuration))) 626 1)))
627 (zero?
628 (system* #$(file-append postgresql "/bin/createdb")
629 "-O"
630 #$(patchwork-database-configuration-user
631 configuration)
632 #$(patchwork-database-configuration-name
633 configuration))))
634 0
635 1)))
636 (lambda ()
637 (primitive-exit 1)))
638 (zero? (cdr (waitpid pid)))))))
639 627
640 (shepherd-service 628 (shepherd-service
641 (requirement '(postgres)) 629 (requirement '(postgres))
642 (provision '(patchwork-postgresql-user-and-database)) 630 (provision '(patchwork-postgresql-user-and-database))
643 (start start-gexp) 631 (start #~(lambda _
632 (zero? (spawn-command
633 '(#$(program-file "patchwork-initial-database-setup"
634 start-gexp))
635 #:user "postgres"
636 #:group "postgres"))))
644 (stop #~(const #f)) 637 (stop #~(const #f))
645 (respawn? #f)
646 (documentation "Setup patchwork database."))) 638 (documentation "Setup patchwork database.")))
647 639
648(define (patchwork-os patchwork) 640(define (patchwork-os patchwork)
@@ -724,6 +716,18 @@ HTTP-PORT."
724 ((pid) pid))))) 716 ((pid) pid)))))
725 marionette)) 717 marionette))
726 718
719 (test-assert "patchwork-setup started"
720 (marionette-eval
721 '(begin
722 (use-modules (gnu services herd))
723 (match (start-service 'patchwork-setup)
724 (#f #f)
725 (('service response-parts ...)
726 (match (assq-ref response-parts 'running)
727 ((#t) #t)
728 ((pid) pid)))))
729 marionette))
730
727 (test-assert "httpd running" 731 (test-assert "httpd running"
728 (marionette-eval 732 (marionette-eval
729 '(begin 733 '(begin