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:
9999 path : pr/
100100 - name : Save comment ID (if it exists)
101101 run : |
102- mkdir -p comment
103102 # Find the latest comment starting with COMMENT_PREFIX
104103 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
106112 env :
107113 GITHUB_TOKEN : ${{ github.token }}
108114 PR_NUMBER : ${{ github.event.pull_request.number }}
@@ -111,3 +117,4 @@ jobs:
111117 with :
112118 name : comment
113119 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):
5656 if os .path .isdir ("pr" ):
5757 shutil .rmtree ("pr" )
5858
59- utils .download_artifact (repo , "comment" , "comment" , run_id )
60-
6159 try :
60+ utils .download_artifact (repo , "comment" , "comment" , run_id )
6261 with open ("comment/ID" ) as file :
6362 raw_comment_id = int (file .read ())
6463 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 `
6766 # to fail, so we catch that and set `raw_comment_id` to `None`.
6867 print ("Could not retrieve an existing comment ID. \n " , e )
6968 raw_comment_id = None
You can’t perform that action at this time.
0 commit comments