Skip to content
Snippets Groups Projects

test-generic.yaml: Utilize SQUAD API in CI jobs

Merged Stevan Radaković requested to merge sradakovi/oniro:squad-build-id into kirkstone
1 file
+ 7
8
Compare changes
  • Side-by-side
  • Inline
@@ -45,8 +45,7 @@
@@ -45,8 +45,7 @@
-e 's/@ci_project_id@/'"$CI_PROJECT_ID"'/'
-e 's/@ci_project_id@/'"$CI_PROJECT_ID"'/'
-e 's/@ci_pipeline_id@/'"$CI_PIPELINE_ID"'/'
-e 's/@ci_pipeline_id@/'"$CI_PIPELINE_ID"'/'
-e 's,@ci_pipeline_url@,'"$CI_PIPELINE_URL"','
-e 's,@ci_pipeline_url@,'"$CI_PIPELINE_URL"','
-e 's/@build_job_id@/'"$build_job_id"'/'
-e 's/@build_job_id@/'"$build_job_id"'/' job_def.yaml
-e 's,@callback_url@,'"$CALLBACK_URL"',' job_def.yaml
# Generate test jobs.
# Generate test jobs.
- |
- |
set -x
set -x
@@ -72,8 +71,10 @@
@@ -72,8 +71,10 @@
# Submit the jobs to SQUAD.
# Submit the jobs to SQUAD.
- |
- |
for job_def in $(find lava_jobs/ -name "*.yaml"); do
for job_def in $(find lava_jobs/ -name "*.yaml"); do
echo $CI_SQUAD_INSTANCE/api/submitjob/oniro-core/$CI_PROJECT_NAME/$CI_COMMIT_SHORT_SHA/$MACHINE --header "Auth-Token: $CI_SQUAD_TOKEN" --form "backend=oniro_lava" --form "definition=@${job_def}"
echo $CI_SQUAD_INSTANCE/api/submitjob/oniro-core/$CI_PROJECT_NAME/$CI_PIPELINE_ID/$MACHINE --header "Auth-Token: $CI_SQUAD_TOKEN" --form "backend=oniro_lava" --form "definition=@${job_def}"
curl $CI_SQUAD_INSTANCE/api/submitjob/oniro-core/$CI_PROJECT_NAME/$CI_COMMIT_SHORT_SHA/$MACHINE --header "Auth-Token: $CI_SQUAD_TOKEN" --form "backend=oniro_lava" --form "definition=@${job_def}"
curl $CI_SQUAD_INSTANCE/api/submitjob/oniro-core/$CI_PROJECT_NAME/$CI_PIPELINE_ID/$MACHINE --header "Auth-Token: $CI_SQUAD_TOKEN" --form "backend=oniro_lava" --form "definition=@${job_def}"
 
# Attach a callback to this build to trigger the lava-report job
 
curl -X POST /api/build/$CI_PIPELINE_ID/callbacks/ -F "callback_url=$CALLBACK_URL"
done
done
artifacts:
artifacts:
paths:
paths:
@@ -137,10 +138,8 @@
@@ -137,10 +138,8 @@
script:
script:
- |
- |
set -x
set -x
curl --silent "$CI_API_V4_URL/projects/$CI_PROJECT_ID/pipelines/$CI_PIPELINE_ID/test_report" > test-report.json
pass_percentage="$(curl --silent https://squadp.svc.ostc-eu.dev/api/builds/$build_id/status/ | jq -r '.pass_percentage')"
total_count="$(jq '.total_count' test-report.json)"
success_rate=`printf "%.2f" $pass_percentage`
success_count="$(jq '.success_count' test-report.json)"
success_rate=$(( 100 * success_count / total_count ))
anybadge --label=lava-test --value=${success_rate} --suffix='%' --file=lava-test.svg 50=red 60=orange 80=yellow 100=green
anybadge --label=lava-test --value=${success_rate} --suffix='%' --file=lava-test.svg 50=red 60=orange 80=yellow 100=green
set +x
set +x
artifacts:
artifacts:
Loading