File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
misc/scripts/library-coverage Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -99,10 +99,16 @@ jobs:
99
99
path : pr/
100
100
- name : Save comment ID (if it exists)
101
101
run : |
102
- mkdir -p comment
103
102
# Find the latest comment starting with COMMENT_PREFIX
104
103
COMMENT_PREFIX=":warning: The head of this PR and the base branch were compared for differences in the framework coverage reports."
105
- gh api "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" --paginate | jq --arg prefix "${COMMENT_PREFIX}" '[.[] | select(.body|startswith($prefix)) | .id] | max' > comment/ID
104
+ COMMENT_ID=$(gh api "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" --paginate | jq --arg prefix "${COMMENT_PREFIX}" 'map(select(.body|startswith($prefix)) | .id) | max // empty')
105
+ if [[ -z ${COMMENT_ID} ]]
106
+ then
107
+ echo "Comment not found. Not uploading 'comment/ID' artifact."
108
+ else
109
+ mkdir -p comment
110
+ echo ${COMMENT_ID} > comment/ID
111
+ fi
106
112
env :
107
113
GITHUB_TOKEN : ${{ github.token }}
108
114
PR_NUMBER : ${{ github.event.pull_request.number }}
@@ -111,3 +117,4 @@ jobs:
111
117
with :
112
118
name : comment
113
119
path : comment/
120
+ if-no-files-found : ignore
Original file line number Diff line number Diff line change @@ -56,14 +56,13 @@ def comment_pr(repo, run_id):
56
56
if os .path .isdir ("pr" ):
57
57
shutil .rmtree ("pr" )
58
58
59
- utils .download_artifact (repo , "comment" , "comment" , run_id )
60
-
61
59
try :
60
+ utils .download_artifact (repo , "comment" , "comment" , run_id )
62
61
with open ("comment/ID" ) as file :
63
62
raw_comment_id = int (file .read ())
64
63
except Exception as e :
65
- # If there is no existing comment, comment/ID will contain just a
66
- # newline (due to jq & gh behaviour) . This will cause `int(file.read()) `
64
+ # If there is no existing comment, the ` comment/ID` artifact
65
+ # will not exist . This will cause `utils.download_artifact `
67
66
# to fail, so we catch that and set `raw_comment_id` to `None`.
68
67
print ("Could not retrieve an existing comment ID. \n " , e )
69
68
raw_comment_id = None
You can’t perform that action at this time.
0 commit comments