diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 2a934f2aa..5b89bbc61 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -184,3 +184,43 @@ jobs: - uses: actions/checkout@v3 - name: build & test cwltool_module container run: ./build-cwltool-docker.sh + + macos: + name: CI test on macos-latest + runs-on: macos-latest + env: + TOXENV: py310-unit + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + cache: pip + cache-dependency-path: | + requirements.txt + tox.ini + - name: Upgrade setuptools and install tox + run: | + pip install -U pip setuptools wheel + pip install tox tox-gh-actions + # # docker for mac install is not currently stable + # - name: 'SETUP MacOS: load Homebrew cache' + # uses: actions/cache@v3 + # if: runner.os == 'macOS' + # with: + # path: | + # ~/Library/Caches/Homebrew/downloads/*--Docker.dmg + # key: brew-actions-setup-docker-1.0.11 + # restore-keys: brew-actions-setup-docker- + # - name: setup docker on macos (default stable version) + # uses: docker-practice/actions-setup-docker@master + - name: Test with tox + run: tox + - name: Upload coverage to Codecov + if: ${{ matrix.step == 'unit' }} + uses: codecov/codecov-action@v3 + with: + fail_ci_if_error: true diff --git a/Makefile b/Makefile index f0f65168e..d633a6979 100644 --- a/Makefile +++ b/Makefile @@ -157,11 +157,11 @@ diff-cover: coverage.xml diff-cover.html: coverage.xml diff-cover --compare-branch=main $^ --html-report $@ -## test : run the ${MODULE} test suite +## test : run the cwltool test suite test: check-python3 $(PYSOURCES) python -m pytest -rs ${PYTEST_EXTRA} -## testcov : run the ${MODULE} test suite and collect coverage +## testcov : run the cwltool test suite and collect coverage testcov: check-python3 $(PYSOURCES) python -m pytest -rs --cov --cov-config=.coveragerc --cov-report= ${PYTEST_EXTRA} diff --git a/build-cwltool-docker.sh b/build-cwltool-docker.sh index 85e150a49..d733b9919 100755 --- a/build-cwltool-docker.sh +++ b/build-cwltool-docker.sh @@ -7,4 +7,4 @@ docker run -t -v /var/run/docker.sock:/var/run/docker.sock \ -v /tmp:/tmp \ -v "$PWD":/tmp/cwltool \ quay.io/commonwl/cwltool_module /bin/sh -c \ - "apk add gcc bash && pip install -r/tmp/cwltool/test-requirements.txt ; pytest -k 'not (test_bioconda or test_double_overwrite or test_env_filtering or test_biocontainers or test_disable_file_overwrite_without_ext or test_disable_file_creation_in_outdir_with_ext or test_write_write_conflict or test_directory_literal_with_real_inputs_inside or test_revsort_workflow or test_stdin_with_id_preset)' --ignore-glob '*test_udocker.py' -n auto -v -rs --pyargs cwltool" + "apk add gcc bash && pip install -r/tmp/cwltool/test-requirements.txt ; pytest -k 'not (test_bioconda or test_double_overwrite or test_env_filtering or test_biocontainers or test_disable_file_overwrite_without_ext or test_disable_file_creation_in_outdir_with_ext or test_write_write_conflict or test_directory_literal_with_real_inputs_inside or test_revsort_workflow or test_stdin_with_id_preset or test_no_compute_chcksum or test_packed_workflow_execution[tests/wf/count-lines1-wf.cwl-tests/wf/wc-job.json-False] or test_sequential_workflow or test_single_process_subwf_subwf_inline_step)' --ignore-glob '*test_udocker.py' -n 0 -v -rs --pyargs cwltool" diff --git a/cwltool/argparser.py b/cwltool/argparser.py index 8dba4ce28..8a2328fce 100644 --- a/cwltool/argparser.py +++ b/cwltool/argparser.py @@ -5,7 +5,6 @@ import urllib from typing import ( Any, - AnyStr, Callable, Dict, List, @@ -18,8 +17,6 @@ cast, ) -from schema_salad.ref_resolver import file_uri - from .loghandler import _logger from .process import Process, shortname from .resolver import ga4gh_tool_registries diff --git a/cwltool/command_line_tool.py b/cwltool/command_line_tool.py index e4ba6f961..6125d5d17 100644 --- a/cwltool/command_line_tool.py +++ b/cwltool/command_line_tool.py @@ -15,7 +15,6 @@ from functools import cmp_to_key, partial from typing import ( Any, - Callable, Dict, Generator, List, diff --git a/cwltool/cuda.py b/cwltool/cuda.py index 65dc19c10..50bee5599 100644 --- a/cwltool/cuda.py +++ b/cwltool/cuda.py @@ -1,6 +1,6 @@ import subprocess # nosec import xml.dom.minidom # nosec -from typing import Tuple, cast +from typing import Tuple from .loghandler import _logger from .utils import CWLObjectType diff --git a/cwltool/docker.py b/cwltool/docker.py index b7578faf9..1d7c9f978 100644 --- a/cwltool/docker.py +++ b/cwltool/docker.py @@ -16,7 +16,6 @@ from .builder import Builder from .context import RuntimeContext -from .cuda import cuda_check from .docker_id import docker_vm_id from .errors import WorkflowException from .job import ContainerCommandLineJob diff --git a/cwltool/provenance_profile.py b/cwltool/provenance_profile.py index 0252127bb..465f79351 100644 --- a/cwltool/provenance_profile.py +++ b/cwltool/provenance_profile.py @@ -20,15 +20,7 @@ ) from prov.identifier import Identifier, QualifiedName -from prov.model import ( - PROV, - PROV_LABEL, - PROV_TYPE, - PROV_VALUE, - ProvDocument, - ProvEntity, - ProvRecord, -) +from prov.model import PROV, PROV_LABEL, PROV_TYPE, PROV_VALUE, ProvDocument, ProvEntity from schema_salad.sourceline import SourceLine from typing_extensions import TYPE_CHECKING diff --git a/tests/checker_wf/wc.cwl b/tests/checker_wf/wc.cwl index f472862ce..abfc41cd8 100755 --- a/tests/checker_wf/wc.cwl +++ b/tests/checker_wf/wc.cwl @@ -1,6 +1,9 @@ #!/usr/bin/env cwl-runner cwlVersion: v1.1 class: CommandLineTool +hints: + DockerRequirement: + dockerPull: docker.io/debian:stable-slim inputs: intxt: type: File diff --git a/tests/subgraph/count-lines17-wf.cwl.json b/tests/subgraph/count-lines17-wf.cwl.json index 1fd4e29cd..279790b87 100644 --- a/tests/subgraph/count-lines17-wf.cwl.json +++ b/tests/subgraph/count-lines17-wf.cwl.json @@ -113,6 +113,11 @@ "-l" ], "class": "CommandLineTool", + "hints": { + "DockerRequirement": { + "dockerPull": "docker.io/debian:stable-slim" + } + }, "id": "count-lines17-wf.cwl@step_step1@run@step_stepX@run@step_stepY@run", "inputs": [ { diff --git a/tests/subgraph/wc-tool.cwl b/tests/subgraph/wc-tool.cwl index 165585494..f458e2df0 100755 --- a/tests/subgraph/wc-tool.cwl +++ b/tests/subgraph/wc-tool.cwl @@ -3,6 +3,10 @@ class: CommandLineTool cwlVersion: v1.0 +hints: + DockerRequirement: + dockerPull: docker.io/debian:stable-slim + inputs: file1: File diff --git a/tests/test_cuda.py b/tests/test_cuda.py index 61920a969..3ebe476fb 100644 --- a/tests/test_cuda.py +++ b/tests/test_cuda.py @@ -11,10 +11,10 @@ from cwltool.job import CommandLineJob from cwltool.load_tool import load_tool from cwltool.main import main -from cwltool.pathmapper import MapperEnt, PathMapper -from cwltool.process import use_custom_schema, use_standard_schema +from cwltool.pathmapper import PathMapper +from cwltool.process import use_custom_schema from cwltool.stdfsaccess import StdFsAccess -from cwltool.update import INTERNAL_VERSION, ORIGINAL_CWLVERSION +from cwltool.update import INTERNAL_VERSION from cwltool.utils import CWLObjectType from .util import get_data, needs_docker, needs_singularity_3_or_newer diff --git a/tests/test_examples.py b/tests/test_examples.py index ee899f9a3..47f62230d 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -910,6 +910,7 @@ def test_static_checker() -> None: factory.make(get_data("tests/checker_wf/broken-wf3.cwl")) +@needs_docker def test_circular_dependency_checker() -> None: # check that the circular dependency checker raises exception when there is # circular dependency in the workflow. @@ -1119,8 +1120,9 @@ def test_cid_file_dir(tmp_path: Path, factor: str) -> None: stderr = re.sub(r"\s\s+", " ", stderr) assert "completed success" in stderr assert error_code == 0 - cidfiles_count = sum(1 for _ in tmp_path.glob("**/*")) - assert cidfiles_count == 2 + cidfiles = list(tmp_path.glob("**/*.cid")) + cidfiles_count = len(cidfiles) + assert cidfiles_count == 2, f"Should be 2 cidfiles, but got {cidfiles}" @needs_docker @@ -1449,6 +1451,7 @@ def test_no_compute_chcksum(tmp_path: Path, factor: str) -> None: assert "checksum" not in stdout +@needs_docker @pytest.mark.parametrize("factor", test_factors) def test_bad_userspace_runtime(factor: str) -> None: test_file = "tests/wf/wc-tool.cwl" diff --git a/tests/test_iwdr.py b/tests/test_iwdr.py index 163492c89..9eea8a8e1 100644 --- a/tests/test_iwdr.py +++ b/tests/test_iwdr.py @@ -131,7 +131,9 @@ def test_iwdr_permutations(tmp_path_factory: Any) -> None: ) assert err_code == 0 log = json.loads(stdout)["log"] - assert log["checksum"] == "sha1$bc51ebb3f65ca44282789dd1e6de9747d8abe75f", log + with open(log["path"]) as log_h: + log_text = log_h.read() + assert log["checksum"] == "sha1$bc51ebb3f65ca44282789dd1e6de9747d8abe75f", log_text def test_iwdr_permutations_readonly(tmp_path_factory: Any) -> None: @@ -240,7 +242,9 @@ def test_iwdr_permutations_inplace(tmp_path_factory: Any) -> None: ) assert err_code == 0 log = json.loads(stdout)["log"] - assert log["checksum"] == "sha1$bc51ebb3f65ca44282789dd1e6de9747d8abe75f", log + with open(log["path"]) as log_h: + log_text = log_h.read() + assert log["checksum"] == "sha1$bc51ebb3f65ca44282789dd1e6de9747d8abe75f", log_text @needs_singularity @@ -298,7 +302,9 @@ def test_iwdr_permutations_singularity(tmp_path_factory: Any) -> None: ) assert err_code == 0 log = json.loads(stdout)["log"] - assert log["checksum"] == "sha1$bc51ebb3f65ca44282789dd1e6de9747d8abe75f", log + with open(log["path"]) as log_h: + log_text = log_h.read() + assert log["checksum"] == "sha1$bc51ebb3f65ca44282789dd1e6de9747d8abe75f", log_text @needs_singularity diff --git a/tests/test_misc_cli.py b/tests/test_misc_cli.py index 602b381bc..13d6e6887 100644 --- a/tests/test_misc_cli.py +++ b/tests/test_misc_cli.py @@ -2,7 +2,7 @@ from cwltool.utils import versionstring -from .util import get_data, get_main_output +from .util import get_data, get_main_output, needs_docker def test_version() -> None: @@ -44,6 +44,7 @@ def test_basic_pack() -> None: assert "$graph" in stdout +@needs_docker def test_basic_print_subgraph() -> None: """Basic test of --print-subgraph. See test_subgraph.py for detailed testing.""" return_code, stdout, stderr = get_main_output( diff --git a/tests/test_parallel.py b/tests/test_parallel.py index e989e4f0a..8c86d41fc 100644 --- a/tests/test_parallel.py +++ b/tests/test_parallel.py @@ -5,9 +5,10 @@ from cwltool.executors import MultithreadedJobExecutor from cwltool.factory import Factory -from .util import get_data +from .util import get_data, needs_docker +@needs_docker def test_sequential_workflow(tmp_path: Path) -> None: test_file = "tests/wf/count-lines1-wf.cwl" executor = MultithreadedJobExecutor() @@ -20,6 +21,7 @@ def test_sequential_workflow(tmp_path: Path) -> None: assert echo(file1=file_contents) == {"count_output": 16} +@needs_docker def test_scattered_workflow() -> None: test_file = "tests/wf/scatter-wf4.cwl" job_file = "tests/wf/scatter-job2.json" diff --git a/tests/test_stdout_stderr_log_dir.py b/tests/test_stdout_stderr_log_dir.py index d80ca1b67..35075317a 100644 --- a/tests/test_stdout_stderr_log_dir.py +++ b/tests/test_stdout_stderr_log_dir.py @@ -1,10 +1,7 @@ import json -import os from pathlib import Path -from cwltool.main import main - -from .util import get_data, get_main_output, needs_docker +from .util import get_data, get_main_output def test_log_dir_echo_output(tmp_path: Path) -> None: diff --git a/tests/test_subgraph.py b/tests/test_subgraph.py index a23ce1f89..a4ac69347 100644 --- a/tests/test_subgraph.py +++ b/tests/test_subgraph.py @@ -240,6 +240,7 @@ def test_single_process_packed_subwf_step(tmp_path: Path) -> None: ) +@needs_docker def test_single_process_subwf_subwf_inline_step() -> None: """Test --single-process on an inline sub-sub-workflow step.""" err_code, stdout, stderr = get_main_output( @@ -350,6 +351,7 @@ def test_print_targets_embedded_reqsinherit() -> None: assert err_code == 0 +@needs_docker def test_print_targets_embedded_sub_subwfs() -> None: """Confirm that --print-targets works with inline sub-sub-workflows.""" err_code, stdout, stderr = get_main_output( diff --git a/tests/test_toolargparse.py b/tests/test_toolargparse.py index d7807084a..8200b6598 100644 --- a/tests/test_toolargparse.py +++ b/tests/test_toolargparse.py @@ -1,7 +1,7 @@ import argparse from io import StringIO from pathlib import Path -from typing import Any, Callable, Dict, List +from typing import Callable, List import pytest diff --git a/tests/test_udocker.py b/tests/test_udocker.py index 06f543740..d63d05949 100644 --- a/tests/test_udocker.py +++ b/tests/test_udocker.py @@ -50,8 +50,7 @@ def test_udocker_usage_should_not_write_cid_file(udocker: str, tmp_path: Path) - """Confirm that no cidfile is made when udocker is used.""" with working_directory(tmp_path): - test_file = "tests/wf/wc-tool.cwl" - job_file = "tests/wf/wc-job.json" + test_file = "tests/echo.cwl" error_code, stdout, stderr = get_main_output( [ "--debug", @@ -59,7 +58,8 @@ def test_udocker_usage_should_not_write_cid_file(udocker: str, tmp_path: Path) - "debian:stable-slim", "--user-space-docker-cmd=" + udocker, get_data(test_file), - get_data(job_file), + "--inp", + "hello", ] ) diff --git a/tests/wf/iwdr_permutations.cwl b/tests/wf/iwdr_permutations.cwl index e4f6bba03..97500635a 100755 --- a/tests/wf/iwdr_permutations.cwl +++ b/tests/wf/iwdr_permutations.cwl @@ -74,13 +74,13 @@ stdout: log.txt baseCommand: [bash, -c] arguments: - | - find . | sort + find . | grep -v '\.docker' | sort find /my_path | sort find /my_other_path | sort echo "a" > first_writable_file echo "b" > /my_path/third_writable_file touch fifth_writable_directory/c touch /my_path/seventh_writable_directory/d - find . | sort + find . | grep -v '\.docker' | sort find /my_path | sort find /my_other_path | sort diff --git a/tests/wf/iwdr_permutations_nocontainer.cwl b/tests/wf/iwdr_permutations_nocontainer.cwl index 0ef2e2646..1a4580ee9 100755 --- a/tests/wf/iwdr_permutations_nocontainer.cwl +++ b/tests/wf/iwdr_permutations_nocontainer.cwl @@ -38,6 +38,6 @@ outputs: baseCommand: [bash, -c] arguments: - | - find . + find . | grep -v '\.docker' | sort echo "a" > first_writable_file touch fifth_writable_directory/c diff --git a/tests/wf/wc-tool.cwl b/tests/wf/wc-tool.cwl index 165585494..f458e2df0 100755 --- a/tests/wf/wc-tool.cwl +++ b/tests/wf/wc-tool.cwl @@ -3,6 +3,10 @@ class: CommandLineTool cwlVersion: v1.0 +hints: + DockerRequirement: + dockerPull: docker.io/debian:stable-slim + inputs: file1: File