Skip to content
Open
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
8 changes: 5 additions & 3 deletions landoscript/src/landoscript/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ async def process_actions(session, context, owner, repo, public_artifact_dir, br
if version_bump_actions:
lando_actions.extend(version_bump_actions)
elif action == "tag":
if "hg_repo_url" not in payload["tag_info"]:
raise TaskVerificationError("must provide hg_repo_url!")
tag_actions = await tag.run(session, tag.HgTagInfo(**payload["tag_info"]))
if "hg_repo_url" in payload["tag_info"]:
tag_info = tag.HgTagInfo(**payload["tag_info"])
else:
tag_info = tag.GitTagInfo(**payload["tag_info"])
tag_actions = await tag.run(session, tag_info)
lando_actions.extend(tag_actions)
elif action == "merge_day":
merge_day_actions = await merge_day.run(
Expand Down
51 changes: 41 additions & 10 deletions landoscript/tests/test_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,30 +59,61 @@ def assert_func(req):


@pytest.mark.asyncio
async def test_no_tags(aioresponses, github_installation_responses, context):
@pytest.mark.parametrize(
"tag_info,dry_run",
(
pytest.param(
{
"revision": "ghijkl654321",
"tags": ["BUILD1"],
},
True,
id="dry_run",
),
pytest.param(
{
"revision": "ghijkl654321",
"tags": ["BUILD1"],
},
False,
id="one_tag",
),
pytest.param(
{
"revision": "ghijkl654321",
"tags": ["BUILD1", "RELEASE"],
},
False,
id="multiple_tags",
),
),
)
async def test_success_git(aioresponses, github_installation_responses, context, tag_info, dry_run):
payload = {
"actions": ["tag"],
"lando_repo": "repo_name",
"tag_info": {
"revision": "abcdef123456",
"hg_repo_url": "https://hg.testing/repo",
"tags": [],
},
"tag_info": tag_info,
"dry_run": dry_run,
}
await run_test(aioresponses, github_installation_responses, context, payload, ["tag"], err=TaskVerificationError, errmsg="must provide at least one tag!")

def assert_func(req):
assert_tag_response(req, tag_info, tag_info["revision"])

await run_test(aioresponses, github_installation_responses, context, payload, ["tag"], not dry_run, assert_func)


@pytest.mark.asyncio
async def test_hg_repo_url(aioresponses, github_installation_responses, context):
async def test_no_tags(aioresponses, github_installation_responses, context):
payload = {
"actions": ["tag"],
"lando_repo": "repo_name",
"tag_info": {
"revision": "abcdef123456",
"tags": ["FOO"],
"hg_repo_url": "https://hg.testing/repo",
"tags": [],
},
}
await run_test(aioresponses, github_installation_responses, context, payload, ["tag"], err=TaskVerificationError, errmsg="must provide hg_repo_url!")
await run_test(aioresponses, github_installation_responses, context, payload, ["tag"], err=TaskVerificationError, errmsg="must provide at least one tag!")


@pytest.mark.parametrize(
Expand Down