Skip to content

Commit 50ec2bb

Browse files
authored
Merge pull request #176 from mlcommons/arjunsuresh-patch-1
Improve github actions
2 parents c0ba5ea + 1a852bf commit 50ec2bb

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

.github/workflows/test-mlc-core-actions.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: MLC core actions test
2+
permissions:
3+
contents: read
24

35
on:
46
pull_request:
@@ -327,3 +329,9 @@ jobs:
327329
mlc help rm cache
328330
mlc help search cache
329331
mlc help show cache
332+
- name: MLC doc script
333+
run: |
334+
mlc pull repo mlcommons@mlperf-automations
335+
mlc doc script --tags=detect,cpu
336+
mlc doc script --all
337+

mlc/repo_action.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import shutil
88
from . import utils
99
from .logger import logger
10+
from urllib.parse import urlparse
1011

1112
class RepoAction(Action):
1213
"""
@@ -85,7 +86,8 @@ def add(self, run_args):
8586
if not os.path.exists(i_repo_path):
8687
#check if its an URL
8788
if utils.is_valid_url(i_repo_path):
88-
if "github.com" in i_repo_path:
89+
parsed = urlparse(i_repo_path)
90+
if parsed.hostname == "github.com":
8991
res = self.github_url_to_user_repo_format(i_repo_path)
9092
if res['return'] > 0:
9193
return res
@@ -197,12 +199,18 @@ def find(self, run_args):
197199
repo_uid = repo_split[1]
198200
elif "@" in repo:
199201
repo_name = repo
200-
elif "github.com" in repo:
201-
result = self.github_url_to_user_repo_format(repo)
202-
if result["return"] == 0:
203-
repo_name = result["value"]
204-
else:
205-
return result
202+
else:
203+
# Check for valid github.com URL using urlparse
204+
try:
205+
parsed = urlparse(repo)
206+
except Exception:
207+
parsed = None
208+
if parsed and parsed.scheme in ("http", "https") and parsed.hostname == "github.com":
209+
result = self.github_url_to_user_repo_format(repo)
210+
if result["return"] == 0:
211+
repo_name = result["value"]
212+
else:
213+
return result
206214

207215
# Check if repo_name exists in repos.json
208216
matched_repo_path = None

0 commit comments

Comments
 (0)