Skip to content

improve test running on mac-os #1710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
2 changes: 1 addition & 1 deletion build-cwltool-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 0 additions & 3 deletions cwltool/argparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import urllib
from typing import (
Any,
AnyStr,
Callable,
Dict,
List,
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion cwltool/command_line_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from functools import cmp_to_key, partial
from typing import (
Any,
Callable,
Dict,
Generator,
List,
Expand Down
2 changes: 1 addition & 1 deletion cwltool/cuda.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion cwltool/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 1 addition & 9 deletions cwltool/provenance_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions tests/checker_wf/wc.cwl
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions tests/subgraph/count-lines17-wf.cwl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
4 changes: 4 additions & 0 deletions tests/subgraph/wc-tool.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
class: CommandLineTool
cwlVersion: v1.0

hints:
DockerRequirement:
dockerPull: docker.io/debian:stable-slim

inputs:
file1: File

Expand Down
6 changes: 3 additions & 3 deletions tests/test_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
12 changes: 9 additions & 3 deletions tests/test_iwdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/test_misc_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 3 additions & 1 deletion tests/test_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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"
Expand Down
5 changes: 1 addition & 4 deletions tests/test_stdout_stderr_log_dir.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_subgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_toolargparse.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
6 changes: 3 additions & 3 deletions tests/test_udocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ 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",
"--default-container",
"debian:stable-slim",
"--user-space-docker-cmd=" + udocker,
get_data(test_file),
get_data(job_file),
"--inp",
"hello",
]
)

Expand Down
4 changes: 2 additions & 2 deletions tests/wf/iwdr_permutations.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/wf/iwdr_permutations_nocontainer.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions tests/wf/wc-tool.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
class: CommandLineTool
cwlVersion: v1.0

hints:
DockerRequirement:
dockerPull: docker.io/debian:stable-slim

inputs:
file1: File

Expand Down