about summary refs log tree commit diff
path: root/.guix/cwltest-package.scm
blob: f3eeb9ddaaee73ef6ac415c7fb070ff7829ef09e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
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