From 2affa98e7f15590670230534e22ac68dcfe3a940 Mon Sep 17 00:00:00 2001
From: Chase Qi <chase.qi@linaro.org>
Date: Tue, 16 Aug 2022 10:51:01 +0800
Subject: [PATCH] ci: migrate gcc test to scheduled-weekly/gcc on squad

Signed-off-by: Chase Qi <chase.qi@linaro.org>
---
 .gitlab-ci.yml               |  4 ++--
 .oniro-ci/build-generic.yaml | 21 +++++++++++++--------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4fb4ec4b..b6e0376f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -793,7 +793,7 @@ oe-selftest-report:
   script:
     - |
       set -x
-      curl https://git.ostc-eu.org/OSTC/infrastructure/lava/lava-test-definitions/-/raw/gcc-test/automated/utils/gcc-result-parser.py \
+      curl https://git.ostc-eu.org/OSTC/infrastructure/lava/lava-test-definitions/-/raw/oniro/automated/utils/gcc-result-parser.py \
         > gcc-result-parser.py
       for job_path in $(find artifacts/ -type d -name oe-selftest-gcc*); do
         (
@@ -812,7 +812,7 @@ oe-selftest-report:
             job_id="$job-$component"
             time curl \
               --header "Auth-Token: $CI_SQUAD_TOKEN" \
-              https://squadp.svc.ostc-eu.dev/api/submit/oniro-core/gcc-test/$CI_PIPELINE_ID/$test_env \
+              https://squadp.svc.ostc-eu.dev/api/submit/scheduled-weekly/gcc/$CI_PIPELINE_ID/$test_env \
               --form tests=@$result_file \
               --form "metadata={\"job_id\": \"$job_id\", \"gcc_version\": \"$gcc_version\"}"
           done
diff --git a/.oniro-ci/build-generic.yaml b/.oniro-ci/build-generic.yaml
index e397e619..90c511a3 100644
--- a/.oniro-ci/build-generic.yaml
+++ b/.oniro-ci/build-generic.yaml
@@ -164,7 +164,7 @@
           | tee -a conf/local.conf )
     # Variables in the form of '^CI_ONIRO_BB_BBLAYERS_CONF_plus_equals_attr' are
     # converted to 'attr += "value"' and appended to bblayers.conf
-    # this is useful if layer has to be added but bitbake add-layer command cannot be used 
+    # this is useful if layer has to be added but bitbake add-layer command cannot be used
     # (for example this layer's class is inherited via local.conf already)
     - |
       ( set +o pipefail;
@@ -499,16 +499,21 @@
     # Only run tests when gcc version changed.
     - gcc_version="$(bitbake -s | grep '^gcc-runtime' | awk -F':' '{print $NF}' | head -1 | awk '{$1=$1;print}')"
     - echo "Current GCC version $gcc_version"
-    - last_build_id="$(curl --silent $CI_SQUAD_INSTANCE/api/projects/5/builds/ | jq -r '.results | .[] | .id' | head -1)"
-    - last_tested_gcc_version="$(curl --silent $CI_SQUAD_INSTANCE/api/builds/$last_build_id/metadata/ | jq -r '.gcc_version')"
-    - echo "The last tested GCC version $last_tested_gcc_version"
+    - last_build_id="$(curl --silent $CI_SQUAD_INSTANCE/api/projects/12/builds/ | jq -r '.results | .[] | .id' | head -1)"
     - |
-      if [ "$gcc_version" != "$last_tested_gcc_version" ]; then
-        echo "GCC verion changed, about to test the new version ..."
+      if [ -n "${last_build_id}" ]; then
+        last_tested_gcc_version="$(curl --silent $CI_SQUAD_INSTANCE/api/builds/$last_build_id/metadata/ | jq -r '.gcc_version')"
+        echo "The last tested GCC version $last_tested_gcc_version"
+        if [ "$gcc_version" != "$last_tested_gcc_version" ]; then
+          echo "GCC verion changed, about to test the new version ..."
+        else
+          echo "GCC verion not changed, skipping gcc tests ..."
+          exit 0
+        fi
       else
-        echo "GCC verion not changed, skipping gcc tests ..."
-        exit 0
+        echo "The last tested GCC version not found, about to run gcc tests ..."
       fi
+    - |
     # oe-selftest inherits the current 'build/conf/local.conf' to create
     # '../build-st/conf/local.conf' for qemu image building. Adding the
     # MACHINE variable to the current local conf allows test job to customize
-- 
GitLab