| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6e1342f commit 3f67c4b
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -126,6 +126,8 @@ def __init__( | |||
| 126 | 126 | ||
| 127 | 127 | self.broadcastmessages = objects.BroadcastMessageManager(self) | |
| 128 | 128 | """See :class:`~gitlab.v4.objects.BroadcastMessageManager`""" | |
| 129 | + self.ci_lint = objects.CiLintManager(self) | ||
| 130 | + """See :class:`~gitlab.v4.objects.CiLintManager`""" | ||
| 129 | 131 | self.deploykeys = objects.DeployKeyManager(self) | |
| 130 | 132 | """See :class:`~gitlab.v4.objects.DeployKeyManager`""" | |
| 131 | 133 | self.deploytokens = objects.DeployTokenManager(self) | |
@@ -397,6 +399,11 @@ def lint(self, content: str, **kwargs: Any) -> Tuple[bool, List[str]]: | |||
| 397 | 399 | Returns: | |
| 398 | 400 | (True, []) if the file is valid, (False, errors(list)) otherwise | |
| 399 | 401 | """ | |
| 402 | + utils.warn( | ||
| 403 | + "`lint()` is deprecated and will be removed in a future version.\n" | ||
| 404 | + "Please use `ci_lint.create()` instead.", | ||
| 405 | + category=DeprecationWarning, | ||
| 406 | + ) | ||
| 400 | 407 | post_data = {"content": content} | |
| 401 | 408 | data = self.http_post("/ci/lint", post_data=post_data, **kwargs) | |
| 402 | 409 | if TYPE_CHECKING: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,25 @@ | |||
| 9 | 9 | from gitlab.mixins import CreateMixin, GetWithoutIdMixin | |
| 10 | 10 | from gitlab.types import RequiredOptional | |
| 11 | 11 | ||
| 12 | + __all__ = [ | ||
| 13 | + "CiLint", | ||
| 14 | + "CiLintManager", | ||
| 15 | + "ProjectCiLint", | ||
| 16 | + "ProjectCiLintManager", | ||
| 17 | + ] | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + class CiLint(RESTObject): | ||
| 21 | + _id_attr = None | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + class CiLintManager(CreateMixin, RESTManager): | ||
| 25 | + _path = "/ci/lint" | ||
| 26 | + _obj_cls = CiLint | ||
| 27 | + _create_attrs = RequiredOptional( | ||
| 28 | + required=("content",), optional=("include_merged_yaml", "include_jobs") | ||
| 29 | + ) | ||
| 30 | + | ||
| 12 | 31 | ||
| 13 | 32 | class ProjectCiLint(RESTObject): | |
| 14 | 33 | pass | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,7 +38,7 @@ | |||
| 38 | 38 | from .badges import ProjectBadgeManager # noqa: F401 | |
| 39 | 39 | from .boards import ProjectBoardManager # noqa: F401 | |
| 40 | 40 | from .branches import ProjectBranchManager, ProjectProtectedBranchManager # noqa: F401 | |
| 41 | - from .ci_lint import ProjectCiLint, ProjectCiLintManager # noqa: F401 | ||
| 41 | + from .ci_lint import ProjectCiLintManager # noqa: F401 | ||
| 42 | 42 | from .clusters import ProjectClusterManager # noqa: F401 | |
| 43 | 43 | from .commits import ProjectCommitManager # noqa: F401 | |
| 44 | 44 | from .container_registry import ProjectRegistryRepositoryManager # noqa: F401 | |
@@ -102,8 +102,6 @@ | |||
| 102 | 102 | "ProjectRemoteMirrorManager", | |
| 103 | 103 | "ProjectStorage", | |
| 104 | 104 | "ProjectStorageManager", | |
| 105 | - "ProjectCiLint", | ||
| 106 | - "ProjectCiLintManager", | ||
| 107 | 105 | ] | |
| 108 | 106 | ||
| 109 | 107 | ||
@@ -165,7 +163,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO | |||
| 165 | 163 | badges: ProjectBadgeManager | |
| 166 | 164 | boards: ProjectBoardManager | |
| 167 | 165 | branches: ProjectBranchManager | |
| 168 | - ci_lint: "ProjectCiLintManager" | ||
| 166 | + ci_lint: ProjectCiLintManager | ||
| 169 | 167 | clusters: ProjectClusterManager | |
| 170 | 168 | commits: ProjectCommitManager | |
| 171 | 169 | customattributes: ProjectCustomAttributeManager | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,15 @@ | |||
| 1 | 1 | import pytest | |
| 2 | 2 | import responses | |
| 3 | 3 | ||
| 4 | - ci_lint_get_content = { | ||
| 4 | + gitlab_ci_yml = """--- | ||
| 5 | + :test_job: | ||
| 6 | + :script: echo 1 | ||
| 7 | + """ | ||
| 8 | + | ||
| 9 | + ci_lint_create_content = {"status": "valid", "errors": [], "warnings": []} | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + project_ci_lint_content = { | ||
| 5 | 13 | "valid": True, | |
| 6 | 14 | "merged_yaml": "---\n:test_job:\n :script: echo 1\n", | |
| 7 | 15 | "errors": [], | |
@@ -10,40 +18,54 @@ | |||
| 10 | 18 | ||
| 11 | 19 | ||
| 12 | 20 | @pytest.fixture | |
| 13 | - def resp_get_ci_lint(): | ||
| 21 | + def resp_create_ci_lint(): | ||
| 22 | + with responses.RequestsMock() as rsps: | ||
| 23 | + rsps.add( | ||
| 24 | + method=responses.POST, | ||
| 25 | + url="http://localhost/api/v4/ci/lint", | ||
| 26 | + json=ci_lint_create_content, | ||
| 27 | + content_type="application/json", | ||
| 28 | + status=200, | ||
| 29 | + ) | ||
| 30 | + yield rsps | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + @pytest.fixture | ||
| 34 | + def resp_get_project_ci_lint(): | ||
| 14 | 35 | with responses.RequestsMock() as rsps: | |
| 15 | 36 | rsps.add( | |
| 16 | 37 | method=responses.GET, | |
| 17 | 38 | url="http://localhost/api/v4/projects/1/ci/lint", | |
| 18 | - json=ci_lint_get_content, | ||
| 39 | + json=project_ci_lint_content, | ||
| 19 | 40 | content_type="application/json", | |
| 20 | 41 | status=200, | |
| 21 | 42 | ) | |
| 22 | 43 | yield rsps | |
| 23 | 44 | ||
| 24 | 45 | ||
| 25 | 46 | @pytest.fixture | |
| 26 | - def resp_create_ci_lint(): | ||
| 47 | + def resp_create_project_ci_lint(): | ||
| 27 | 48 | with responses.RequestsMock() as rsps: | |
| 28 | 49 | rsps.add( | |
| 29 | 50 | method=responses.POST, | |
| 30 | 51 | url="http://localhost/api/v4/projects/1/ci/lint", | |
| 31 | - json=ci_lint_get_content, | ||
| 52 | + json=project_ci_lint_content, | ||
| 32 | 53 | content_type="application/json", | |
| 33 | 54 | status=200, | |
| 34 | 55 | ) | |
| 35 | 56 | yield rsps | |
| 36 | 57 | ||
| 37 | 58 | ||
| 38 | - def test_project_ci_lint_get(project, resp_get_ci_lint): | ||
| 59 | + def test_ci_lint_create(gl, resp_create_ci_lint): | ||
| 60 | + lint_result = gl.ci_lint.create({"content": gitlab_ci_yml}) | ||
| 61 | + assert lint_result.status == "valid" | ||
| 62 | + | ||
| 63 | + | ||
| 64 | + def test_project_ci_lint_get(project, resp_get_project_ci_lint): | ||
| 39 | 65 | lint_result = project.ci_lint.get() | |
| 40 | 66 | assert lint_result.valid is True | |
| 41 | 67 | ||
| 42 | 68 | ||
| 43 | - def test_project_ci_lint_create(project, resp_create_ci_lint): | ||
| 44 | - gitlab_ci_yml = """--- | ||
| 45 | - :test_job: | ||
| 46 | - :script: echo 1 | ||
| 47 | - """ | ||
| 69 | + def test_project_ci_lint_create(project, resp_create_project_ci_lint): | ||
| 48 | 70 | lint_result = project.ci_lint.create({"content": gitlab_ci_yml}) | |
| 49 | 71 | assert lint_result.valid is True | |
| Back | FazBrowse Home | New Git URL |
0 commit comments