about summary refs log tree commit diff
path: root/.guix
diff options
context:
space:
mode:
Diffstat (limited to '.guix')
-rw-r--r--.guix/cwl-conformance.scm114
-rw-r--r--.guix/cwltest-package.scm117
-rw-r--r--.guix/e2e-tests.scm78
-rw-r--r--.guix/ravanan-package.scm13
4 files changed, 320 insertions, 2 deletions
diff --git a/.guix/cwl-conformance.scm b/.guix/cwl-conformance.scm
new file mode 100644
index 0000000..3e25c71
--- /dev/null
+++ b/.guix/cwl-conformance.scm
@@ -0,0 +1,114 @@
+;;; ravanan --- High-reproducibility CWL runner powered by Guix
+;;; Copyright © 2025 Arun Isaac <arunisaac@systemreboot.net>
+;;;
+;;; This file is part of ravanan.
+;;;
+;;; ravanan 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.
+;;;
+;;; ravanan 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 ravanan.  If not, see <https://www.gnu.org/licenses/>.
+
+(define-module (cwl-conformance)
+  #:use-module ((cwltest-package) #:select (cwltest))
+  #:use-module ((ravanan-package) #:select (ravanan))
+  #:use-module ((gnu packages python) #:select (python))
+  #:use-module ((gnu packages python-web) #:select (python-pybadges))
+  #:use-module (guix gexp)
+  #:use-module (guix git-download)
+  #:use-module (guix packages)
+  #:use-module (guix profiles)
+  #:use-module (guix utils)
+  #:use-module (ice-9 match)
+  #:export (cwltest-suite-gexp))
+
+(define* (cwltest-suite-gexp cwltest-suite manifest-file #:key (skip-tests '()))
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils)
+                     (ice-9 match))
+
+        ;; Guix peeks into HOME.
+        (setenv "HOME" (getcwd))
+        ;; cwltest writes out output directories to TMPDIR, but does not clean
+        ;; up after. So, we set TMPDIR to our own temporary directory that we
+        ;; can manage easily. See pending issue on cleaning up temporary output
+        ;; directories:
+        ;; https://github.com/common-workflow-language/cwltest/issues/249
+        (mkdir "tmpdir")
+        (setenv "TMPDIR" "tmpdir")
+        (apply invoke
+               #$(file-append cwltest "/bin/cwltest")
+               "--test" #$cwltest-suite
+               "--tool" #$(file-append ravanan "/bin/ravanan")
+               "--badgedir" "badges"
+               (append '#$(match skip-tests
+                            (() '())
+                            (_ (list "-S" (string-join skip-tests ","))))
+                       (list "--"
+                             "--store=store"
+                             (string-append "--guix-manifest=" #$manifest-file)))))))
+
+(define cwl-v1.2-conformance-suite
+  (let ((version "1.2.1"))
+    (origin
+      (method git-fetch)
+      (uri (git-reference
+             (url "https://github.com/common-workflow-language/cwl-v1.2")
+             (commit (string-append "v" version))))
+      (file-name (git-file-name "cwl-v1.2" version))
+      (sha256
+       (base32
+        "03q8pd0niaaff52n6sn07l3rjnvwi4da649lnc8mn928sh0vywf3")))))
+
+(define-public cwl-v1.2-conformance
+  (program-file "cwl-v1.2-conformance"
+                (cwltest-suite-gexp
+                 (file-append cwl-v1.2-conformance-suite
+                              "/conformance_tests.yaml")
+                 (local-file "../cwl-conformance/manifest.scm")
+                 ;; With these tests, evil things happen and too much memory is
+                 ;; consumed. So, disable for now.
+                 #:skip-tests (list "env_home_tmpdir"
+                                    "env_home_tmpdir_docker"
+                                    "env_home_tmpdir_docker_no_return_code"))))
+
+(define generate-badges-gexp
+  (with-imported-modules '((guix build utils))
+    #~(begin
+        (use-modules (guix build utils)
+                     (ice-9 match))
+
+        (match (command-line)
+          ((_ cwltest-badgedir output-directory)
+           (set-path-environment-variable
+            "GUIX_PYTHONPATH"
+            '(#$(string-append "lib/python"
+                               (version-major+minor (package-version python))
+                               "/site-packages"))
+            (list #$(profile
+                      (content (packages->manifest
+                                (list python python-pybadges))))))
+           (invoke #$(file-append python "/bin/python3")
+                   #$(local-file "../cwl-conformance/badgegen.py")
+                   cwltest-badgedir
+                   #$(local-file "../cwl-conformance/commonwl.svg")
+                   output-directory))
+          ((program _ ...)
+           (format (current-error-port)
+                   "Usage: ~a CWLTEST_BADGEDIR OUTPUT-DIRECTORY~%"
+                   program)
+           (exit #f))))))
+
+(define-public generate-badges
+  (program-file "generate-badges"
+                generate-badges-gexp))
+
+cwl-v1.2-conformance
diff --git a/.guix/cwltest-package.scm b/.guix/cwltest-package.scm
new file mode 100644
index 0000000..f3eeb9d
--- /dev/null
+++ b/.guix/cwltest-package.scm
@@ -0,0 +1,117 @@
+;;; ravanan --- High-reproducibility CWL runner powered by Guix
+;;; Copyright © 2025 Arun Isaac <arunisaac@systemreboot.net>
+;;;
+;;; This file is part of ravanan.
+;;;
+;;; ravanan 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.
+;;;
+;;; ravanan 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 ravanan.  If not, see <https://www.gnu.org/licenses/>.
+
+(define-module (cwltest-package)
+  #:use-module ((gnu packages bioinformatics)
+                #:select (cwltool python-schema-salad))
+  #:use-module ((gnu packages check)
+                #:select (python-pytest python-pytest-xdist))
+  #:use-module ((gnu packages node) #:select (node))
+  #:use-module ((gnu packages python-build)
+                #:select (python-setuptools python-setuptools-scm python-wheel))
+  #:use-module ((gnu packages python-check) #:select (python-junit-xml))
+  #:use-module ((gnu packages xml) #:select (python-defusedxml))
+  #:use-module (guix build-system pyproject)
+  #:use-module (guix build-system python)
+  #:use-module (guix download)
+  #:use-module (guix gexp)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix packages))
+
+;; cwltest uses cwltool as a library. so, create a library version of cwltool
+;; where inputs become propagated inputs.
+(define python-cwltool
+  (package
+    (inherit cwltool)
+    (name "python-cwltool")
+    (inputs
+     (list node))
+    (propagated-inputs
+     (modify-inputs (package-inputs cwltool)
+       (delete "node")))))
+
+;; cwltest requires cwl-runner, the implementation-agnostic entry point to
+;; cwltool, for its tests.
+(define cwl-runner
+  (file-union "cwl-runner"
+              `(("bin/cwl-runner" ,(file-append cwltool "/bin/cwltool")))))
+
+(define-public cwltest
+  (package
+    (name "cwltest")
+    (version "2.6.20250314152537")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "cwltest" version))
+       (sha256
+        (base32 "0h2w9bllb6cz8d5pja5lbbd1kj08yga40jdi3300anwllczcnfq6"))))
+    (build-system pyproject-build-system)
+    (arguments
+     (list #:modules `((rnrs io ports)
+                       (srfi srfi-1)
+                       (srfi srfi-26)
+                       (srfi srfi-171)
+                       (guix build pyproject-build-system)
+                       (guix build utils))
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'disable-docker-in-tests
+                 (lambda _
+                   ;; Remove DockerRequirement (lines 7–10).
+                   (let* ((file "tests/test-data/v1.0/cat1-testcli.cwl")
+                          (lines (call-with-input-file file
+                                   (cut port-transduce
+                                        identity
+                                        rcons
+                                        get-line
+                                        <>))))
+                     (call-with-output-file file
+                       (lambda (port)
+                         (for-each (lambda (line)
+                                     (display line port)
+                                     (newline port))
+                                   (append (take lines 6)
+                                           (drop lines 10))))))))
+               (add-after 'install 'fix-permissions
+                 (lambda* (#:key inputs outputs #:allow-other-keys)
+                   ;; Make test scripts executable.
+                   (for-each (lambda (file)
+                               (chmod (string-append (site-packages inputs outputs)
+                                                     "/cwltest/tests/test-data/"
+                                                     file)
+                                      #o755))
+                             (list "dummy-executor.sh"
+                                   "mock_cwl_runner.py")))))))
+    (inputs (list python-defusedxml
+                  python-junit-xml
+                  python-pytest
+                  python-schema-salad))
+    (native-inputs (list cwl-runner
+                         python-cwltool
+                         python-pytest
+                         python-pytest-xdist
+                         python-setuptools
+                         python-setuptools-scm
+                         python-wheel))
+    (home-page "https://github.com/common-workflow-language/cwltest")
+    (synopsis "Common Workflow Language testing framework")
+    (description "Common Workflow Language testing framework.")
+    (license license:asl2.0)))
+
+cwltest
diff --git a/.guix/e2e-tests.scm b/.guix/e2e-tests.scm
new file mode 100644
index 0000000..58ba480
--- /dev/null
+++ b/.guix/e2e-tests.scm
@@ -0,0 +1,78 @@
+;;; ravanan --- High-reproducibility CWL runner powered by Guix
+;;; Copyright © 2025 Arun Isaac <arunisaac@systemreboot.net>
+;;;
+;;; This file is part of ravanan.
+;;;
+;;; ravanan 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.
+;;;
+;;; ravanan 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 ravanan.  If not, see <https://www.gnu.org/licenses/>.
+
+(define-module (e2e-tests)
+  #:use-module ((cwl-conformance) #:select (cwltest-suite-gexp))
+  #:use-module ((gnu packages bioinformatics) #:select (ccwl))
+  #:use-module (guix gexp)
+  #:use-module (ice-9 match))
+
+(define (ccwl-compile source-file)
+  #~(begin
+      (use-modules (rnrs io ports)
+                   (srfi srfi-26)
+                   (ice-9 match)
+                   (ice-9 popen))
+
+      (define (call-with-input-pipe command proc)
+        (match command
+          ((prog args ...)
+           (let ((port #f))
+             (dynamic-wind
+               (lambda ()
+                 (set! port (apply open-pipe* OPEN_READ prog args)))
+               (cut proc port)
+               (lambda ()
+                 (unless (zero? (close-pipe port))
+                   (error "Command invocation failed" command))))))))
+
+      (call-with-output-file #$output
+        (cut display
+             (call-with-input-pipe '(#$(file-append ccwl "/bin/ccwl")
+                                     "compile"
+                                     #$source-file)
+               get-string-all)
+             <>))))
+
+(define e2e-tools-ccwl-sources
+  `(("hello-world.scm" . ,(local-file "../e2e-tests/tools/hello-world.scm"))))
+
+(define e2e-tools
+  (file-union "e2e-tools"
+              (map (match-lambda
+                     ((ccwl-source-filename . ccwl-source-file)
+                      (let ((cwl-filename (string-append (basename ccwl-source-filename ".scm")
+                                                         ".cwl")))
+                        (list cwl-filename
+                              (computed-file cwl-filename
+                                             (ccwl-compile ccwl-source-file))))))
+                   e2e-tools-ccwl-sources)))
+
+(define e2e-test-suite
+  (file-union "e2e-test-suite"
+              `(("tests.yaml" ,(local-file "../e2e-tests/tests.yaml"))
+                ("tools" ,e2e-tools)
+                ("jobs" ,(local-file "../e2e-tests/jobs"
+                                     #:recursive? #t)))))
+
+(define-public e2e-tests
+  (program-file "e2e-tests"
+                (cwltest-suite-gexp (file-append e2e-test-suite "/tests.yaml")
+                                    (local-file "../e2e-tests/manifest.scm"))))
+
+e2e-tests
diff --git a/.guix/ravanan-package.scm b/.guix/ravanan-package.scm
index a59ec68..508e8ce 100644
--- a/.guix/ravanan-package.scm
+++ b/.guix/ravanan-package.scm
@@ -29,7 +29,16 @@
     (source (local-file ".."
                         "ravanan-checkout"
                         #:recursive? #t
-                        #:select? (or (git-predicate (dirname (current-source-directory)))
-                                      (const #t))))))
+                        #:select? (lambda (file stat)
+                                    ;; If .guix is included, changes to other
+                                    ;; files under .guix—such as the CWL
+                                    ;; conformance tests—unnecessarily trigger a
+                                    ;; rebuild of ravanan. This could be a
+                                    ;; nuisance when hacking on the CWL
+                                    ;; conformance test scripts.
+                                    (and (not (string-contains file "/.guix/"))
+                                         ((or (git-predicate (dirname (current-source-directory)))
+                                              (const #t))
+                                          file stat)))))))
 
 ravanan