Skip to content

Commit

Permalink
fix cornercase in which the artifacts of a job contains the results o…
Browse files Browse the repository at this point in the history
…f another validation package. Seems to depends on the runner's config?
  • Loading branch information
j-bauer committed Jul 5, 2024
1 parent 290549a commit 36848c7
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions misc/datahub-hooks.bash
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# be printed as part of the commands within the logfile.
# Be careful who you send this log to avoid credentials leaks!


# TODO: idea wrap the curl request to use the standard options
authenticated_request() {
:
Expand Down Expand Up @@ -203,21 +202,32 @@ if [ "$event_type" = "pipeline" ]; then
exit 1
fi

job_ids=($(jq -r '.builds[] | select(.stage=="'"${arc_validation_stage_name}"'") | .id // empty' <<< "$json"))
if [ "${#job_ids[@]}" = 0 ]; then
echo "Failed to find job ids."
exit 1
fi

# prepare the commit json body
commit_payload='
{
"branch": "'"$arc_quality_control_branch_name"'",
"commit_message": "Results for commit: '$commit_id'",
"actions": []
}'

for job_id in ${job_ids[@]}; do

# parse the job names and their ids
declare -A ci_jobs
jq -r '.builds[] | select(.stage=="'"${arc_validation_stage_name}"'") | "\(.name) \(.id)"' <<< "$json"
while read -r line; do
read -r job_name job_id _ <<< "$line"
echo "NAME: $job_name"
echo "ID: $job_id"
ci_jobs["${job_name#validate-}"]="$job_id"
declare -p ci_jobs
done < <(jq -r '.builds[] | select(.stage=="'"${arc_validation_stage_name}"'") | "\(.name) \(.id)"' <<< "$json")

if [ "${#ci_jobs[@]}" = 0 ]; then
echo "Failed to find jobs."
exit 1
fi

for job_name in "${!ci_jobs[@]}"; do
job_id="${ci_jobs["$job_name"]}"
tmp_dir="$(mktemp -d)"
cd "$tmp_dir"
echo "Fetching job (${job_id}) artifacts for project ${project_id}..."
Expand All @@ -237,8 +247,12 @@ if [ "$event_type" = "pipeline" ]; then

# detect the name of the validation package through the result folder
# it should be: <branch>/<package>@<version>
validation_package_results_folder="$(find * -mindepth 1 -type d)"
validation_package_results_folder="$(find * -mindepth 1 -type d -name "*$job_name*")"
echo "Results: $validation_package_results_folder"
if [ ! -d "$validation_package_results_folder" ]; then
echo "Failed to find package result directory of $job_name..."
continue
fi

# we want to upload all the files created by the validation package
# in the quality control branch.
Expand Down

0 comments on commit 36848c7

Please sign in to comment.