Update pr_helper criticality score (#10566)

Update repo_url as criticality score does not support url ends with
'.git'.
Example: 
~/go/bin$ `./criticality_score --format json
-gcp-project-id=clusterfuzz-external
https://github.com/kubernetes/kubernetes.git`
2023-06-21 14:27:39.583	INFO	Preparing default scorer
2023-06-21 14:27:41.007	INFO	deps.dev signal source enabled
`2023-06-21 14:27:41.869 WARN Repo cannot be collected {"worker": 0,
"url": "https://github.com/kubernetes/kubernetes.git", "error": "repo
failed: not found: https://github.com/kubernetes/kubernetes.git"}`

---------

Co-authored-by: Dongge Liu <alan32.liu@gmail.com>
This commit is contained in:
Holly Gong 2023-06-22 10:27:23 +10:00 committed by GitHub
parent 71b357c4f3
commit 123e5980b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -35,6 +35,9 @@ CRITICALITY_SCORE_PATH = '/home/runner/go/bin/criticality_score'
def get_criticality_score(repo_url):
"""Gets the criticality score of the project."""
# Criticality score does not support repo url ends with '.git'
if repo_url.endswith('.git'):
repo_url = repo_url[:-4]
report = subprocess.run([
CRITICALITY_SCORE_PATH, '--format', 'json',
'-gcp-project-id=clusterfuzz-external', '-depsdev-disable', repo_url
@ -42,7 +45,12 @@ def get_criticality_score(repo_url):
capture_output=True,
text=True)
report_dict = json.loads(report.stdout)
try:
report_dict = json.loads(report.stdout)
except:
print(f'Criticality score failed with stdout: {report.stdout}')
print(f'Criticality score failed with stderr: {report.stderr}')
return 'N/A'
return report_dict.get('default_score', 'N/A')