diff options
| author | Frederick Muriuki Muriithi | 2026-06-08 11:06:27 -0500 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2026-06-15 09:48:42 -0500 |
| commit | 1f0b324f81c899f11d963e566913b39a8d783399 (patch) | |
| tree | f9677ba9b998c0dabb10fd71ac84904ad8dea242 | |
| parent | cf97a3e293f7e3b3f10d54b6928d70fa981879b7 (diff) | |
| download | gn-machines-1f0b324f81c899f11d963e566913b39a8d783399.tar.gz | |
Add gexp for running various smoke/integration tests.
Add a "generic" gexp that will run the smoke and/or integration tests in a mostly standard way.
| -rw-r--r-- | genenetwork-development.scm | 92 |
1 files changed, 88 insertions, 4 deletions
diff --git a/genenetwork-development.scm b/genenetwork-development.scm index 966b0fa..bceddeb 100644 --- a/genenetwork-development.scm +++ b/genenetwork-development.scm @@ -22,14 +22,15 @@ (use-modules (gnu) (gn-machines services monitoring) - ((gn-machines genenetwork) #:select (genenetwork2 genenetwork3 gn-auth gn-guile)) + ((gn-machines genenetwork) #:select (genenetwork2 genenetwork3 gn-auth gn-guile gn-integration-tests)) (gn services databases) (gnu build linux-container) ((gnu packages admin) #:select (shepherd shadow)) ((gnu packages base) #:select (gnu-make tar coreutils-minimal)) ((gnu packages bash) #:select (bash)) ((gnu packages nss) #:select (nss-certs)) - ((gnu packages check) #:select (python-pylint)) + ((gnu packages python) #:select (python)) + ((gnu packages check) #:select (python-pylint python-pytest)) ((gnu packages curl) #:select (curl)) ((gnu packages ci) #:select (laminar)) ((gnu packages compression) #:select (gzip)) @@ -43,7 +44,7 @@ ((gnu packages guile-xyz) #:select (guile-sparql) #:prefix guix:) ((gnu packages haskell-apps) #:select (shellcheck)) ((gnu packages python-check) #:select (python-mypy)) - ((gnu packages python-web) #:select (gunicorn)) + ((gnu packages python-web) #:select (gunicorn python-requests)) ((gnu packages rdf) #:select (raptor2)) ((gnu packages tls) #:select (openssl)) ((gnu packages version-control) #:select (git-minimal)) @@ -157,7 +158,9 @@ be imported into G-expressions." (repositories genenetwork-configuration-repositories (default "/export/data/repositories")) (gn-doc-git-checkout genenetwork-configuration-gn-doc-git-checkout - (default "/export/data/gn-docs"))) + (default "/export/data/gn-docs")) + (gn-integration-tests-repository genenetwork-gn-integration-tests-repository + (default "https://git.genenetwork.org/gn-integration-tests"))) ;;; @@ -1527,6 +1530,11 @@ gn-guile to display RDF pages." (xapian-db-path %xapian-directory))) + + +;; +;; gn-integration-tests +;; (define (gn-auth-test-flask config) "Return a program-file that wraps flask with the gn-auth environment derived from CONFIG. All arguments are forwarded to flask, allowing @@ -1590,6 +1598,82 @@ delete-test-users, etc.) as the genenetwork user via sudo." (define %gn-auth-test-flask (gn-auth-test-flask %genenetwork-configuration)) + +(define* (gn-integration-tests-gexp config test-command + #:key + (setup '()) + (teardown '())) + (match-record config <genenetwork-configuration> + (gn-integration-tests-repository repositories-checkout-directory) + (let ((gn-libs-checkout (string-append repositories-checkout-directory "/gn-libs")) + (gn-auth-checkout (string-append repositories-checkout-directory "/gn-auth")) + (gn3-checkout (string-append repositories-checkout-directory "/genenetwork3")) + (gn2-checkout (string-append repositories-checkout-directory "/genenetwork2")) + (gn-guile-checkout (string-append repositories-checkout-directory "/gn-guile"))) + (with-imported-modules '((guix build utils)) + (with-packages (list nss-certs git-minimal) + #~(begin + (use-modules (guix build utils)) + + (define (hline) + "Print a horizontal line 50 '=' characters long." + (display (make-string 50 #\=)) + (newline) + (force-output)) + + (define (show-head-commit) + (hline) + (invoke #$(file-append git-minimal "/bin/git") + "--no-pager" "log" "--max-count" "1") + (hline)) + + + ;; laminar user cannot `cd' into some (or all) of these directories + ;; (with-directory-excursion #$gn-libs-checkout (show-head-commit)) + ;; (with-directory-excursion #$gn-auth-checkout (show-head-commit)) + ;; (with-directory-excursion #$gn-guile-checkout (show-head-commit)) + ;; (with-directory-excursion #$gn3-checkout (show-head-commit)) + ;; (with-directory-excursion #$gn2-checkout (show-head-commit)) + + (let* ((orig-dir (getcwd)) + (tmp-dir (mkdtemp "/tmp/gn-integration-tests.XXXXXX")) + (tests-profile #$(profile + (content (package->development-manifest gn-integration-tests)) + (allow-collisions? #t))) + (py-version + #$(version-major+minor (package-version python))) + (site-packages + (string-append tests-profile "/lib/python" + py-version "/site-packages"))) + (chdir tmp-dir) + (invoke #$(file-append git-minimal "/bin/git") + "clone" "--depth" "1" #$gn-integration-tests-repository) + (with-directory-excursion "gn-integration-tests" + (show-head-commit)) + (chdir "gn-integration-tests") + + (setenv "GN_INTEGRATION_TESTS_PROFILE" tests-profile) + (setenv "PATH" (string-append tests-profile "/bin:" + (getenv "PATH"))) + (if (getenv "PYTHONPATH") + (setenv + "PYTHONPATH" + (string-append site-packages ":" (getenv "PYTHONPATH"))) + (setenv "PYTHONPATH" site-packages)) + (dynamic-wind + (lambda () ;; Run setup if provided + (for-each + (lambda (setup-cmd) (apply invoke setup-cmd)) + '#$setup)) + (lambda () (apply invoke '#$test-command)) ;; Run actual tests + (lambda () ;; Always run teardowns to clean up. + (for-each + (lambda (teardown-cmd) (apply invoke teardown-cmd)) + '#$teardown) + (chdir orig-dir) + (delete-file-recursively tmp-dir)))))))))) + + (operating-system (host-name "genenetwork-development") (timezone "UTC") |
