Debian Codegraph @

automation/eclair_analysis/ECLAIR/action_pull_request.sh

raw symbols SCIP
1 #!/bin/sh
2
3 set -eu
4
5 usage() {
6 echo "Usage: $0 WTOKEN ANALYSIS_OUTPUT_DIR" >&2
7 exit 2
8 }
9
10 [ $# -eq 2 ] || usage
11
12 wtoken=$1
13 analysisOutputDir=$2
14
15 # Load settings and helpers
16 . "$(dirname "$0")/action.helpers"
17 . "$(dirname "$0")/action.settings"
18
19 curl -sS "${eclairReportUrlPrefix}/ext/update_pull_request" \
20 -F "wtoken=${wtoken}" \
21 -F "artifactsDir=${artifactsDir}" \
22 -F "subDir=${subDir}" \
23 -F "jobId=${jobId}" \
24 -F "jobHeadline=${jobHeadline}" \
25 -F "baseCommitId=${baseCommitId}" \
26 -F "keepOldAnalyses=${keepOldAnalyses}" \
27 -F "db=@${analysisOutputDir}/PROJECT.ecd" \
28 >"${updateLog}"
29 ex=0
30 grep -Fq "unfixedReports: " "${updateLog}" || ex=$?
31 maybe_log_file_exit PUBLISH_RESULT "Publishing results" "${updateLog}" "${ex}"
32
33 summary
34
35 if is_enabled "${ENABLE_ECLAIR_BOT:-}"; then
36 case ${ci} in
37 github)
38 ex=0
39 gh api \
40 --method POST \
41 "/repos/${repository}/issues/${pullRequestId}/comments" \
42 -F "body=@${summaryTxt}" \
43 --silent >"${commentLog}" 2>&1 || ex=$?
44 maybe_log_file_exit ADD_COMMENT "Adding comment" "${commentLog}" "${ex}"
45 ;;
46 gitlab)
47 curl -sS --request POST \
48 "${gitlabApiUrl}/projects/${CI_PROJECT_ID}/merge_requests/${pullRequestId}/notes" \
49 -H "PRIVATE-TOKEN: ${gitlabBotToken}" \
50 -F "body=<${summaryTxt}" >"${commentLog}"
51 ex=0
52 grep -Fq "Unfixed reports: " "${commentLog}" || ex=$?
53 maybe_log_file_exit ADD_COMMENT "Adding comment" "${commentLog}" "${ex}"
54 ;;
55 *) ;;
56 esac
57 fi