Debian Codegraph @

automation/eclair_analysis/ECLAIR/action.settings

raw
1 variantSubDir=
2 variantHeadline=
3 if [ -n "${VARIANT:-}" ]; then
4 variantSubDir="/${VARIANT}"
5 variantHeadline=" [${VARIANT}]"
6 fi
7
8 # AUTO PR Feature
9 # If the following variables are defined, then all pipelines
10 # of other branches will be considered pull-requests to
11 # autoPRBranch.
12 # Customized
13 autoPRRepository="${AUTO_PR_REPOSITORY:-}"
14 # Customized
15 autoPRBranch="${AUTO_PR_BRANCH:-}"
16
17 case "${ci}" in
18 github)
19 # To be customized
20 repository="${GITHUB_REPOSITORY}"
21 jobId="${GITHUB_RUN_NUMBER}"
22
23 autoPRRemoteUrl="${GITHUB_SERVER_URL}/${autoPRRepository:-}.git"
24
25 case "${GITHUB_EVENT_NAME}" in
26 pull_request*)
27 event=pull_request
28 pullRequestId="${GITHUB_EVENT_PULL_REQUEST_NUMBER}"
29 pullRequestHeadRepo="${PR_HEAD_REPO}"
30 pullRequestHeadRef="${PR_HEAD_REF}"
31 pullRequestBaseRef="${PR_BASE_REF}"
32 pullRequestUser="${PR_USER}"
33 # baseCommitId and headCommitId are the most recent merge points without conflicts
34 git fetch -q --deepen=2
35 baseCommitId=$(git show -s --pretty=%H HEAD^1)
36 headCommitId=$(git show -s --pretty=%H HEAD^2)
37 ;;
38 push | workflow_dispatch)
39 event=push
40 # Extract the branch name from "refs/heads/<branch>"
41 ref="${GITHUB_REF#refs/heads/}"
42 headCommitId="${GITHUB_SHA}"
43 pushUser="${GITHUB_ACTOR}"
44 ;;
45 *)
46 echo "Unexpected GITHUB_REF ${GITHUB_REF}" >&2
47 exit 1
48 ;;
49 esac
50 ;;
51 gitlab)
52 # Customized
53 repository="${CI_PROJECT_PATH}"
54 jobId="${CI_JOB_ID}"
55
56 gitlabApiUrl="${CI_SERVER_PROTOCOL}://${CI_SERVER_HOST}:${CI_SERVER_PORT}/api/v4"
57 autoPRRemoteUrl="${CI_SERVER_PROTOCOL}://${CI_SERVER_HOST}:${CI_SERVER_PORT}/${autoPRRepository:-}.git"
58
59 # Customized
60 gitlabBotToken="${ECLAIR_BOT_TOKEN:-}"
61
62 case "${CI_PIPELINE_SOURCE}" in
63 merge_request_event)
64 event=pull_request
65 pullRequestId="${CI_MERGE_REQUEST_IID}"
66 pullRequestHeadRef="${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}"
67 pullRequestHeadRepo="${CI_MERGE_REQUEST_SOURCE_PROJECT_PATH}"
68 pullRequestBaseRef="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}"
69 pullRequestUser="${GITLAB_USER_LOGIN}"
70 headCommitId="${CI_COMMIT_SHA}"
71 baseCommitId="${CI_MERGE_REQUEST_DIFF_BASE_SHA}"
72 ;;
73 push | pipeline | web | schedule)
74 event=push
75 if [ -n "${CI_COMMIT_BRANCH:-}" ]; then
76 ref_kind=branch
77 ref="${CI_COMMIT_BRANCH}"
78 else
79 ref_kind=tag
80 ref="${CI_COMMIT_TAG}"
81 fi
82 headCommitId="${CI_COMMIT_SHA}"
83 pushUser="${GITLAB_USER_NAME}"
84 ;;
85 *)
86 echo "Unexpected event ${CI_PIPELINE_SOURCE}" >&2
87 exit 1
88 ;;
89 esac
90 ;;
91 jenkins)
92 # To be customized
93 repository="${JOB_BASE_NAME}"
94 project="${JOB_NAME}"
95 jobId="${BUILD_NUMBER}"
96
97 jenkinsApiUrl="${JENKINS_URL}"
98 autoPRRemoteUrl="${JENKINS_URL}/${autoPRRepository:-}.git"
99
100 # To be customized
101 jenkinsBotUsername="${ECLAIR_BOT_USERNAME:-}"
102 jenkinsBotToken="${ECLAIR_BOT_TOKEN:-}"
103
104 event=push
105 ref="${GIT_BRANCH}"
106 headCommitId="${GIT_COMMIT}"
107 pushUser=$(git show --pretty='format:%aN' -s)
108 ;;
109 *)
110 echo "Unexpected CI/CD context" >&2
111 exit 1
112 ;;
113 esac
114
115 if [ "${event}" = "push" ] && [ -n "${autoPRBranch:-}" ]; then
116 # AUTO PR Feature enabled
117 if ! [ "${ref}" = "${autoPRBranch}" ] ||
118 ! [ "${repository}" = "${autoPRRepository}" ]; then
119 event=auto_pull_request
120 fi
121 fi
122
123 case "${event}" in
124 pull_request)
125 subDir="${pullRequestHeadRepo}.ecdf/${pullRequestBaseRef}"
126 jobHeadline="ECLAIR ${ANALYSIS_KIND} on repository ${repository}: ${pullRequestUser} wants to merge ${pullRequestHeadRepo}:${pullRequestHeadRef} (${headCommitId}) into ${pullRequestBaseRef} (${baseCommitId})"
127 ;;
128 push)
129 subDir="${ref}"
130 jobHeadline="ECLAIR ${ANALYSIS_KIND} on repository ${repository}: ${ref_kind} ${ref} (${headCommitId})"
131 badgeLabel="ECLAIR ${ANALYSIS_KIND} ${ref}${variantHeadline} #${jobId}"
132 ;;
133 auto_pull_request)
134 git remote remove autoPRRemote 2>/dev/null || true
135 git remote add autoPRRemote "${autoPRRemoteUrl}"
136 git fetch -q autoPRRemote
137 subDir="${ref}"
138 if ! baseCommitId=$(git merge-base "autoPRRemote/${autoPRBranch}" HEAD); then
139 baseCommitId=no_merge_point
140 fi
141 jobHeadline="ECLAIR ${ANALYSIS_KIND} on repository ${repository}: ${pushUser} wants to merge ${repository}:${ref} (${headCommitId}) into ${autoPRRepository}/${autoPRBranch} (${baseCommitId})"
142 ;;
143 *)
144 echo "Unexpected event ${event}" >&2
145 exit 1
146 ;;
147 esac
148
149 case "${repository}" in
150 xen-project/xen)
151 # Customized
152 keepOldAnalyses=0
153 ;;
154 xen-project/*)
155 # Customized
156 keepOldAnalyses=10
157 ;;
158 *)
159 echo "Unexpected repository" >&2
160 exit 1
161 ;;
162 esac
163
164 ECLAIR_BIN_DIR=/opt/bugseng/eclair/bin/
165
166 # Artifacts URL served by the eclair_report server
167 if [ -z "${ECLAIR_ECDF_DIR}" ]
168 then
169 echo "WARNING: No ecdf dir supplied, using default"
170 fi
171 artifactsEcdfDir="${ECLAIR_ECDF_DIR:-/var/local/eclair/xen-project.ecdf}"
172 artifactsDir="${artifactsEcdfDir}/${repository}/ECLAIR_${ANALYSIS_KIND}"
173 subDir="${subDir}${variantSubDir}"
174 jobHeadline="${jobHeadline}${variantHeadline}"
175
176 # Remote eclair_report hosting server
177 if [ -z "${ECLAIR_REPORT_HOST}" ]
178 then
179 echo "WARNING: No eclair_report host supplied, using default"
180 fi
181
182 # URL to browse eclair reports
183 if [ -z "${ECLAIR_ANALYSIS_RESULTS}" ]
184 then
185 echo "WARNING: No URL to browse analysis results is set, using default"
186 fi
187
188 eclairReportHost="${ECLAIR_REPORT_HOST:-saas.eclairit.com:3787}"
189 eclairReportUrlPrefix="https://${eclairReportHost}"
190 eclairResultsUrl="${ECLAIR_ANALYSIS_RESULTS:-${eclairReportUrlPrefix}}"
191
192 jobDir="${artifactsDir}/${subDir}/${jobId}"
193 updateLog="${analysisOutputDir}/update.log"
194 cleanRegressionsLog="${analysisOutputDir}/clean_regressions.log"
195 commentLog="${analysisOutputDir}/comment.json"
196 indexHtmlUrl="${eclairResultsUrl}/fs${jobDir}/index.html"
197 summaryTxt="${analysisOutputDir}/summary.txt"