@@ -52,7 +52,7 @@ def get_step_message(log, start, end, title, message, details):
52
52
return res
53
53
54
54
55
- def get_message (log_file , repo , run_id , details ):
55
+ def get_message (log_file , repo , pr_number , sha , run_id , details ):
56
56
with open (log_file , "r" ) as f :
57
57
log = f .read ()
58
58
@@ -152,15 +152,21 @@ def get_message(log_file, repo, run_id, details):
152
152
details = details ,
153
153
)
154
154
155
+ commit_link = (
156
+ "\n \n _Generated for commit:"
157
+ f" [{ sha [:7 ]} ](https://github.com/{ repo } /pull/{ pr_number } /commits/{ sha } )_"
158
+ )
159
+
155
160
if not message :
156
161
# no issues detected, so this script "fails"
157
162
return (
158
- "## Linting Passed\n "
163
+ "## ✔️ Linting Passed\n "
159
164
"All linting checks passed. Your pull request is in excellent shape! ☀️"
165
+ + commit_link
160
166
)
161
167
162
168
message = (
163
- "## Linting issues\n \n "
169
+ "## ❌ Linting issues\n \n "
164
170
"This PR is introducing linting issues. Here's a summary of the issues. "
165
171
"Note that you can avoid having linting issues by enabling `pre-commit` "
166
172
"hooks. Instructions to enable them can be found [here]("
@@ -169,6 +175,7 @@ def get_message(log_file, repo, run_id, details):
169
175
"You can see the details of the linting issues under the `lint` job [here]"
170
176
f"(https://github.com/{ repo } /actions/runs/{ run_id } )\n \n "
171
177
+ message
178
+ + commit_link
172
179
)
173
180
174
181
return message
@@ -245,6 +252,7 @@ def create_or_update_comment(comment, message, repo, pr_number, token):
245
252
repo = os .environ ["GITHUB_REPOSITORY" ]
246
253
token = os .environ ["GITHUB_TOKEN" ]
247
254
pr_number = os .environ ["PR_NUMBER" ]
255
+ sha = os .environ ["BRANCH_SHA" ]
248
256
log_file = os .environ ["LOG_FILE" ]
249
257
run_id = os .environ ["RUN_ID" ]
250
258
@@ -261,7 +269,14 @@ def create_or_update_comment(comment, message, repo, pr_number, token):
261
269
exit (0 )
262
270
263
271
try :
264
- message = get_message (log_file , repo = repo , run_id = run_id , details = True )
272
+ message = get_message (
273
+ log_file ,
274
+ repo = repo ,
275
+ pr_number = pr_number ,
276
+ sha = sha ,
277
+ run_id = run_id ,
278
+ details = True ,
279
+ )
265
280
create_or_update_comment (
266
281
comment = comment ,
267
282
message = message ,
@@ -273,7 +288,14 @@ def create_or_update_comment(comment, message, repo, pr_number, token):
273
288
except requests .HTTPError :
274
289
# The above fails if the message is too long. In that case, we
275
290
# try again without the details.
276
- message = get_message (log_file , repo = repo , run_id = run_id , details = False )
291
+ message = get_message (
292
+ log_file ,
293
+ repo = repo ,
294
+ pr_number = pr_number ,
295
+ sha = sha ,
296
+ run_id = run_id ,
297
+ details = False ,
298
+ )
277
299
create_or_update_comment (
278
300
comment = comment ,
279
301
message = message ,
0 commit comments