Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/inab/WfExS-backend
Browse files Browse the repository at this point in the history
  • Loading branch information
jmfernandez committed Aug 30, 2023
2 parents bb862a1 + 06c46d1 commit a60b6a2
Show file tree
Hide file tree
Showing 13 changed files with 332 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
types:
- python
exclude: "^[^/]*env/|dev-[^/]*/"
entry: pylint -j 4
entry: pylint -j 4 --source-roots .
- id: mypy
name: Local MyPy
language: system
Expand Down
2 changes: 2 additions & 0 deletions .pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
testpaths = tests
3 changes: 3 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ authors:
- family-names: Iborra
given-names: Paula
orcid: "https://orcid.org/0000-0003-0504-3029"
- family-names: Lea
given-names: Daniel
orcid: "https://orcid.org/0000-0001-8152-0398"
cff-version: 1.2.0
date-released: "2023-08-01"
identifiers:
Expand Down
3 changes: 3 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
wheel
pylint < 2.14.0 ; python_version == '3.6'
pylint >= 2.15.5 ; python_version >= '3.7'
pytest
pytest-cov
pytest-xdist
pyflakes >= 2.5.0
flake8 < 6.0.0 ; python_version < '3.8'
flake8 >= 6.0.0 ; python_version >= '3.8'
Expand Down
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Tests for WfExS-backend"""
Empty file added tests/fetchers/__init__.py
Empty file.
171 changes: 171 additions & 0 deletions tests/fetchers/test_git.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
import pytest
import logging
from typing import (
cast,
TYPE_CHECKING,
)

if TYPE_CHECKING:
from wfexs_backend.common import (
RelPath,
RepoTag,
RepoURL,
URIType,
)

from wfexs_backend.common import (
RepoGuessFlavor,
RemoteRepo,
RepoType,
)
from wfexs_backend.fetchers.git import guess_git_repo_params


@pytest.mark.parametrize(
["url", "expected"],
[
(
"https://github.com/inab/WfExS-backend.git",
RemoteRepo(
repo_url=cast("RepoURL", "https://github.com/inab/WfExS-backend.git"),
tag=cast("RepoTag", "main"),
guess_flavor=RepoGuessFlavor.GitHub,
repo_type=RepoType.Git,
),
),
(
"git+https://github.com/inab/WfExS-backend.git",
RemoteRepo(
repo_url=cast("RepoURL", "https://github.com/inab/WfExS-backend.git"),
tag=cast("RepoTag", "main"),
repo_type=RepoType.Git,
),
),
(
"https://github.com/inab/WfExS-backend.git@0.1.2",
RemoteRepo(
repo_url=cast("RepoURL", "https://github.com/inab/WfExS-backend.git"),
repo_type=RepoType.Git,
tag=cast("RepoTag", "0.1.2"),
),
),
(
"https://github.com/inab/WfExS-backend.git#subdirectory=workflow_examples/ipc/cosifer_test1_cwl.wfex.stage",
RemoteRepo(
repo_url=cast("RepoURL", "https://github.com/inab/WfExS-backend.git"),
repo_type=RepoType.Git,
tag=cast("RepoTag", "main"),
rel_path=cast(
"RelPath", "workflow_examples/ipc/cosifer_test1_cwl.wfex.stage"
),
),
),
(
"ssh://git@github.com:inab/WfExS-backend.git",
RemoteRepo(
repo_url=cast("RepoURL", "ssh://git@github.com/inab/WfExS-backend.git"),
tag=cast("RepoTag", "main"),
repo_type=RepoType.Git,
),
),
(
"git+ssh://git@github.com:inab/WfExS-backend.git",
RemoteRepo(
repo_url=cast("RepoURL", "ssh://git@github.com/inab/WfExS-backend.git"),
tag=cast("RepoTag", "main"),
repo_type=RepoType.Git,
),
),
(
"ssh://git@github.com:inab/WfExS-backend.git@0.1.2",
RemoteRepo(
repo_url=cast("RepoURL", "ssh://git@github.com/inab/WfExS-backend.git"),
repo_type=RepoType.Git,
tag=cast("RepoTag", "0.1.2"),
),
),
(
"ssh://git@github.com:inab/WfExS-backend.git#subdirectory=workflow_examples/ipc/cosifer_test1_cwl.wfex.stage",
RemoteRepo(
repo_url=cast("RepoURL", "ssh://git@github.com/inab/WfExS-backend.git"),
repo_type=RepoType.Git,
tag=cast("RepoTag", "main"),
rel_path=cast(
"RelPath", "workflow_examples/ipc/cosifer_test1_cwl.wfex.stage"
),
),
),
(
"file:///inab/WfExS-backend/.git",
RemoteRepo(
repo_url=cast("RepoURL", "file:///inab/WfExS-backend/.git"),
repo_type=RepoType.Git,
),
),
(
"git+file:///inab/WfExS-backend/.git",
RemoteRepo(
repo_url=cast("RepoURL", "file:///inab/WfExS-backend/.git"),
repo_type=RepoType.Git,
),
),
(
"file:///inab/WfExS-backend/.git@0.1.2",
RemoteRepo(
repo_url=cast("RepoURL", "file:///inab/WfExS-backend/.git"),
repo_type=RepoType.Git,
tag=cast("RepoTag", "0.1.2"),
),
),
(
"file:///inab/WfExS-backend/.git#subdirectory=workflow_examples/ipc/cosifer_test1_cwl.wfex.stage",
RemoteRepo(
repo_url=cast("RepoURL", "file:///inab/WfExS-backend/.git"),
repo_type=RepoType.Git,
rel_path=cast(
"RelPath", "workflow_examples/ipc/cosifer_test1_cwl.wfex.stage"
),
),
),
(
"github.com/inab/WfExS-backend.git",
None,
),
(
"git@github.com:inab/WfExS-backend.git",
RemoteRepo(
repo_url=cast("RepoURL", "ssh://git@github.com/inab/WfExS-backend.git"),
tag=cast("RepoTag", "main"),
repo_type=RepoType.Git,
),
),
(
"ssh://git@github.com:inab/WfExS-backend",
RemoteRepo(
repo_url=cast("RepoURL", "ssh://git@github.com/inab/WfExS-backend"),
tag=cast("RepoTag", "main"),
repo_type=RepoType.Git,
),
),
(
"https://github.com/inab/WfExS-backend",
RemoteRepo(
repo_url=cast("RepoURL", "https://github.com/inab/WfExS-backend"),
guess_flavor=RepoGuessFlavor.GitHub,
repo_type=RepoType.Git,
tag=cast("RepoTag", "main"),
),
),
(
"file:///inab/WfExS-backend",
RemoteRepo(
repo_url=cast("RepoURL", "file:///inab/WfExS-backend"),
repo_type=RepoType.Git,
),
),
],
)
def test_guess_git_repo_params(url: "str", expected: "RemoteRepo") -> "None":
logger = logging.Logger("name")
output = guess_git_repo_params(cast("URIType", url), logger=logger)
assert output == expected
11 changes: 8 additions & 3 deletions wfexs_backend/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,15 +663,19 @@ def _value_fixes(cls) -> "Mapping[str, Optional[str]]":


class RepoType(enum.Enum):
GitHub = "github"
GitLab = "gitlab"
BitBucket = "bitbucket"
Git = "git"
Raw = "raw"
Other = "other"
SoftwareHeritage = "swh"
TRS = "trs"


class RepoGuessFlavor(enum.Enum):
GitHub = "github"
GitLab = "gitlab"
BitBucket = "bitbucket"


class RemoteRepo(NamedTuple):
"""
Remote repository description
Expand All @@ -682,6 +686,7 @@ class RemoteRepo(NamedTuple):
rel_path: "Optional[RelPath]" = None
repo_type: "Optional[RepoType]" = None
web_url: "Optional[URIType]" = None
guess_flavor: "Optional[RepoGuessFlavor]" = None


class IdentifiedWorkflow(NamedTuple):
Expand Down
5 changes: 3 additions & 2 deletions wfexs_backend/cwl_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ class CWLWorkflowEngine(WorkflowEngine):

CWL_REPO = "https://github.com/common-workflow-language/"
CWLTOOL_REPO = CWL_REPO + CWLTOOL_PYTHON_PACKAGE
DEVEL_CWLTOOL_REPO = "https://github.com/jmfernandez/" + CWLTOOL_PYTHON_PACKAGE
# DEVEL_CWLTOOL_REPO = "https://github.com/jmfernandez/" + CWLTOOL_PYTHON_PACKAGE
DEVEL_CWLTOOL_REPO = CWLTOOL_REPO
CWL_UTILS_REPO = CWL_REPO + CWL_UTILS_PYTHON_PACKAGE

DEFAULT_CWLTOOL_VERSION = cast("EngineVersion", "3.1.20230719185429")
Expand All @@ -135,7 +136,7 @@ class CWLWorkflowEngine(WorkflowEngine):
DEVEL_CWLTOOL_PACKAGE = f"git+{DEVEL_CWLTOOL_REPO}.git"
# Set this constant to something meaningful only when a hotfix
# between releases is needed
DEVEL_CWLTOOL_VERSION = "191841853da642f2446b7298bc814db81e7149a7"
DEVEL_CWLTOOL_VERSION = "509ffb9d6802c837ec2a818b799ef4c332c34d04"
# DEVEL_CWLTOOL_VERSION = None

# DEFAULT_CWL_UTILS_VERSION = 'v0.10'
Expand Down
Loading

0 comments on commit a60b6a2

Please sign in to comment.