Skip to content

Commit 30ed3d5

Browse files
authored
fix: remove debug statement when calling gh api (#7889)
Remove a debug statement from the CallGitHubApi function to avoid that it adds stuff to theh function output on successful calls when debug logging is enabled.
1 parent cd79eea commit 30ed3d5

1 file changed

Lines changed: 18 additions & 12 deletions

File tree

‎lib/functions/output.sh‎

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,10 @@ CallGitHubApi() {
138138
local INCLUDE_RESPONSE_HEADERS="${1:-false}"
139139

140140
if [[ -z "${GITHUB_TOKEN:-}" ]]; then
141-
warn "Provide a GitHub token to call the GitHub API: ${GITHUB_URL}"
141+
error "Provide a GitHub token to call the GitHub API: ${GITHUB_URL}"
142142
return 1
143143
fi
144144

145-
debug "Calling GitHub API (${GITHUB_URL}) with method: ${HTTP_METHOD}, payload: ${PAYLOAD}"
146-
147145
local CURL_ARGS=(
148146
--fail
149147
--location
@@ -167,7 +165,7 @@ CallGitHubApi() {
167165

168166
local CALL_GITHUB_API_OUT
169167
if ! CALL_GITHUB_API_OUT=$(curl "${CURL_ARGS[@]}" 2>&1); then
170-
warn "Failed to call GitHub API (${GITHUB_URL}) with ${HTTP_METHOD} HTTP method: ${CALL_GITHUB_API_OUT}"
168+
error "Failed to call GitHub API (${GITHUB_URL}) with ${HTTP_METHOD} HTTP method: ${CALL_GITHUB_API_OUT}"
171169
return 1
172170
fi
173171
echo "${CALL_GITHUB_API_OUT}"
@@ -198,6 +196,7 @@ CreateGitHubCommitStatus() {
198196
\"context\": \"--> Linted: ${LANGUAGE}\"
199197
}"
200198

199+
debug "Calling GitHub API (${GITHUB_STATUS_URL}), payload: ${GITHUB_STATUS_API_PAYLOAD}"
201200
if ! CallGitHubApi "${GITHUB_STATUS_URL}" "${GITHUB_TOKEN}" "${GITHUB_STATUS_API_PAYLOAD}"; then
202201
warn "Failed to create GitHub Commit Status"
203202
return 1
@@ -221,6 +220,7 @@ CreateGitHubIssueComment() {
221220

222221
debug "Creating GitHub issue comment (URL: ${GITHUB_ISSUE_COMMENT_URL}). GITHUB_ISSUE_NUMBER: ${GITHUB_ISSUE_NUMBER}, payload: ${CREATE_ISSUE_COMMENT_API_PAYLOAD}"
223222

223+
debug "Calling GitHub API (${GITHUB_ISSUE_COMMENT_URL}), payload: ${CREATE_ISSUE_COMMENT_API_PAYLOAD}"
224224
if ! CallGitHubApi "${GITHUB_ISSUE_COMMENT_URL}" "${GITHUB_TOKEN}" "${CREATE_ISSUE_COMMENT_API_PAYLOAD}"; then
225225
warn "Failed to create GitHub issue comment"
226226
return 1
@@ -245,7 +245,10 @@ FindExistingSummaryComment() {
245245
local NEXT_URL="${GITHUB_ISSUE_COMMENTS_URL}?per_page=100"
246246
while [[ -n "${NEXT_URL}" ]]; do
247247
local CALL_GITHUB_API_OUT
248-
if ! CALL_GITHUB_API_OUT="$(CallGitHubApi "${NEXT_URL}" "${GITHUB_TOKEN}" "" "GET" "true")"; then
248+
local GITHUB_API_HTTP_METHOD
249+
GITHUB_API_HTTP_METHOD="GET"
250+
if ! CALL_GITHUB_API_OUT="$(CallGitHubApi "${NEXT_URL}" "${GITHUB_TOKEN}" "" "${GITHUB_API_HTTP_METHOD}" "true")"; then
251+
debug "Calling GitHub API (${NEXT_URL}), HTTP method: ${GITHUB_API_HTTP_METHOD}"
249252
error "Failed to list comments for issue #${GITHUB_ISSUE_NUMBER}: ${CALL_GITHUB_API_OUT}"
250253
return 1
251254
fi
@@ -314,7 +317,10 @@ UpdateGitHubIssueComment() {
314317
GITHUB_ISSUE_COMMENT_URL="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/issues/comments/${COMMENT_ID}"
315318
debug "Updating GitHub issue comment (URL: ${GITHUB_ISSUE_COMMENT_URL}). COMMENT_ID: ${COMMENT_ID}"
316319

317-
if ! CallGitHubApi "${GITHUB_ISSUE_COMMENT_URL}" "${GITHUB_TOKEN}" "${UPDATE_ISSUE_COMMENT_API_PAYLOAD}" "PATCH"; then
320+
local GITHUB_API_HTTP_METHOD
321+
GITHUB_API_HTTP_METHOD="PATCH"
322+
debug "Calling GitHub API (${GITHUB_ISSUE_COMMENT_URL}), HTTP method: ${GITHUB_API_HTTP_METHOD}, payload: ${UPDATE_ISSUE_COMMENT_API_PAYLOAD}"
323+
if ! CallGitHubApi "${GITHUB_ISSUE_COMMENT_URL}" "${GITHUB_TOKEN}" "${UPDATE_ISSUE_COMMENT_API_PAYLOAD}" "${GITHUB_API_HTTP_METHOD}"; then
318324
warn "Failed to update GitHub issue comment"
319325
return 1
320326
fi
@@ -328,7 +334,7 @@ CreateGitHubPullRequestSummaryComment() {
328334

329335
local SUMMARY_COMMENT_BODY
330336
if ! SUMMARY_COMMENT_BODY="$(<"${SUPER_LINTER_SUMMARY_OUTPUT_PATH}")"; then
331-
warn "Error while loading the contents of COMMENT_PAYLOAD to SUMMARY_COMMENT_BODY"
337+
error "Error while loading the contents of COMMENT_PAYLOAD to SUMMARY_COMMENT_BODY: ${SUMMARY_COMMENT_BODY}"
332338
return 1
333339
fi
334340

@@ -341,9 +347,9 @@ ${SUMMARY_COMMENT_BODY}"
341347
local SUPER_LINTER_EXISTING_SUMMARY_COMMENT_ID
342348
debug "Listing comments for issue #${GITHUB_PULL_REQUEST_NUMBER} to find existing summary comment"
343349
if ! SUPER_LINTER_EXISTING_SUMMARY_COMMENT_ID="$(FindExistingSummaryComment "${GITHUB_PULL_REQUEST_NUMBER}")"; then
344-
warn "Error while looking up existing summary comment, falling back to creating a new one"
350+
error "Error while looking up existing summary comment, falling back to creating a new one"
345351
if ! CreateGitHubIssueComment "${SUMMARY_COMMENT_BODY}" "${GITHUB_PULL_REQUEST_NUMBER}"; then
346-
warn "Error while posting pull request summary"
352+
error "Error while posting pull request summary"
347353
return 1
348354
fi
349355
return 0
@@ -352,20 +358,20 @@ ${SUMMARY_COMMENT_BODY}"
352358
if [[ -n "${SUPER_LINTER_EXISTING_SUMMARY_COMMENT_ID:-}" ]]; then
353359
debug "Updating existing summary comment (ID: ${SUPER_LINTER_EXISTING_SUMMARY_COMMENT_ID}) on PR #${GITHUB_PULL_REQUEST_NUMBER}"
354360
if ! UpdateGitHubIssueComment "${SUMMARY_COMMENT_BODY}" "${SUPER_LINTER_EXISTING_SUMMARY_COMMENT_ID}"; then
355-
warn "Error while updating pull request summary comment"
361+
error "Error while updating pull request summary comment"
356362
return 1
357363
fi
358364
else
359365
debug "No existing summary comment found, creating a new one"
360366
if ! CreateGitHubIssueComment "${SUMMARY_COMMENT_BODY}" "${GITHUB_PULL_REQUEST_NUMBER}"; then
361-
warn "Error while posting pull request summary"
367+
error "Error while posting pull request summary"
362368
return 1
363369
fi
364370
fi
365371
else
366372
debug "UPDATE_EXISTING_GITHUB_PULL_REQUEST_SUMMARY_COMMENT is false, creating a new comment"
367373
if ! CreateGitHubIssueComment "${SUMMARY_COMMENT_BODY}" "${GITHUB_PULL_REQUEST_NUMBER}"; then
368-
warn "Error while posting pull request summary"
374+
error "Error while posting pull request summary"
369375
return 1
370376
fi
371377
fi

0 commit comments

Comments
 (0)