[pw-ci] [PATCH 2/3] Finish introducing ci_instance to git_builds

Michael Santana msantana at redhat.com
Tue Aug 10 21:33:53 UTC 2021


With this patch CI infrastructures can share the same git_builds table

Signed-off-by: Michael Santana <msantana at redhat.com>
---
 ci_mon           |  4 ++--
 github_mon       |  7 ++++---
 series_db_lib.sh | 13 +++++++++----
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/ci_mon b/ci_mon
index 40b6432..a5207f6 100755
--- a/ci_mon
+++ b/ci_mon
@@ -149,7 +149,7 @@ for I in travis github dummy; do
     fi
 
     ./${I}_mon $pw_instance ${!token} "$pw_project" | grep "^pw|" | while IFS="|" \
-        read -r PW pw_chk_instance BUILD series_id SHA shasum result build_url series_name repo_name test_name; do
+        read -r PW pw_chk_instance BUILD series_id SHA shasum result build_url series_name repo_name test_name ci_instance; do
 
         SERIES_LINE=$(./series_get $pw_instance $series_id)
         sid=$(echo $SERIES_LINE | cut -d\| -f1)
@@ -160,7 +160,7 @@ for I in travis github dummy; do
 
         PATCHDATA=$(curl -s $url)
 
-        patch_id="$(get_patch_id_by_series_id_and_sha "$series_id" "$shasum" "$pw_chk_instance")"
+        patch_id="$(get_patch_id_by_series_id_and_sha "$series_id" "$shasum" "$pw_chk_instance" "$ci_instance")"
         if [ "X$patch_id" == "X" ]; then
             patch_id=$(echo $PATCHDATA | jq -rc '.patches[-1].id')
         fi
diff --git a/github_mon b/github_mon
index 6ee604a..814ba97 100755
--- a/github_mon
+++ b/github_mon
@@ -48,6 +48,7 @@ fi
 AUTH="Authorization: token ${github_token}"
 APP="Accept: application/vnd.github.v3+json"
 GITHUB_API="https://api.github.com"
+ci_instance="github_actions_ci"
 
 make_result_for_series () {
 
@@ -91,15 +92,15 @@ make_result_for_series () {
 
         test_name=$WORKFLOWNAME
 
-        echo "pw|$pw_instance|build|$series_id|SHA|$sha|$result|$build_url|$patch_name|$repo_name|$test_name"
+        echo "pw|$pw_instance|build|$series_id|SHA|$sha|$result|$build_url|$patch_name|$repo_name|$test_name|$ci_instance"
     done
 
-    set_synced_patch "$patch_id" "$pw_instance"
+    set_synced_patch "$patch_id" "$pw_instance" "$repo_name"
 }
 
 prev_series=""
 
-get_unsynced_series "$pw_instance" | \
+get_unsynced_series "$pw_instance" "$ci_instance" | \
 while IFS="|" read -r series_id patch_id patch_url patch_name sha patchwork_instance patchwork_project repo_name gap_sync; do
 
     if [ "X$pw_project" != "X" -a "X$pw_project" != "X$patchwork_project" ]; then
diff --git a/series_db_lib.sh b/series_db_lib.sh
index d65a5ba..8ef9b2f 100644
--- a/series_db_lib.sh
+++ b/series_db_lib.sh
@@ -339,28 +339,31 @@ function patch_id_by_sha() {
 
 function get_unsynced_series() {
     local instance="$1"
+    local ci_instance="$2"
 
     series_db_exists
 
-    echo "select * from git_builds where patchwork_instance=\"$instance\" and gap_sync=0 order by series_id;" | series_db_execute
+    echo "select * from git_builds where patchwork_instance=\"$instance\" and gap_sync=0 and ci_instance=\"$ci_instance\" order by series_id;" | series_db_execute
 }
 
 function set_synced_patch() {
     local patch_id="$1"
     local instance="$2"
+    local ci_instance="$3"
 
     series_db_exists
 
-    echo "update git_builds set gap_sync=1 where patchwork_instance=\"$instance\" and patch_id=$patch_id;" | series_db_execute
+    echo "update git_builds set gap_sync=1 where patchwork_instance=\"$instance\" and patch_id=$patch_id and ci_instance=\"$ci_instance\";" | series_db_execute
 }
 
 function set_synced_for_series() {
     local series_id="$1"
     local instance="$2"
+    local ci_instance="$3"
 
     series_db_exists
 
-    echo "update git_builds set gap_sync=1 where patchwork_instance=\"$instance\" and series_id=$series_id;" | series_db_execute
+    echo "update git_builds set gap_sync=1 where patchwork_instance=\"$instance\" and series_id=$series_id and ci_instance=\"$ci_instance\";" | series_db_execute
 }
 
 function insert_commit() {
@@ -372,6 +375,7 @@ function insert_commit() {
     local instance="$6"
     local project="$7"
     local repo_name="$8"
+    local ci_instance="$9"
 
     series_db_exists
 
@@ -382,8 +386,9 @@ function get_patch_id_by_series_id_and_sha() {
     local series_id="$1"
     local sha="$2"
     local instance="$3"
+    local ci_instance="$4"
 
     series_db_exists
 
-    echo "select patch_id from git_builds where patchwork_instance=\"$instance\" and series_id=$series_id and sha=\"$sha\";" | series_db_execute
+    echo "select patch_id from git_builds where patchwork_instance=\"$instance\" and series_id=$series_id and sha=\"$sha\" and ci_instance=\"$ci_instance\";" | series_db_execute
 }
-- 
2.31.1



More information about the Pwci mailing list