diff options
-rw-r--r-- | .guix/cwl-conformance.scm | 115 | ||||
-rw-r--r-- | HACKING.md | 10 | ||||
-rw-r--r-- | e2e-tests/.gitignore | 1 | ||||
-rw-r--r-- | e2e-tests/Makefile | 37 |
4 files changed, 92 insertions, 71 deletions
diff --git a/.guix/cwl-conformance.scm b/.guix/cwl-conformance.scm index 8da1645..42d25d1 100644 --- a/.guix/cwl-conformance.scm +++ b/.guix/cwl-conformance.scm @@ -19,50 +19,60 @@ (define-module (cwl-conformance) #:use-module ((cwltest-package) #:select (cwltest)) #:use-module ((ravanan-package) #:select (ravanan)) + #:use-module ((gnu packages bioinformatics) #:select (ccwl)) #:use-module ((gnu packages nss) #:select (nss-certs)) #:use-module ((gnu packages python) #:select (python)) #:use-module ((gnu packages python-web) #:select (python-pybadges)) + #:use-module (guix build utils) #: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)) -(define* (cwltest-suite-gexp manifest-file #:key (skip-tests '())) +(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)) - (match (command-line) - ((_ cwltest-suite) - ;; 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))))) - ((program _ ...) - (format (current-error-port) - "Usage: ~a CWLTEST-SUITE~%" - program) - (exit #f)))))) + ;; 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. @@ -70,9 +80,58 @@ "env_home_tmpdir_docker" "env_home_tmpdir_docker_no_return_code")))) +(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 "ravanan-e2e-tests" - (cwltest-suite-gexp (local-file "../e2e-tests/manifest.scm")))) + (program-file "e2e-tests" + (cwltest-suite-gexp (file-append e2e-test-suite "/tests.yaml") + (local-file "../e2e-tests/manifest.scm")))) (define generate-badges-gexp (with-imported-modules '((guix build utils)) diff --git a/HACKING.md b/HACKING.md index 7bb6691..e456242 100644 --- a/HACKING.md +++ b/HACKING.md @@ -7,12 +7,12 @@ guix shell -L .guix -Df manifest.scm # Run end-to-end tests -ravanan comes with a suite of end-to-end tests under `e2e-tests`. To run them, first compile the required CWL workflows from the ccwl sources. +ravanan comes with a suite of end-to-end tests under `e2e-tests`. End-to-end tests require a running Guix daemon. To run them, create and change into a new empty directory. ``` -make -C e2e-tests +mkdir rundir +cd rundir ``` -Then, run cwltest like so: +Then, build and run the tests. ``` -make -C e2e-tests check +$(guix build -L ../.guix -e '(@ (cwl-conformance) e2e-tests)') ``` -End-to-end tests require a running Guix daemon. diff --git a/e2e-tests/.gitignore b/e2e-tests/.gitignore deleted file mode 100644 index 321232f..0000000 --- a/e2e-tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tools/*.cwl \ No newline at end of file diff --git a/e2e-tests/Makefile b/e2e-tests/Makefile deleted file mode 100644 index 1410a6d..0000000 --- a/e2e-tests/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -# 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/>. - -CCWL ?= ccwl -CWLTEST ?= cwltest - -tools_directory = tools -tool_ccwl = $(wildcard $(tools_directory)/*.scm) -tool_cwl = $(tool_ccwl:.scm=.cwl) - -all: $(tool_cwl) - -%.cwl: %.scm - $(CCWL) compile $^ > $@ - -.PHONY: check clean -check: - mkdir -p /tmp/cwltest-tmpdir - TMPDIR=/tmp/cwltest-tmpdir ../pre-inst-env $(CWLTEST) --test tests.yaml --tool ravanan -- --store=store --guix-manifest=manifest.scm - -clean: - rm -f $(tool_cwl) |