Skip to content

Commit 75c2384

Browse files
committed
Svace improvements (#38)
Signed-off-by: Maksim Khimchenko <[email protected]> (cherry picked from commit 454451d)
1 parent b88e93d commit 75c2384

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

svace_analyze/action.yml

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,17 @@ runs:
227227
--form options='{\"values\":[ \
228228
{\"option\":\"project-group\",\"value\":\"${PROJECT_GROUP}\"}, \
229229
{\"option\":\"if-no-group\",\"value\":\"${IF_NO_GROUP}\"}, \
230-
{\"option\":\"field\",\"value\":\"CI_COMMIT_HASH:${CI_COMMIT_HASH}\"} \
230+
{\"option\":\"field\",\"value\":\"CI_COMMIT_HASH:${CI_COMMIT_HASH}\"}, \
231+
{\"option\":\"field\",\"value\":\"CI_COMMIT_REF_NAME:${CI_COMMIT_REF_NAME}\"} \
231232
]}'"
232233
233234
info "Importing \"${project_name}\"..."
234235
response=$(send_request "${svacer_import}" $request_attempts)
235236
read import_task_id import_task_status <<< $(jq -r '(.task_id|tostring)+" "+.status' <<< ${response})
237+
if [[ -z "${import_task_id}" ]]; then
238+
error "Import task failed. Response: ${response}"
239+
exit 1
240+
fi
236241
info "Import task scheduled succesfully. Task id: ${import_task_id}"
237242
238243
get_import_log="curl --write-out \"\\n%{http_code}\" -sSL --request GET \
@@ -268,6 +273,27 @@ runs:
268273
fi
269274
}
270275
276+
define_import_params() {
277+
local -n project="${1}"
278+
local -n branch="${2}"
279+
if [[ $(send "[[ -f ${proj}/.svace-dir/import-settings ]] && echo true || echo false") == true ]]; then
280+
import_settings=$(send "cat /${proj}/.svace-dir/import-settings")
281+
while IFS='=' read -r key val; do
282+
case "$key" in
283+
ProjectName)
284+
project=$val
285+
;;
286+
Branch)
287+
branch=$val
288+
;;
289+
*)
290+
warning "Undefined import setting \"${key}=${val}\" will be ommited!"
291+
;;
292+
esac
293+
done <<< "${import_settings}"
294+
fi
295+
}
296+
271297
if [[ $(send "[[ -d /${SVACE_ANALYZE_DIR}/${CI_COMMIT_HASH} ]] && echo true || echo false") == false ]]; then
272298
echo "::warning file=$(realpath "$0")::Specified commit directory doesn't exists on analyze server." && exit 0
273299
fi
@@ -281,7 +307,12 @@ runs:
281307
svacer_proj=${proj#/${SVACE_ANALYZE_DIR}/${CI_COMMIT_HASH}/}
282308
build_item=${svacer_proj##*/}
283309
310+
import_project=${svacer_proj}
311+
import_branch=${CI_COMMIT_REF_NAME}
312+
284313
if [[ $(send "[[ -d ${proj}/.svace-dir ]] && echo true || echo false") == true ]]; then
314+
define_import_params import_project import_branch
315+
285316
info "Start analyzing project \"${svacer_proj}\" ..."
286317
send "svace config --svace-dir ${proj} THREAD_NUMBER auto"
287318
send "svace analyze --set-config SKIP_UNREACHABLE_PROCEDURE_ANALYSIS=${SKIP_UNREACHABLE_PROCEDURE_ANALYSIS} --quiet --svace-dir ${proj}"
@@ -295,8 +326,8 @@ runs:
295326
fi
296327
297328
if [[ $(send "[[ -f ${proj}/${build_item}.tar.gz ]] && echo true || echo false") == true ]]; then
298-
info "Start importing project \"${svacer_proj}\" ..."
299-
upload_to_svacer "${svacer_proj}" "${CI_COMMIT_REF_NAME}" "${proj}/${build_item}.tar.gz"
329+
info "Start importing project \"${import_project}\" with branch \"${import_branch}\" ..."
330+
upload_to_svacer "${import_project}" "${import_branch}" "${proj}/${build_item}.tar.gz"
300331
success "Import completed successfuly!"
301332
else
302333
warning "Nothing to import! Couldn't find \"${build_item}.tar.gz\" in \"${proj}\""

0 commit comments

Comments
 (0)