[pw-ci] [PATCH 1/2] Prepare to introduce OBS CI

Michael Santana msantana at redhat.com
Wed Aug 25 00:12:48 UTC 2021


This patch adds a new column, obs_sync, to determine if an entry in the
git_builds table was synced in patchwork with OBS build status

As part of adding this new table the series_db_lib.sh had to be modified
to let CI scripts specify which column is for their CI

github_mon was also updated to conform to the new usage

Signed-off-by: Michael Santana <msantana at redhat.com>
---
 github_mon       |  5 +++--
 series_db_lib.sh | 21 +++++++++++++++++----
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/github_mon b/github_mon
index 6ee604a..42478be 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="gap_sync"
 
 make_result_for_series () {
 
@@ -94,12 +95,12 @@ make_result_for_series () {
         echo "pw|$pw_instance|build|$series_id|SHA|$sha|$result|$build_url|$patch_name|$repo_name|$test_name"
     done
 
-    set_synced_patch "$patch_id" "$pw_instance"
+    set_synced_patch "$patch_id" "$pw_instance" "$ci_instance"
 }
 
 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 c511c36..07a2075 100644
--- a/series_db_lib.sh
+++ b/series_db_lib.sh
@@ -104,6 +104,16 @@ gap_sync INTEGER);
 EOF
         run_db_command "INSERT INTO series_schema_version(id) values (6);"
     fi
+
+    # 0007 - patch data for Open Build Service and Patchwork sync
+    run_db_command "select * from series_schema_version;" | egrep '^7$' >/dev/null 2>&1
+    if [ $? -eq 1 ]; then
+        sqlite3 ${HOME}/.series-db <<EOF
+ALTER TABLE git_builds ADD COLUMN obs_sync INTEGER;
+EOF
+        run_db_command "INSERT INTO series_schema_version(id) values (7);"
+    fi
+
 }
 
 function series_db_exists() {
@@ -329,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 $ci_instance=0 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 $ci_instance=1 where patchwork_instance=\"$instance\" and patch_id=$patch_id;" | 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, obs_sync=1 where patchwork_instance=\"$instance\" and series_id=$series_id;" | series_db_execute
 }
 
 function insert_commit() {
@@ -365,7 +378,7 @@ function insert_commit() {
 
     series_db_exists
 
-    echo "INSERT INTO git_builds (series_id, patch_id, patch_url, patch_name, sha, patchwork_instance, patchwork_project, repo_name, gap_sync) VALUES($series_id, $patch_id, \"$patch_url\", \"$patch_name\", \"$sha\", \"$instance\", \"$project\", \"$repo_name\", 0);" | series_db_execute
+    echo "INSERT INTO git_builds (series_id, patch_id, patch_url, patch_name, sha, patchwork_instance, patchwork_project, repo_name, gap_sync, obs_sync) VALUES($series_id, $patch_id, \"$patch_url\", \"$patch_name\", \"$sha\", \"$instance\", \"$project\", \"$repo_name\", 0, 0);" | series_db_execute
 }
 
 function get_patch_id_by_series_id_and_sha() {
-- 
2.31.1



More information about the Pwci mailing list