Skip to content

Commit 9c578fb

Browse files
authored
Merge pull request #51 from Quantco/subdir-action-update
Fix updating actions in subdirs
2 parents 5c01809 + 00d906d commit 9c578fb

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

scripts/update_actions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ def update_workflow_actions(file_path: Path):
1616
else:
1717
action_with_rest = line.split(":")[1].strip()
1818
action, current_sha_with_version = action_with_rest.split("@")
19+
action_repo = "/".join(action.split("/")[:2])
1920
current_sha, current_version = current_sha_with_version.split("#")
2021
current_sha = current_sha.strip()
2122
current_version = current_version.strip()
22-
new_version, new_sha = get_latest_github_tag(action)
23+
new_version, new_sha = get_latest_github_tag(action_repo)
2324
print(
2425
f"{action}:"
2526
f" current version: {current_version},"

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ def generated_project(project_slug, project_description, generate_project):
6969

7070
@pytest.fixture(autouse=True)
7171
def mock_get_latest_github_tag(monkeypatch):
72-
def custom_get_latest_github_tag(_action: str) -> tuple[str, str]:
72+
def custom_get_latest_github_tag(repo_name: str) -> tuple[str, str]:
73+
assert repo_name.count("/") == 1
7374
return "v9.9.9", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
7475

7576
monkeypatch.setattr(

tests/test_template_update.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
REPO_ROOT = Path(__file__).parent.parent
99

1010

11-
def custom_get_latest_github_tag(_action: str) -> tuple[str, str]:
12-
return "v9.9.9", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
13-
14-
1511
def test_template_actions_update(tmp_path: Path):
1612
# Arrange
1713
src = REPO_ROOT / "template" / ".github" / "workflows"
@@ -44,6 +40,7 @@ def test_actions_update(tmp_path):
4440
test:
4541
steps:
4642
- uses: actions/upload-release-asset@64e5e85fc528f162d7ba7ce2d15a3bb67efb3d80 # v0.0.0
43+
- uses: actions/upload-release-asset/subdir-action@64e5e85fc528f162d7ba7ce2d15a3bb67efb3d80 # v0.0.0
4744
"""
4845
).lstrip()
4946
)
@@ -62,6 +59,7 @@ def test_actions_update(tmp_path):
6259
test:
6360
steps:
6461
- uses: actions/upload-release-asset@aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa # v9.9.9
62+
- uses: actions/upload-release-asset/subdir-action@aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa # v9.9.9
6563
"""
6664
).lstrip()
6765
)

0 commit comments

Comments
 (0)