@@ -23,10 +23,10 @@ def __main__() -> None:
23
23
elif (path := pathlib .Path (".github-token" )).is_file ():
24
24
token = path .read_text ().strip ()
25
25
else :
26
- token = input ("we need a GitHub access token to fetch the requirements; please visit "
26
+ token = input ("We need a GitHub access token to fetch the requirements. Please visit "
27
27
"https://github.com/settings/tokens/new, create a token with `public_repo` "
28
28
"scope, and paste it here: " ).strip ()
29
- cache = input ("do you want to cache the token in a `.github-token` file [Ny]? " )
29
+ cache = input ("Do you want to cache the token in a `.github-token` file [Ny]? " )
30
30
if cache .lower ().startswith ("y" ):
31
31
path .write_text (token )
32
32
@@ -38,13 +38,13 @@ def __main__() -> None:
38
38
if args .run : # Run id was specified.
39
39
run = args .run
40
40
elif args .pr : # PR was specified, let's get the most recent run id.
41
- print (f"fetching most recent commit for PR #{ args .pr } " )
41
+ print (f"Fetching most recent commit for PR #{ args .pr } . " )
42
42
response = requests .get (f"{ base_url } /pulls/{ args .pr } " , headers = headers )
43
43
response .raise_for_status ()
44
44
response = response .json ()
45
45
head_sha = response ["head" ]["sha" ]
46
46
else : # Nothing was specified, let's get the most recent run id on the main branch.
47
- print (f"fetching most recent commit for branch `{ args .branch } `" )
47
+ print (f"Fetching most recent commit for branch `{ args .branch } `. " )
48
48
response = requests .get (f"{ base_url } /branches/{ args .branch } " , headers = headers )
49
49
response .raise_for_status ()
50
50
response = response .json ()
@@ -61,8 +61,12 @@ def __main__() -> None:
61
61
# Get the requirements run.
62
62
runs = [run for run in response ["workflow_runs" ] if
63
63
run ["path" ].endswith ("requirements.yml" )]
64
+ if not runs :
65
+ raise RuntimeError ("Could not find a workflow. Has the GitHub Action run completed? If you"
66
+ "are a first-time contributor, a contributor has to approve your changes"
67
+ "before Actions can run." )
64
68
if len (runs ) != 1 :
65
- raise RuntimeError (f"could not identify unique workflow run: { runs } " )
69
+ raise RuntimeError (f"Could not identify unique workflow run: { runs } " )
66
70
run = runs [0 ]["id" ]
67
71
68
72
# Get all the artifacts.
@@ -72,13 +76,13 @@ def __main__() -> None:
72
76
response .raise_for_status ()
73
77
response = response .json ()
74
78
artifacts = response ["artifacts" ]
75
- print (f"discovered { len (artifacts )} artifacts" )
79
+ print (f"Discovered { len (artifacts )} artifacts. " )
76
80
77
81
# Get the content for each artifact and save it.
78
82
for artifact in artifacts :
79
83
name : str = artifact ["name" ]
80
84
name = name .removeprefix ("requirements-" )
81
- print (f"fetching artifact { name } ..." )
85
+ print (f"Fetching artifact { name } ..." )
82
86
response = requests .get (artifact ["archive_download_url" ], headers = headers )
83
87
response .raise_for_status ()
84
88
with zipfile .ZipFile (io .BytesIO (response .content )) as zip , \
@@ -87,7 +91,7 @@ def __main__() -> None:
87
91
shutil .move (pathlib .Path (tempdir ) / "requirements.txt" ,
88
92
pathlib .Path ("requirements" ) / name )
89
93
90
- print ("done " )
94
+ print ("Done. " )
91
95
92
96
93
97
if __name__ == "__main__" :
0 commit comments