* [PATCH] cirrus: add an initial polling mechanism
@ 2023-12-12 16:08 Aaron Conole
2024-01-11 18:37 ` Aaron Conole
2024-01-15 20:00 ` Michael Santana
0 siblings, 2 replies; 7+ messages in thread
From: Aaron Conole @ 2023-12-12 16:08 UTC (permalink / raw)
To: ci; +Cc: Eelco Chaudron, Ilya Maximets, Dumitru Ceara, Michael Santana
Cirrus-CI is used to provide a testing environment for FreeBSD, among
others. As of now, the ci monitoring framework doesn't support checking
for cirrus-ci status, but that can be changed. We add an initial polling
similar to the original GitHub Actions or Travis-CI polling mechanisms
that merely provides pass/fail/warn with a URL. This can be improved
later to provide logs on a per-task (similar to GHA Jobs) basis.
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
ci_mon | 6 ++-
cirrus_mon | 100 +++++++++++++++++++++++++++++++++++++++++++++++
series_db_lib.sh | 13 +++++-
3 files changed, 116 insertions(+), 3 deletions(-)
create mode 100755 cirrus_mon
diff --git a/ci_mon b/ci_mon
index 2e30da4..4b35d38 100755
--- a/ci_mon
+++ b/ci_mon
@@ -140,13 +140,16 @@ if [ "X" = "X$pw_instance" ]; then
exit 1
fi
-for I in travis github obs dummy; do
+for I in travis github obs cirrus dummy; do
token=${I}_token
disable=disable_${I}
if [ "X${!disable}" = "Xyes" ]; then
+ echo "Skiping ${I}"
continue
+ else
+ echo "Scanning ${I}"
fi
./${I}_mon $pw_instance ${!token} "$pw_project" | grep "^pw|" | while IFS="|" \
@@ -163,6 +166,7 @@ for I in travis github obs dummy; do
patch_id="$(get_patch_id_by_series_id_and_sha "$series_id" "$shasum" "$pw_chk_instance")"
if [ "X$patch_id" == "X" ]; then
+ echo "No patchid..."
patch_id=$(echo $PATCHDATA | jq -rc '.patches[-1].id')
fi
PATCHDATA="$(echo "$PATCHDATA" | jq ".patches[] | select(.id==$patch_id)")"
diff --git a/cirrus_mon b/cirrus_mon
new file mode 100755
index 0000000..f307961
--- /dev/null
+++ b/cirrus_mon
@@ -0,0 +1,100 @@
+#!/bin/bash
+# SPDX-Identifier: gpl-2.0-or-later
+# Copyright (C) 2023, Red Hat, Inc.
+#
+# Monitors cirrus build history for builds in a series.
+# Records the builds in the series database (and emits them on the
+# stdout line for processing)
+#
+# Licensed under the terms of the GNU General Public License as published
+# by the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version. You may obtain a copy of the
+# license at
+#
+# https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+[ -f "$(dirname $0)/series_db_lib.sh" ] && source "$(dirname $0)/series_db_lib.sh"
+
+while [ "$1" != "" ]; do
+ if echo "$1" | grep -q -s -E ^--pw-instance= ; then
+ pw_instance=$(echo "$1" | sed s/^--pw-instance=//)
+ shift
+ elif echo "$1" | grep -q -s -E ^--cirrus-token= ; then
+ cirrus_token=$(echo "$1" | sed s/^--cirrus-token=//)
+ shift
+ elif echo "$1" | grep -q -s -E ^--help ; then
+ echo "Cirrus CI monitor script"
+ echo "$0: args"
+ echo "Required if not set in ~/.pwmon-rc file:"
+ echo " --pw-instance=<inst url> URL for pw"
+ echo ""
+ echo "Options:"
+ echo " --cirrus-token=<token> Sets tokenfor web requests"
+ echo ""
+ exit 0
+ elif ! echo "$1" | grep -q -s -E ^-- ; then
+ break
+ fi
+done
+
+echo "scanning started " >> /tmp/cirrus.log
+
+if [ "X" = "X$pw_instance" ]; then
+ pw_instance="$1"
+ shift
+fi
+
+if [ "X" = "X$github_token" ]; then
+ github_token="$1"
+ shift
+fi
+
+if [ "X" = "X$pw_project" -a "X$1" != "X" ]; then
+ pw_project="$1"
+ shift
+fi
+
+if [ "X$cirrus_token" != "X" ]; then
+ AUTH="-H \"Authorization: Bearer $cirrus_token\""
+fi
+
+ci_instance="cirrus_sync"
+
+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 obs_sync cirrus_sync; do
+ repo_owner=$(echo "$repo_name" | cut -d/ -f1)
+ repo_real=$(echo "$repo_name" | cut -d/ -f2)
+
+ graph_string="{ \"query\": \"query BuildBySHAQuery(\$owner: String!, \$name: String!, \$SHA: String){ searchBuilds(repositoryOwner: \$owner, repositoryName: \$name, SHA: \$SHA) { id, status } }\", \"variables\": { \"owner\": \"$repo_owner\", \"name\": \"$repo_real\", \"SHA\": \"$sha\" } }"
+ build_details=$(curl -s "$AUTH" -X POST --data "$graph_string" https://api.cirrus-ci.com/graphql)
+
+ id=$(echo "$build_details" | jq -rc '.data.searchBuilds[-1].id')
+ status=$(echo "$build_details" | jq '.data.searchBuilds[-1].status')
+ build_url="https://cirrus-ci.com/build/$id"
+
+ result="in-progress"
+ if [ "$status" == "\"COMPLETED\"" ]; then
+ result="passed"
+ elif [ "$status" == "\"FAILED\"" ]; then
+ result="failed"
+ elif [ "$status" == "\"ABORTED\"" ]; then
+ set_synced_patch "$patch_id" "$patchwork_instance" "$ci_instance"
+ echo "CIRRUS patch_id=$patch_id belonging to series=$series_id on $patchwork_instance was aborted" 1>$2
+ continue
+ elif [ "$status" == "\"ERRORED\"" ]; then
+ result="warn"
+ fi
+
+ if [ "$result" == "in-progress" ]; then
+ echo "CIRRUS patch_id=$patch_id belonging to series=$series_id is not completed[$status]. Skipping" 1>&2
+ continue
+ fi
+
+ echo "pw|$pw_instance|build|$series_id|SHA|$sha|$result|$build_url|$patch_name|$repo_name|$test_name"
+done
diff --git a/series_db_lib.sh b/series_db_lib.sh
index c5f42e0..e415870 100644
--- a/series_db_lib.sh
+++ b/series_db_lib.sh
@@ -130,6 +130,15 @@ recheck_sync INTEGER
EOF
run_db_command "INSERT INTO series_schema_version(id) values (8);"
fi
+
+ # 0009 - cirrus CI data
+ run_db_command "select * from series_schema_version;" | egrep '^9$' >/dev/null 2>&1
+ if [ $? -eq 1 ]; then
+ sqlite3 ${HOME}/.series-db <<EOF
+ALTER TABLE git_builds ADD COLUMN cirrus_sync INTEGER;
+EOF
+ run_db_command "INSERT INTO series_schema_version(id) values (9);"
+ fi
}
function series_db_exists() {
@@ -379,7 +388,7 @@ function set_synced_for_series() {
series_db_exists
- echo "update git_builds set gap_sync=1, obs_sync=1 where patchwork_instance=\"$instance\" and series_id=$series_id;" | series_db_execute
+ echo "update git_builds set gap_sync=1, cirrus_sync=1, obs_sync=1 where patchwork_instance=\"$instance\" and series_id=$series_id;" | series_db_execute
}
function set_unsynced_for_series() {
@@ -402,7 +411,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, obs_sync) VALUES($series_id, $patch_id, \"$patch_url\", \"$patch_name\", \"$sha\", \"$instance\", \"$project\", \"$repo_name\", 0, 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, cirrus_sync) VALUES($series_id, $patch_id, \"$patch_url\", \"$patch_name\", \"$sha\", \"$instance\", \"$project\", \"$repo_name\", 0, 0, 0);" | series_db_execute
}
function get_patch_id_by_series_id_and_sha() {
--
2.41.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] cirrus: add an initial polling mechanism
2023-12-12 16:08 [PATCH] cirrus: add an initial polling mechanism Aaron Conole
@ 2024-01-11 18:37 ` Aaron Conole
2024-01-11 19:01 ` Ilya Maximets
2024-01-11 19:36 ` Michael Santana
2024-01-15 20:00 ` Michael Santana
1 sibling, 2 replies; 7+ messages in thread
From: Aaron Conole @ 2024-01-11 18:37 UTC (permalink / raw)
To: ci; +Cc: Eelco Chaudron, Ilya Maximets, Dumitru Ceara, Michael Santana
Aaron Conole <aconole@redhat.com> writes:
> Cirrus-CI is used to provide a testing environment for FreeBSD, among
> others. As of now, the ci monitoring framework doesn't support checking
> for cirrus-ci status, but that can be changed. We add an initial polling
> similar to the original GitHub Actions or Travis-CI polling mechanisms
> that merely provides pass/fail/warn with a URL. This can be improved
> later to provide logs on a per-task (similar to GHA Jobs) basis.
>
> Signed-off-by: Aaron Conole <aconole@redhat.com>
> ---
Any comments? I hope to apply this soon.
> ci_mon | 6 ++-
> cirrus_mon | 100 +++++++++++++++++++++++++++++++++++++++++++++++
> series_db_lib.sh | 13 +++++-
> 3 files changed, 116 insertions(+), 3 deletions(-)
> create mode 100755 cirrus_mon
>
> diff --git a/ci_mon b/ci_mon
> index 2e30da4..4b35d38 100755
> --- a/ci_mon
> +++ b/ci_mon
> @@ -140,13 +140,16 @@ if [ "X" = "X$pw_instance" ]; then
> exit 1
> fi
>
> -for I in travis github obs dummy; do
> +for I in travis github obs cirrus dummy; do
>
> token=${I}_token
> disable=disable_${I}
>
> if [ "X${!disable}" = "Xyes" ]; then
> + echo "Skiping ${I}"
> continue
> + else
> + echo "Scanning ${I}"
> fi
>
> ./${I}_mon $pw_instance ${!token} "$pw_project" | grep "^pw|" | while IFS="|" \
> @@ -163,6 +166,7 @@ for I in travis github obs dummy; do
>
> patch_id="$(get_patch_id_by_series_id_and_sha "$series_id" "$shasum" "$pw_chk_instance")"
> if [ "X$patch_id" == "X" ]; then
> + echo "No patchid..."
> patch_id=$(echo $PATCHDATA | jq -rc '.patches[-1].id')
> fi
> PATCHDATA="$(echo "$PATCHDATA" | jq ".patches[] | select(.id==$patch_id)")"
> diff --git a/cirrus_mon b/cirrus_mon
> new file mode 100755
> index 0000000..f307961
> --- /dev/null
> +++ b/cirrus_mon
> @@ -0,0 +1,100 @@
> +#!/bin/bash
> +# SPDX-Identifier: gpl-2.0-or-later
> +# Copyright (C) 2023, Red Hat, Inc.
> +#
> +# Monitors cirrus build history for builds in a series.
> +# Records the builds in the series database (and emits them on the
> +# stdout line for processing)
> +#
> +# Licensed under the terms of the GNU General Public License as published
> +# by the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version. You may obtain a copy of the
> +# license at
> +#
> +# https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
> +#
> +# Unless required by applicable law or agreed to in writing, software
> +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
> +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
> +# License for the specific language governing permissions and limitations
> +# under the License.
> +
> +[ -f "$(dirname $0)/series_db_lib.sh" ] && source "$(dirname $0)/series_db_lib.sh"
> +
> +while [ "$1" != "" ]; do
> + if echo "$1" | grep -q -s -E ^--pw-instance= ; then
> + pw_instance=$(echo "$1" | sed s/^--pw-instance=//)
> + shift
> + elif echo "$1" | grep -q -s -E ^--cirrus-token= ; then
> + cirrus_token=$(echo "$1" | sed s/^--cirrus-token=//)
> + shift
> + elif echo "$1" | grep -q -s -E ^--help ; then
> + echo "Cirrus CI monitor script"
> + echo "$0: args"
> + echo "Required if not set in ~/.pwmon-rc file:"
> + echo " --pw-instance=<inst url> URL for pw"
> + echo ""
> + echo "Options:"
> + echo " --cirrus-token=<token> Sets tokenfor web requests"
> + echo ""
> + exit 0
> + elif ! echo "$1" | grep -q -s -E ^-- ; then
> + break
> + fi
> +done
> +
> +echo "scanning started " >> /tmp/cirrus.log
> +
> +if [ "X" = "X$pw_instance" ]; then
> + pw_instance="$1"
> + shift
> +fi
> +
> +if [ "X" = "X$github_token" ]; then
> + github_token="$1"
> + shift
> +fi
> +
> +if [ "X" = "X$pw_project" -a "X$1" != "X" ]; then
> + pw_project="$1"
> + shift
> +fi
> +
> +if [ "X$cirrus_token" != "X" ]; then
> + AUTH="-H \"Authorization: Bearer $cirrus_token\""
> +fi
> +
> +ci_instance="cirrus_sync"
> +
> +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 obs_sync cirrus_sync; do
> + repo_owner=$(echo "$repo_name" | cut -d/ -f1)
> + repo_real=$(echo "$repo_name" | cut -d/ -f2)
> +
> + graph_string="{ \"query\": \"query BuildBySHAQuery(\$owner: String!, \$name: String!, \$SHA: String){ searchBuilds(repositoryOwner: \$owner, repositoryName: \$name, SHA: \$SHA) { id, status } }\", \"variables\": { \"owner\": \"$repo_owner\", \"name\": \"$repo_real\", \"SHA\": \"$sha\" } }"
> + build_details=$(curl -s "$AUTH" -X POST --data "$graph_string" https://api.cirrus-ci.com/graphql)
> +
> + id=$(echo "$build_details" | jq -rc '.data.searchBuilds[-1].id')
> + status=$(echo "$build_details" | jq '.data.searchBuilds[-1].status')
> + build_url="https://cirrus-ci.com/build/$id"
> +
> + result="in-progress"
> + if [ "$status" == "\"COMPLETED\"" ]; then
> + result="passed"
> + elif [ "$status" == "\"FAILED\"" ]; then
> + result="failed"
> + elif [ "$status" == "\"ABORTED\"" ]; then
> + set_synced_patch "$patch_id" "$patchwork_instance" "$ci_instance"
> + echo "CIRRUS patch_id=$patch_id belonging to series=$series_id on $patchwork_instance was aborted" 1>$2
> + continue
> + elif [ "$status" == "\"ERRORED\"" ]; then
> + result="warn"
> + fi
> +
> + if [ "$result" == "in-progress" ]; then
> + echo "CIRRUS patch_id=$patch_id belonging to series=$series_id is not completed[$status]. Skipping" 1>&2
> + continue
> + fi
> +
> + echo "pw|$pw_instance|build|$series_id|SHA|$sha|$result|$build_url|$patch_name|$repo_name|$test_name"
> +done
> diff --git a/series_db_lib.sh b/series_db_lib.sh
> index c5f42e0..e415870 100644
> --- a/series_db_lib.sh
> +++ b/series_db_lib.sh
> @@ -130,6 +130,15 @@ recheck_sync INTEGER
> EOF
> run_db_command "INSERT INTO series_schema_version(id) values (8);"
> fi
> +
> + # 0009 - cirrus CI data
> + run_db_command "select * from series_schema_version;" | egrep '^9$' >/dev/null 2>&1
> + if [ $? -eq 1 ]; then
> + sqlite3 ${HOME}/.series-db <<EOF
> +ALTER TABLE git_builds ADD COLUMN cirrus_sync INTEGER;
> +EOF
> + run_db_command "INSERT INTO series_schema_version(id) values (9);"
> + fi
> }
>
> function series_db_exists() {
> @@ -379,7 +388,7 @@ function set_synced_for_series() {
>
> series_db_exists
>
> - echo "update git_builds set gap_sync=1, obs_sync=1 where patchwork_instance=\"$instance\" and series_id=$series_id;" | series_db_execute
> + echo "update git_builds set gap_sync=1, cirrus_sync=1, obs_sync=1 where patchwork_instance=\"$instance\" and series_id=$series_id;" | series_db_execute
> }
>
> function set_unsynced_for_series() {
> @@ -402,7 +411,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, obs_sync) VALUES($series_id, $patch_id, \"$patch_url\", \"$patch_name\", \"$sha\", \"$instance\", \"$project\", \"$repo_name\", 0, 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, cirrus_sync) VALUES($series_id, $patch_id, \"$patch_url\", \"$patch_name\", \"$sha\", \"$instance\", \"$project\", \"$repo_name\", 0, 0, 0);" | series_db_execute
> }
>
> function get_patch_id_by_series_id_and_sha() {
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] cirrus: add an initial polling mechanism
2024-01-11 18:37 ` Aaron Conole
@ 2024-01-11 19:01 ` Ilya Maximets
2024-01-12 17:53 ` Aaron Conole
2024-01-11 19:36 ` Michael Santana
1 sibling, 1 reply; 7+ messages in thread
From: Ilya Maximets @ 2024-01-11 19:01 UTC (permalink / raw)
To: Aaron Conole, ci
Cc: i.maximets, Eelco Chaudron, Dumitru Ceara, Michael Santana
On 1/11/24 19:37, Aaron Conole wrote:
> Aaron Conole <aconole@redhat.com> writes:
>
>> Cirrus-CI is used to provide a testing environment for FreeBSD, among
>> others. As of now, the ci monitoring framework doesn't support checking
>> for cirrus-ci status, but that can be changed. We add an initial polling
>> similar to the original GitHub Actions or Travis-CI polling mechanisms
>> that merely provides pass/fail/warn with a URL. This can be improved
>> later to provide logs on a per-task (similar to GHA Jobs) basis.
>>
>> Signed-off-by: Aaron Conole <aconole@redhat.com>
>> ---
>
> Any comments? I hope to apply this soon.
Hi. I'm not familiar with this project enough, so not
a full review, just a few comments. See below.
>
>> ci_mon | 6 ++-
>> cirrus_mon | 100 +++++++++++++++++++++++++++++++++++++++++++++++
>> series_db_lib.sh | 13 +++++-
>> 3 files changed, 116 insertions(+), 3 deletions(-)
>> create mode 100755 cirrus_mon
>>
>> diff --git a/ci_mon b/ci_mon
>> index 2e30da4..4b35d38 100755
>> --- a/ci_mon
>> +++ b/ci_mon
>> @@ -140,13 +140,16 @@ if [ "X" = "X$pw_instance" ]; then
>> exit 1
>> fi
>>
>> -for I in travis github obs dummy; do
>> +for I in travis github obs cirrus dummy; do
>>
>> token=${I}_token
>> disable=disable_${I}
>>
>> if [ "X${!disable}" = "Xyes" ]; then
>> + echo "Skiping ${I}"
>> continue
>> + else
>> + echo "Scanning ${I}"
>> fi
>>
>> ./${I}_mon $pw_instance ${!token} "$pw_project" | grep "^pw|" | while IFS="|" \
>> @@ -163,6 +166,7 @@ for I in travis github obs dummy; do
>>
>> patch_id="$(get_patch_id_by_series_id_and_sha "$series_id" "$shasum" "$pw_chk_instance")"
>> if [ "X$patch_id" == "X" ]; then
>> + echo "No patchid..."
patch_id ?
>> patch_id=$(echo $PATCHDATA | jq -rc '.patches[-1].id')
>> fi
>> PATCHDATA="$(echo "$PATCHDATA" | jq ".patches[] | select(.id==$patch_id)")"
>> diff --git a/cirrus_mon b/cirrus_mon
>> new file mode 100755
>> index 0000000..f307961
>> --- /dev/null
>> +++ b/cirrus_mon
>> @@ -0,0 +1,100 @@
>> +#!/bin/bash
>> +# SPDX-Identifier: gpl-2.0-or-later
>> +# Copyright (C) 2023, Red Hat, Inc.
>> +#
>> +# Monitors cirrus build history for builds in a series.
>> +# Records the builds in the series database (and emits them on the
>> +# stdout line for processing)
>> +#
>> +# Licensed under the terms of the GNU General Public License as published
>> +# by the Free Software Foundation; either version 2 of the License, or
>> +# (at your option) any later version. You may obtain a copy of the
>> +# license at
>> +#
>> +# https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
>> +#
>> +# Unless required by applicable law or agreed to in writing, software
>> +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
>> +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
>> +# License for the specific language governing permissions and limitations
>> +# under the License.
>> +
>> +[ -f "$(dirname $0)/series_db_lib.sh" ] && source "$(dirname $0)/series_db_lib.sh"
>> +
>> +while [ "$1" != "" ]; do
>> + if echo "$1" | grep -q -s -E ^--pw-instance= ; then
>> + pw_instance=$(echo "$1" | sed s/^--pw-instance=//)
>> + shift
>> + elif echo "$1" | grep -q -s -E ^--cirrus-token= ; then
>> + cirrus_token=$(echo "$1" | sed s/^--cirrus-token=//)
>> + shift
>> + elif echo "$1" | grep -q -s -E ^--help ; then
>> + echo "Cirrus CI monitor script"
>> + echo "$0: args"
>> + echo "Required if not set in ~/.pwmon-rc file:"
>> + echo " --pw-instance=<inst url> URL for pw"
>> + echo ""
>> + echo "Options:"
>> + echo " --cirrus-token=<token> Sets tokenfor web requests"
Missing space. And maybe misaligned?
>> + echo ""
>> + exit 0
>> + elif ! echo "$1" | grep -q -s -E ^-- ; then
>> + break
>> + fi
>> +done
>> +
>> +echo "scanning started " >> /tmp/cirrus.log
>> +
>> +if [ "X" = "X$pw_instance" ]; then
>> + pw_instance="$1"
>> + shift
>> +fi
>> +
>> +if [ "X" = "X$github_token" ]; then
>> + github_token="$1"
>> + shift
>> +fi
>> +
>> +if [ "X" = "X$pw_project" -a "X$1" != "X" ]; then
>> + pw_project="$1"
>> + shift
>> +fi
>> +
>> +if [ "X$cirrus_token" != "X" ]; then
>> + AUTH="-H \"Authorization: Bearer $cirrus_token\""
>> +fi
>> +
>> +ci_instance="cirrus_sync"
>> +
>> +get_unsynced_series "$pw_instance" "$ci_instance" | \
Just curious, if the existing system is upgraded to a
version with this patch, will it request statuses for
every single patch in a patchwork project on a first
run or is there something that prevents that?
>> + while IFS="|" read -r series_id patch_id patch_url patch_name sha patchwork_instance patchwork_project repo_name gap_sync obs_sync cirrus_sync; do
>> + repo_owner=$(echo "$repo_name" | cut -d/ -f1)
>> + repo_real=$(echo "$repo_name" | cut -d/ -f2)
>> +
>> + graph_string="{ \"query\": \"query BuildBySHAQuery(\$owner: String!, \$name: String!, \$SHA: String){ searchBuilds(repositoryOwner: \$owner, repositoryName: \$name, SHA: \$SHA) { id, status } }\", \"variables\": { \"owner\": \"$repo_owner\", \"name\": \"$repo_real\", \"SHA\": \"$sha\" } }"
>> + build_details=$(curl -s "$AUTH" -X POST --data "$graph_string" https://api.cirrus-ci.com/graphql)
>> +
>> + id=$(echo "$build_details" | jq -rc '.data.searchBuilds[-1].id')
>> + status=$(echo "$build_details" | jq '.data.searchBuilds[-1].status')
>> + build_url="https://cirrus-ci.com/build/$id"
>> +
>> + result="in-progress"
>> + if [ "$status" == "\"COMPLETED\"" ]; then
>> + result="passed"
>> + elif [ "$status" == "\"FAILED\"" ]; then
>> + result="failed"
>> + elif [ "$status" == "\"ABORTED\"" ]; then
>> + set_synced_patch "$patch_id" "$patchwork_instance" "$ci_instance"
>> + echo "CIRRUS patch_id=$patch_id belonging to series=$series_id on $patchwork_instance was aborted" 1>$2
$2 typo?
So, aborted jobs will not be reported?
But they will be re-queried every time?
>> + continue
>> + elif [ "$status" == "\"ERRORED\"" ]; then
>> + result="warn"
>> + fi
>> +
>> + if [ "$result" == "in-progress" ]; then
>> + echo "CIRRUS patch_id=$patch_id belonging to series=$series_id is not completed[$status]. Skipping" 1>&2
>> + continue
>> + fi
>> +
>> + echo "pw|$pw_instance|build|$series_id|SHA|$sha|$result|$build_url|$patch_name|$repo_name|$test_name"
>> +done
>> diff --git a/series_db_lib.sh b/series_db_lib.sh
>> index c5f42e0..e415870 100644
>> --- a/series_db_lib.sh
>> +++ b/series_db_lib.sh
>> @@ -130,6 +130,15 @@ recheck_sync INTEGER
>> EOF
>> run_db_command "INSERT INTO series_schema_version(id) values (8);"
>> fi
>> +
>> + # 0009 - cirrus CI data
>> + run_db_command "select * from series_schema_version;" | egrep '^9$' >/dev/null 2>&1
>> + if [ $? -eq 1 ]; then
>> + sqlite3 ${HOME}/.series-db <<EOF
>> +ALTER TABLE git_builds ADD COLUMN cirrus_sync INTEGER;
>> +EOF
>> + run_db_command "INSERT INTO series_schema_version(id) values (9);"
>> + fi
>> }
>>
>> function series_db_exists() {
>> @@ -379,7 +388,7 @@ function set_synced_for_series() {
>>
>> series_db_exists
>>
>> - echo "update git_builds set gap_sync=1, obs_sync=1 where patchwork_instance=\"$instance\" and series_id=$series_id;" | series_db_execute
>> + echo "update git_builds set gap_sync=1, cirrus_sync=1, obs_sync=1 where patchwork_instance=\"$instance\" and series_id=$series_id;" | series_db_execute
>> }
>>
>> function set_unsynced_for_series() {
>> @@ -402,7 +411,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, obs_sync) VALUES($series_id, $patch_id, \"$patch_url\", \"$patch_name\", \"$sha\", \"$instance\", \"$project\", \"$repo_name\", 0, 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, cirrus_sync) VALUES($series_id, $patch_id, \"$patch_url\", \"$patch_name\", \"$sha\", \"$instance\", \"$project\", \"$repo_name\", 0, 0, 0);" | series_db_execute
>> }
>>
>> function get_patch_id_by_series_id_and_sha() {
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] cirrus: add an initial polling mechanism
2024-01-11 18:37 ` Aaron Conole
2024-01-11 19:01 ` Ilya Maximets
@ 2024-01-11 19:36 ` Michael Santana
1 sibling, 0 replies; 7+ messages in thread
From: Michael Santana @ 2024-01-11 19:36 UTC (permalink / raw)
To: Aaron Conole; +Cc: ci, Eelco Chaudron, Ilya Maximets, Dumitru Ceara
Sorry got buried in my email queue from break. Let me take a look
On Thu, Jan 11, 2024 at 1:37 PM Aaron Conole <aconole@redhat.com> wrote:
>
> Aaron Conole <aconole@redhat.com> writes:
>
> > Cirrus-CI is used to provide a testing environment for FreeBSD, among
> > others. As of now, the ci monitoring framework doesn't support checking
> > for cirrus-ci status, but that can be changed. We add an initial polling
> > similar to the original GitHub Actions or Travis-CI polling mechanisms
> > that merely provides pass/fail/warn with a URL. This can be improved
> > later to provide logs on a per-task (similar to GHA Jobs) basis.
> >
> > Signed-off-by: Aaron Conole <aconole@redhat.com>
> > ---
>
> Any comments? I hope to apply this soon.
>
> > ci_mon | 6 ++-
> > cirrus_mon | 100 +++++++++++++++++++++++++++++++++++++++++++++++
> > series_db_lib.sh | 13 +++++-
> > 3 files changed, 116 insertions(+), 3 deletions(-)
> > create mode 100755 cirrus_mon
> >
> > diff --git a/ci_mon b/ci_mon
> > index 2e30da4..4b35d38 100755
> > --- a/ci_mon
> > +++ b/ci_mon
> > @@ -140,13 +140,16 @@ if [ "X" = "X$pw_instance" ]; then
> > exit 1
> > fi
> >
> > -for I in travis github obs dummy; do
> > +for I in travis github obs cirrus dummy; do
> >
> > token=${I}_token
> > disable=disable_${I}
> >
> > if [ "X${!disable}" = "Xyes" ]; then
> > + echo "Skiping ${I}"
> > continue
> > + else
> > + echo "Scanning ${I}"
> > fi
> >
> > ./${I}_mon $pw_instance ${!token} "$pw_project" | grep "^pw|" | while IFS="|" \
> > @@ -163,6 +166,7 @@ for I in travis github obs dummy; do
> >
> > patch_id="$(get_patch_id_by_series_id_and_sha "$series_id" "$shasum" "$pw_chk_instance")"
> > if [ "X$patch_id" == "X" ]; then
> > + echo "No patchid..."
> > patch_id=$(echo $PATCHDATA | jq -rc '.patches[-1].id')
> > fi
> > PATCHDATA="$(echo "$PATCHDATA" | jq ".patches[] | select(.id==$patch_id)")"
> > diff --git a/cirrus_mon b/cirrus_mon
> > new file mode 100755
> > index 0000000..f307961
> > --- /dev/null
> > +++ b/cirrus_mon
> > @@ -0,0 +1,100 @@
> > +#!/bin/bash
> > +# SPDX-Identifier: gpl-2.0-or-later
> > +# Copyright (C) 2023, Red Hat, Inc.
> > +#
> > +# Monitors cirrus build history for builds in a series.
> > +# Records the builds in the series database (and emits them on the
> > +# stdout line for processing)
> > +#
> > +# Licensed under the terms of the GNU General Public License as published
> > +# by the Free Software Foundation; either version 2 of the License, or
> > +# (at your option) any later version. You may obtain a copy of the
> > +# license at
> > +#
> > +# https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
> > +#
> > +# Unless required by applicable law or agreed to in writing, software
> > +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
> > +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
> > +# License for the specific language governing permissions and limitations
> > +# under the License.
> > +
> > +[ -f "$(dirname $0)/series_db_lib.sh" ] && source "$(dirname $0)/series_db_lib.sh"
> > +
> > +while [ "$1" != "" ]; do
> > + if echo "$1" | grep -q -s -E ^--pw-instance= ; then
> > + pw_instance=$(echo "$1" | sed s/^--pw-instance=//)
> > + shift
> > + elif echo "$1" | grep -q -s -E ^--cirrus-token= ; then
> > + cirrus_token=$(echo "$1" | sed s/^--cirrus-token=//)
> > + shift
> > + elif echo "$1" | grep -q -s -E ^--help ; then
> > + echo "Cirrus CI monitor script"
> > + echo "$0: args"
> > + echo "Required if not set in ~/.pwmon-rc file:"
> > + echo " --pw-instance=<inst url> URL for pw"
> > + echo ""
> > + echo "Options:"
> > + echo " --cirrus-token=<token> Sets tokenfor web requests"
> > + echo ""
> > + exit 0
> > + elif ! echo "$1" | grep -q -s -E ^-- ; then
> > + break
> > + fi
> > +done
> > +
> > +echo "scanning started " >> /tmp/cirrus.log
> > +
> > +if [ "X" = "X$pw_instance" ]; then
> > + pw_instance="$1"
> > + shift
> > +fi
> > +
> > +if [ "X" = "X$github_token" ]; then
> > + github_token="$1"
> > + shift
> > +fi
> > +
> > +if [ "X" = "X$pw_project" -a "X$1" != "X" ]; then
> > + pw_project="$1"
> > + shift
> > +fi
> > +
> > +if [ "X$cirrus_token" != "X" ]; then
> > + AUTH="-H \"Authorization: Bearer $cirrus_token\""
> > +fi
> > +
> > +ci_instance="cirrus_sync"
> > +
> > +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 obs_sync cirrus_sync; do
> > + repo_owner=$(echo "$repo_name" | cut -d/ -f1)
> > + repo_real=$(echo "$repo_name" | cut -d/ -f2)
> > +
> > + graph_string="{ \"query\": \"query BuildBySHAQuery(\$owner: String!, \$name: String!, \$SHA: String){ searchBuilds(repositoryOwner: \$owner, repositoryName: \$name, SHA: \$SHA) { id, status } }\", \"variables\": { \"owner\": \"$repo_owner\", \"name\": \"$repo_real\", \"SHA\": \"$sha\" } }"
> > + build_details=$(curl -s "$AUTH" -X POST --data "$graph_string" https://api.cirrus-ci.com/graphql)
> > +
> > + id=$(echo "$build_details" | jq -rc '.data.searchBuilds[-1].id')
> > + status=$(echo "$build_details" | jq '.data.searchBuilds[-1].status')
> > + build_url="https://cirrus-ci.com/build/$id"
> > +
> > + result="in-progress"
> > + if [ "$status" == "\"COMPLETED\"" ]; then
> > + result="passed"
> > + elif [ "$status" == "\"FAILED\"" ]; then
> > + result="failed"
> > + elif [ "$status" == "\"ABORTED\"" ]; then
> > + set_synced_patch "$patch_id" "$patchwork_instance" "$ci_instance"
> > + echo "CIRRUS patch_id=$patch_id belonging to series=$series_id on $patchwork_instance was aborted" 1>$2
> > + continue
> > + elif [ "$status" == "\"ERRORED\"" ]; then
> > + result="warn"
> > + fi
> > +
> > + if [ "$result" == "in-progress" ]; then
> > + echo "CIRRUS patch_id=$patch_id belonging to series=$series_id is not completed[$status]. Skipping" 1>&2
> > + continue
> > + fi
> > +
> > + echo "pw|$pw_instance|build|$series_id|SHA|$sha|$result|$build_url|$patch_name|$repo_name|$test_name"
> > +done
> > diff --git a/series_db_lib.sh b/series_db_lib.sh
> > index c5f42e0..e415870 100644
> > --- a/series_db_lib.sh
> > +++ b/series_db_lib.sh
> > @@ -130,6 +130,15 @@ recheck_sync INTEGER
> > EOF
> > run_db_command "INSERT INTO series_schema_version(id) values (8);"
> > fi
> > +
> > + # 0009 - cirrus CI data
> > + run_db_command "select * from series_schema_version;" | egrep '^9$' >/dev/null 2>&1
> > + if [ $? -eq 1 ]; then
> > + sqlite3 ${HOME}/.series-db <<EOF
> > +ALTER TABLE git_builds ADD COLUMN cirrus_sync INTEGER;
> > +EOF
> > + run_db_command "INSERT INTO series_schema_version(id) values (9);"
> > + fi
> > }
> >
> > function series_db_exists() {
> > @@ -379,7 +388,7 @@ function set_synced_for_series() {
> >
> > series_db_exists
> >
> > - echo "update git_builds set gap_sync=1, obs_sync=1 where patchwork_instance=\"$instance\" and series_id=$series_id;" | series_db_execute
> > + echo "update git_builds set gap_sync=1, cirrus_sync=1, obs_sync=1 where patchwork_instance=\"$instance\" and series_id=$series_id;" | series_db_execute
> > }
> >
> > function set_unsynced_for_series() {
> > @@ -402,7 +411,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, obs_sync) VALUES($series_id, $patch_id, \"$patch_url\", \"$patch_name\", \"$sha\", \"$instance\", \"$project\", \"$repo_name\", 0, 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, cirrus_sync) VALUES($series_id, $patch_id, \"$patch_url\", \"$patch_name\", \"$sha\", \"$instance\", \"$project\", \"$repo_name\", 0, 0, 0);" | series_db_execute
> > }
> >
> > function get_patch_id_by_series_id_and_sha() {
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] cirrus: add an initial polling mechanism
2024-01-11 19:01 ` Ilya Maximets
@ 2024-01-12 17:53 ` Aaron Conole
0 siblings, 0 replies; 7+ messages in thread
From: Aaron Conole @ 2024-01-12 17:53 UTC (permalink / raw)
To: Ilya Maximets; +Cc: ci, Eelco Chaudron, Dumitru Ceara, Michael Santana
Ilya Maximets <i.maximets@ovn.org> writes:
> On 1/11/24 19:37, Aaron Conole wrote:
>> Aaron Conole <aconole@redhat.com> writes:
>>
>>> Cirrus-CI is used to provide a testing environment for FreeBSD, among
>>> others. As of now, the ci monitoring framework doesn't support checking
>>> for cirrus-ci status, but that can be changed. We add an initial polling
>>> similar to the original GitHub Actions or Travis-CI polling mechanisms
>>> that merely provides pass/fail/warn with a URL. This can be improved
>>> later to provide logs on a per-task (similar to GHA Jobs) basis.
>>>
>>> Signed-off-by: Aaron Conole <aconole@redhat.com>
>>> ---
>>
>> Any comments? I hope to apply this soon.
>
> Hi. I'm not familiar with this project enough, so not
> a full review, just a few comments. See below.
Thanks
>>
>>> ci_mon | 6 ++-
>>> cirrus_mon | 100 +++++++++++++++++++++++++++++++++++++++++++++++
>>> series_db_lib.sh | 13 +++++-
>>> 3 files changed, 116 insertions(+), 3 deletions(-)
>>> create mode 100755 cirrus_mon
>>>
>>> diff --git a/ci_mon b/ci_mon
>>> index 2e30da4..4b35d38 100755
>>> --- a/ci_mon
>>> +++ b/ci_mon
>>> @@ -140,13 +140,16 @@ if [ "X" = "X$pw_instance" ]; then
>>> exit 1
>>> fi
>>>
>>> -for I in travis github obs dummy; do
>>> +for I in travis github obs cirrus dummy; do
>>>
>>> token=${I}_token
>>> disable=disable_${I}
>>>
>>> if [ "X${!disable}" = "Xyes" ]; then
>>> + echo "Skiping ${I}"
>>> continue
>>> + else
>>> + echo "Scanning ${I}"
>>> fi
>>>
>>> ./${I}_mon $pw_instance ${!token} "$pw_project" | grep "^pw|" | while IFS="|" \
>>> @@ -163,6 +166,7 @@ for I in travis github obs dummy; do
>>>
>>> patch_id="$(get_patch_id_by_series_id_and_sha "$series_id" "$shasum" "$pw_chk_instance")"
>>> if [ "X$patch_id" == "X" ]; then
>>> + echo "No patchid..."
>
> patch_id ?
ACK
>>> patch_id=$(echo $PATCHDATA | jq -rc '.patches[-1].id')
>>> fi
>>> PATCHDATA="$(echo "$PATCHDATA" | jq ".patches[] | select(.id==$patch_id)")"
>>> diff --git a/cirrus_mon b/cirrus_mon
>>> new file mode 100755
>>> index 0000000..f307961
>>> --- /dev/null
>>> +++ b/cirrus_mon
>>> @@ -0,0 +1,100 @@
>>> +#!/bin/bash
>>> +# SPDX-Identifier: gpl-2.0-or-later
>>> +# Copyright (C) 2023, Red Hat, Inc.
>>> +#
>>> +# Monitors cirrus build history for builds in a series.
>>> +# Records the builds in the series database (and emits them on the
>>> +# stdout line for processing)
>>> +#
>>> +# Licensed under the terms of the GNU General Public License as published
>>> +# by the Free Software Foundation; either version 2 of the License, or
>>> +# (at your option) any later version. You may obtain a copy of the
>>> +# license at
>>> +#
>>> +# https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
>>> +#
>>> +# Unless required by applicable law or agreed to in writing, software
>>> +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
>>> +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
>>> +# License for the specific language governing permissions and limitations
>>> +# under the License.
>>> +
>>> +[ -f "$(dirname $0)/series_db_lib.sh" ] && source "$(dirname $0)/series_db_lib.sh"
>>> +
>>> +while [ "$1" != "" ]; do
>>> + if echo "$1" | grep -q -s -E ^--pw-instance= ; then
>>> + pw_instance=$(echo "$1" | sed s/^--pw-instance=//)
>>> + shift
>>> + elif echo "$1" | grep -q -s -E ^--cirrus-token= ; then
>>> + cirrus_token=$(echo "$1" | sed s/^--cirrus-token=//)
>>> + shift
>>> + elif echo "$1" | grep -q -s -E ^--help ; then
>>> + echo "Cirrus CI monitor script"
>>> + echo "$0: args"
>>> + echo "Required if not set in ~/.pwmon-rc file:"
>>> + echo " --pw-instance=<inst url> URL for pw"
>>> + echo ""
>>> + echo "Options:"
>>> + echo " --cirrus-token=<token> Sets tokenfor web requests"
>
> Missing space. And maybe misaligned?
ACK - will fix both.
>>> + echo ""
>>> + exit 0
>>> + elif ! echo "$1" | grep -q -s -E ^-- ; then
>>> + break
>>> + fi
>>> +done
>>> +
>>> +echo "scanning started " >> /tmp/cirrus.log
>>> +
>>> +if [ "X" = "X$pw_instance" ]; then
>>> + pw_instance="$1"
>>> + shift
>>> +fi
>>> +
>>> +if [ "X" = "X$github_token" ]; then
>>> + github_token="$1"
>>> + shift
>>> +fi
>>> +
>>> +if [ "X" = "X$pw_project" -a "X$1" != "X" ]; then
>>> + pw_project="$1"
>>> + shift
>>> +fi
>>> +
>>> +if [ "X$cirrus_token" != "X" ]; then
>>> + AUTH="-H \"Authorization: Bearer $cirrus_token\""
>>> +fi
>>> +
>>> +ci_instance="cirrus_sync"
>>> +
>>> +get_unsynced_series "$pw_instance" "$ci_instance" | \
>
> Just curious, if the existing system is upgraded to a
> version with this patch, will it request statuses for
> every single patch in a patchwork project on a first
> run or is there something that prevents that?
It will only scan for open series (which is a specific state value in
the DB). Those will only be set when the insert_commit_into_db is
called, and will set things up there. Older series won't have any
values in the column, so they will be ignored.
>>> + while IFS="|" read -r series_id patch_id patch_url patch_name sha
>>> patchwork_instance patchwork_project repo_name gap_sync obs_sync
>>> cirrus_sync; do
>>> + repo_owner=$(echo "$repo_name" | cut -d/ -f1)
>>> + repo_real=$(echo "$repo_name" | cut -d/ -f2)
>>> +
>>> + graph_string="{ \"query\": \"query BuildBySHAQuery(\$owner:
>>> String!, \$name: String!, \$SHA: String){
>>> searchBuilds(repositoryOwner: \$owner, repositoryName: \$name, SHA:
>>> \$SHA) { id, status } }\", \"variables\": { \"owner\":
>>> \"$repo_owner\", \"name\": \"$repo_real\", \"SHA\": \"$sha\" } }"
>>> + build_details=$(curl -s "$AUTH" -X POST --data "$graph_string"
>>> https://api.cirrus-ci.com/graphql)
>>> +
>>> + id=$(echo "$build_details" | jq -rc '.data.searchBuilds[-1].id')
>>> + status=$(echo "$build_details" | jq '.data.searchBuilds[-1].status')
>>> + build_url="https://cirrus-ci.com/build/$id"
>>> +
>>> + result="in-progress"
>>> + if [ "$status" == "\"COMPLETED\"" ]; then
>>> + result="passed"
>>> + elif [ "$status" == "\"FAILED\"" ]; then
>>> + result="failed"
>>> + elif [ "$status" == "\"ABORTED\"" ]; then
>>> + set_synced_patch "$patch_id" "$patchwork_instance" "$ci_instance"
>>> + echo "CIRRUS patch_id=$patch_id belonging to series=$series_id on
>>> $patchwork_instance was aborted" 1>$2
>
> $2 typo?
Oops, thanks.
> So, aborted jobs will not be reported?
> But they will be re-queried every time?
Correct they won't be aborted, but we set them with the set_synced_patch
here rather than letting the caller decide. That's because ABORT is
special, it only happens because (A) someone hit the cancel button, or
(B) a new commit got pushed to the branch.
In both cases, we can't report it as a failure because it didn't fail.
We could consider reporting a WARN, but the issue is that for
multi-patch series, we will report WARN on every patch but the last one
in the series.
So the idea is just silently discard these. We can improve it in the
future, but it looks less alarming that seeing lots of WARN messages.
We could consider reporting PASS, but it would be a false PASS.
Actually, I guess it would be cool for patchwork to allow for additional
states, like some kind of In Progress and canceled states.
>>> + continue
>>> + elif [ "$status" == "\"ERRORED\"" ]; then
>>> + result="warn"
>>> + fi
>>> +
>>> + if [ "$result" == "in-progress" ]; then
>>> + echo "CIRRUS patch_id=$patch_id belonging to series=$series_id is not completed[$status]. Skipping" 1>&2
>>> + continue
>>> + fi
>>> +
>>> + echo "pw|$pw_instance|build|$series_id|SHA|$sha|$result|$build_url|$patch_name|$repo_name|$test_name"
>>> +done
>>> diff --git a/series_db_lib.sh b/series_db_lib.sh
>>> index c5f42e0..e415870 100644
>>> --- a/series_db_lib.sh
>>> +++ b/series_db_lib.sh
>>> @@ -130,6 +130,15 @@ recheck_sync INTEGER
>>> EOF
>>> run_db_command "INSERT INTO series_schema_version(id) values (8);"
>>> fi
>>> +
>>> + # 0009 - cirrus CI data
>>> + run_db_command "select * from series_schema_version;" | egrep '^9$' >/dev/null 2>&1
>>> + if [ $? -eq 1 ]; then
>>> + sqlite3 ${HOME}/.series-db <<EOF
>>> +ALTER TABLE git_builds ADD COLUMN cirrus_sync INTEGER;
>>> +EOF
>>> + run_db_command "INSERT INTO series_schema_version(id) values (9);"
>>> + fi
>>> }
>>>
>>> function series_db_exists() {
>>> @@ -379,7 +388,7 @@ function set_synced_for_series() {
>>>
>>> series_db_exists
>>>
>>> - echo "update git_builds set gap_sync=1, obs_sync=1 where patchwork_instance=\"$instance\" and series_id=$series_id;" | series_db_execute
>>> + echo "update git_builds set gap_sync=1, cirrus_sync=1, obs_sync=1 where patchwork_instance=\"$instance\" and series_id=$series_id;" | series_db_execute
>>> }
>>>
>>> function set_unsynced_for_series() {
>>> @@ -402,7 +411,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, obs_sync) VALUES($series_id, $patch_id, \"$patch_url\", \"$patch_name\", \"$sha\", \"$instance\", \"$project\", \"$repo_name\", 0, 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, cirrus_sync) VALUES($series_id, $patch_id, \"$patch_url\", \"$patch_name\", \"$sha\", \"$instance\", \"$project\", \"$repo_name\", 0, 0, 0);" | series_db_execute
>>> }
>>>
>>> function get_patch_id_by_series_id_and_sha() {
>>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] cirrus: add an initial polling mechanism
2023-12-12 16:08 [PATCH] cirrus: add an initial polling mechanism Aaron Conole
2024-01-11 18:37 ` Aaron Conole
@ 2024-01-15 20:00 ` Michael Santana
2024-01-19 14:51 ` Aaron Conole
1 sibling, 1 reply; 7+ messages in thread
From: Michael Santana @ 2024-01-15 20:00 UTC (permalink / raw)
To: Aaron Conole; +Cc: ci, Eelco Chaudron, Ilya Maximets, Dumitru Ceara
On Tue, Dec 12, 2023 at 11:08 AM Aaron Conole <aconole@redhat.com> wrote:
>
> Cirrus-CI is used to provide a testing environment for FreeBSD, among
> others. As of now, the ci monitoring framework doesn't support checking
> for cirrus-ci status, but that can be changed. We add an initial polling
> similar to the original GitHub Actions or Travis-CI polling mechanisms
> that merely provides pass/fail/warn with a URL. This can be improved
> later to provide logs on a per-task (similar to GHA Jobs) basis.
>
> Signed-off-by: Aaron Conole <aconole@redhat.com>
For the most part it looks good to me. See inline comments below. Thanks Aaron!
> ---
> ci_mon | 6 ++-
> cirrus_mon | 100 +++++++++++++++++++++++++++++++++++++++++++++++
> series_db_lib.sh | 13 +++++-
> 3 files changed, 116 insertions(+), 3 deletions(-)
> create mode 100755 cirrus_mon
>
> diff --git a/ci_mon b/ci_mon
> index 2e30da4..4b35d38 100755
> --- a/ci_mon
> +++ b/ci_mon
> @@ -140,13 +140,16 @@ if [ "X" = "X$pw_instance" ]; then
> exit 1
> fi
>
> -for I in travis github obs dummy; do
> +for I in travis github obs cirrus dummy; do
ok
>
> token=${I}_token
> disable=disable_${I}
>
> if [ "X${!disable}" = "Xyes" ]; then
> + echo "Skiping ${I}"
> continue
> + else
> + echo "Scanning ${I}"
> fi
>
> ./${I}_mon $pw_instance ${!token} "$pw_project" | grep "^pw|" | while IFS="|" \
> @@ -163,6 +166,7 @@ for I in travis github obs dummy; do
>
> patch_id="$(get_patch_id_by_series_id_and_sha "$series_id" "$shasum" "$pw_chk_instance")"
> if [ "X$patch_id" == "X" ]; then
> + echo "No patchid..."
> patch_id=$(echo $PATCHDATA | jq -rc '.patches[-1].id')
> fi
> PATCHDATA="$(echo "$PATCHDATA" | jq ".patches[] | select(.id==$patch_id)")"
> diff --git a/cirrus_mon b/cirrus_mon
> new file mode 100755
> index 0000000..f307961
> --- /dev/null
> +++ b/cirrus_mon
I agree with your commit message. This is very much like the github
and travis pulling. A lot of stuff that's similar to those scripts.
So most of my questions are based on the cirrus specific workflow. It
has been a while since I have worked with cirrus
> @@ -0,0 +1,100 @@
> +#!/bin/bash
> +# SPDX-Identifier: gpl-2.0-or-later
> +# Copyright (C) 2023, Red Hat, Inc.
> +#
> +# Monitors cirrus build history for builds in a series.
> +# Records the builds in the series database (and emits them on the
> +# stdout line for processing)
> +#
> +# Licensed under the terms of the GNU General Public License as published
> +# by the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version. You may obtain a copy of the
> +# license at
> +#
> +# https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
> +#
> +# Unless required by applicable law or agreed to in writing, software
> +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
> +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
> +# License for the specific language governing permissions and limitations
> +# under the License.
> +
> +[ -f "$(dirname $0)/series_db_lib.sh" ] && source "$(dirname $0)/series_db_lib.sh"
> +
> +while [ "$1" != "" ]; do
> + if echo "$1" | grep -q -s -E ^--pw-instance= ; then
> + pw_instance=$(echo "$1" | sed s/^--pw-instance=//)
> + shift
> + elif echo "$1" | grep -q -s -E ^--cirrus-token= ; then
> + cirrus_token=$(echo "$1" | sed s/^--cirrus-token=//)
> + shift
> + elif echo "$1" | grep -q -s -E ^--help ; then
> + echo "Cirrus CI monitor script"
> + echo "$0: args"
> + echo "Required if not set in ~/.pwmon-rc file:"
> + echo " --pw-instance=<inst url> URL for pw"
> + echo ""
> + echo "Options:"
> + echo " --cirrus-token=<token> Sets tokenfor web requests"
s/tokenfor/token for/
> + echo ""
> + exit 0
> + elif ! echo "$1" | grep -q -s -E ^-- ; then
> + break
> + fi
> +done
> +
> +echo "scanning started " >> /tmp/cirrus.log
> +
> +if [ "X" = "X$pw_instance" ]; then
> + pw_instance="$1"
> + shift
> +fi
> +
> +if [ "X" = "X$github_token" ]; then
How come cirrus needs a github token? Sorry, it's been a while since I
used cirrus. Are cirrus builds based on github commits?
> + github_token="$1"
> + shift
> +fi
> +
> +if [ "X" = "X$pw_project" -a "X$1" != "X" ]; then
> + pw_project="$1"
> + shift
> +fi
> +
> +if [ "X$cirrus_token" != "X" ]; then
> + AUTH="-H \"Authorization: Bearer $cirrus_token\""
> +fi
> +
> +ci_instance="cirrus_sync"
> +
> +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 obs_sync cirrus_sync; do
> + repo_owner=$(echo "$repo_name" | cut -d/ -f1)
> + repo_real=$(echo "$repo_name" | cut -d/ -f2)
> +
> + graph_string="{ \"query\": \"query BuildBySHAQuery(\$owner: String!, \$name: String!, \$SHA: String){ searchBuilds(repositoryOwner: \$owner, repositoryName: \$name, SHA: \$SHA) { id, status } }\", \"variables\": { \"owner\": \"$repo_owner\", \"name\": \"$repo_real\", \"SHA\": \"$sha\" } }"
> + build_details=$(curl -s "$AUTH" -X POST --data "$graph_string" https://api.cirrus-ci.com/graphql)
My other question regarding cirrus workflow was this. Normally with
github we would have a direct URL to the project, e.g.
github.com/ovsrobot/ovs, but I dont see anything like
"cirrus.com/ovsrobot/ovs". Maybe that inmbeded in one of the
variables? or is this why we have the query string using the variables
repo_owner and repo_real? If that's the case then it's a shame cirrus
doesnt have a direct API call into the project itself
> +
> + id=$(echo "$build_details" | jq -rc '.data.searchBuilds[-1].id')
> + status=$(echo "$build_details" | jq '.data.searchBuilds[-1].status')
> + build_url="https://cirrus-ci.com/build/$id"
> +
> + result="in-progress"
> + if [ "$status" == "\"COMPLETED\"" ]; then
> + result="passed"
> + elif [ "$status" == "\"FAILED\"" ]; then
> + result="failed"
> + elif [ "$status" == "\"ABORTED\"" ]; then
> + set_synced_patch "$patch_id" "$patchwork_instance" "$ci_instance"
> + echo "CIRRUS patch_id=$patch_id belonging to series=$series_id on $patchwork_instance was aborted" 1>$2
> + continue
> + elif [ "$status" == "\"ERRORED\"" ]; then
> + result="warn"
> + fi
> +
> + if [ "$result" == "in-progress" ]; then
> + echo "CIRRUS patch_id=$patch_id belonging to series=$series_id is not completed[$status]. Skipping" 1>&2
> + continue
> + fi
> +
> + echo "pw|$pw_instance|build|$series_id|SHA|$sha|$result|$build_url|$patch_name|$repo_name|$test_name"
ok
> +done
> diff --git a/series_db_lib.sh b/series_db_lib.sh
> index c5f42e0..e415870 100644
> --- a/series_db_lib.sh
> +++ b/series_db_lib.sh
> @@ -130,6 +130,15 @@ recheck_sync INTEGER
> EOF
> run_db_command "INSERT INTO series_schema_version(id) values (8);"
> fi
> +
> + # 0009 - cirrus CI data
> + run_db_command "select * from series_schema_version;" | egrep '^9$' >/dev/null 2>&1
> + if [ $? -eq 1 ]; then
> + sqlite3 ${HOME}/.series-db <<EOF
> +ALTER TABLE git_builds ADD COLUMN cirrus_sync INTEGER;
> +EOF
> + run_db_command "INSERT INTO series_schema_version(id) values (9);"
ok
> + fi
> }
>
> function series_db_exists() {
> @@ -379,7 +388,7 @@ function set_synced_for_series() {
>
> series_db_exists
>
> - echo "update git_builds set gap_sync=1, obs_sync=1 where patchwork_instance=\"$instance\" and series_id=$series_id;" | series_db_execute
> + echo "update git_builds set gap_sync=1, cirrus_sync=1, obs_sync=1 where patchwork_instance=\"$instance\" and series_id=$series_id;" | series_db_execute
ok
> }
>
> function set_unsynced_for_series() {
> @@ -402,7 +411,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, obs_sync) VALUES($series_id, $patch_id, \"$patch_url\", \"$patch_name\", \"$sha\", \"$instance\", \"$project\", \"$repo_name\", 0, 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, cirrus_sync) VALUES($series_id, $patch_id, \"$patch_url\", \"$patch_name\", \"$sha\", \"$instance\", \"$project\", \"$repo_name\", 0, 0, 0);" | series_db_execute
ok
> }
>
> function get_patch_id_by_series_id_and_sha() {
> --
> 2.41.0
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] cirrus: add an initial polling mechanism
2024-01-15 20:00 ` Michael Santana
@ 2024-01-19 14:51 ` Aaron Conole
0 siblings, 0 replies; 7+ messages in thread
From: Aaron Conole @ 2024-01-19 14:51 UTC (permalink / raw)
To: Michael Santana; +Cc: ci, Eelco Chaudron, Ilya Maximets, Dumitru Ceara
Michael Santana <msantana@redhat.com> writes:
> On Tue, Dec 12, 2023 at 11:08 AM Aaron Conole <aconole@redhat.com> wrote:
>>
>> Cirrus-CI is used to provide a testing environment for FreeBSD, among
>> others. As of now, the ci monitoring framework doesn't support checking
>> for cirrus-ci status, but that can be changed. We add an initial polling
>> similar to the original GitHub Actions or Travis-CI polling mechanisms
>> that merely provides pass/fail/warn with a URL. This can be improved
>> later to provide logs on a per-task (similar to GHA Jobs) basis.
>>
>> Signed-off-by: Aaron Conole <aconole@redhat.com>
> For the most part it looks good to me. See inline comments below. Thanks Aaron!
>> ---
>> ci_mon | 6 ++-
>> cirrus_mon | 100 +++++++++++++++++++++++++++++++++++++++++++++++
>> series_db_lib.sh | 13 +++++-
>> 3 files changed, 116 insertions(+), 3 deletions(-)
>> create mode 100755 cirrus_mon
>>
>> diff --git a/ci_mon b/ci_mon
>> index 2e30da4..4b35d38 100755
>> --- a/ci_mon
>> +++ b/ci_mon
>> @@ -140,13 +140,16 @@ if [ "X" = "X$pw_instance" ]; then
>> exit 1
>> fi
>>
>> -for I in travis github obs dummy; do
>> +for I in travis github obs cirrus dummy; do
> ok
>>
>> token=${I}_token
>> disable=disable_${I}
>>
>> if [ "X${!disable}" = "Xyes" ]; then
>> + echo "Skiping ${I}"
>> continue
>> + else
>> + echo "Scanning ${I}"
>> fi
>>
>> ./${I}_mon $pw_instance ${!token} "$pw_project" | grep "^pw|" | while IFS="|" \
>> @@ -163,6 +166,7 @@ for I in travis github obs dummy; do
>>
>> patch_id="$(get_patch_id_by_series_id_and_sha "$series_id" "$shasum" "$pw_chk_instance")"
>> if [ "X$patch_id" == "X" ]; then
>> + echo "No patchid..."
>> patch_id=$(echo $PATCHDATA | jq -rc '.patches[-1].id')
>> fi
>> PATCHDATA="$(echo "$PATCHDATA" | jq ".patches[] | select(.id==$patch_id)")"
>> diff --git a/cirrus_mon b/cirrus_mon
>> new file mode 100755
>> index 0000000..f307961
>> --- /dev/null
>> +++ b/cirrus_mon
>
> I agree with your commit message. This is very much like the github
> and travis pulling. A lot of stuff that's similar to those scripts.
>
> So most of my questions are based on the cirrus specific workflow. It
> has been a while since I have worked with cirrus
Okay
>> @@ -0,0 +1,100 @@
>> +#!/bin/bash
>> +# SPDX-Identifier: gpl-2.0-or-later
>> +# Copyright (C) 2023, Red Hat, Inc.
>> +#
>> +# Monitors cirrus build history for builds in a series.
>> +# Records the builds in the series database (and emits them on the
>> +# stdout line for processing)
>> +#
>> +# Licensed under the terms of the GNU General Public License as published
>> +# by the Free Software Foundation; either version 2 of the License, or
>> +# (at your option) any later version. You may obtain a copy of the
>> +# license at
>> +#
>> +# https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
>> +#
>> +# Unless required by applicable law or agreed to in writing, software
>> +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
>> +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
>> +# License for the specific language governing permissions and limitations
>> +# under the License.
>> +
>> +[ -f "$(dirname $0)/series_db_lib.sh" ] && source "$(dirname $0)/series_db_lib.sh"
>> +
>> +while [ "$1" != "" ]; do
>> + if echo "$1" | grep -q -s -E ^--pw-instance= ; then
>> + pw_instance=$(echo "$1" | sed s/^--pw-instance=//)
>> + shift
>> + elif echo "$1" | grep -q -s -E ^--cirrus-token= ; then
>> + cirrus_token=$(echo "$1" | sed s/^--cirrus-token=//)
>> + shift
>> + elif echo "$1" | grep -q -s -E ^--help ; then
>> + echo "Cirrus CI monitor script"
>> + echo "$0: args"
>> + echo "Required if not set in ~/.pwmon-rc file:"
>> + echo " --pw-instance=<inst url> URL for pw"
>> + echo ""
>> + echo "Options:"
>> + echo " --cirrus-token=<token> Sets tokenfor web requests"
> s/tokenfor/token for/
>> + echo ""
>> + exit 0
>> + elif ! echo "$1" | grep -q -s -E ^-- ; then
>> + break
>> + fi
>> +done
>> +
>> +echo "scanning started " >> /tmp/cirrus.log
>> +
>> +if [ "X" = "X$pw_instance" ]; then
>> + pw_instance="$1"
>> + shift
>> +fi
>> +
>> +if [ "X" = "X$github_token" ]; then
> How come cirrus needs a github token? Sorry, it's been a while since I
> used cirrus. Are cirrus builds based on github commits?
I'll double check - IIRC, cirrus uses the github token as a log in, but
it might be a bad variable name.
>> + github_token="$1"
>> + shift
>> +fi
>> +
>> +if [ "X" = "X$pw_project" -a "X$1" != "X" ]; then
>> + pw_project="$1"
>> + shift
>> +fi
>> +
>> +if [ "X$cirrus_token" != "X" ]; then
>> + AUTH="-H \"Authorization: Bearer $cirrus_token\""
>> +fi
>> +
>> +ci_instance="cirrus_sync"
>> +
>> +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 obs_sync
>> cirrus_sync; do
>> + repo_owner=$(echo "$repo_name" | cut -d/ -f1)
>> + repo_real=$(echo "$repo_name" | cut -d/ -f2)
>> +
>> + graph_string="{ \"query\": \"query BuildBySHAQuery(\$owner:
>> String!, \$name: String!, \$SHA: String){
>> searchBuilds(repositoryOwner: \$owner, repositoryName: \$name, SHA:
>> \$SHA) { id, status } }\", \"variables\": { \"owner\":
>> \"$repo_owner\", \"name\": \"$repo_real\", \"SHA\": \"$sha\" } }"
>> + build_details=$(curl -s "$AUTH" -X POST --data "$graph_string"
>> https://api.cirrus-ci.com/graphql)
> My other question regarding cirrus workflow was this. Normally with
> github we would have a direct URL to the project, e.g.
> github.com/ovsrobot/ovs, but I dont see anything like
> "cirrus.com/ovsrobot/ovs". Maybe that inmbeded in one of the
> variables? or is this why we have the query string using the variables
> repo_owner and repo_real? If that's the case then it's a shame cirrus
> doesnt have a direct API call into the project itself
Cirrus doesn't do API calls like that. Instead, we need to use GraphQL
to make requests. The whole API is documented, but there are parts of
it that surely need more details than others.
Actually, the reason that this first pass doesn't break out all the jobs
is because the GraphQL queries have to get a bit complex to build that
detail up. It makes the API very powerful, but also very difficult to
work with for simple stuff.
>> +
>> + id=$(echo "$build_details" | jq -rc '.data.searchBuilds[-1].id')
>> + status=$(echo "$build_details" | jq '.data.searchBuilds[-1].status')
>> + build_url="https://cirrus-ci.com/build/$id"
>> +
>> + result="in-progress"
>> + if [ "$status" == "\"COMPLETED\"" ]; then
>> + result="passed"
>> + elif [ "$status" == "\"FAILED\"" ]; then
>> + result="failed"
>> + elif [ "$status" == "\"ABORTED\"" ]; then
>> + set_synced_patch "$patch_id" "$patchwork_instance" "$ci_instance"
>> + echo "CIRRUS patch_id=$patch_id belonging to series=$series_id on
>> $patchwork_instance was aborted" 1>$2
>> + continue
>> + elif [ "$status" == "\"ERRORED\"" ]; then
>> + result="warn"
>> + fi
>> +
>> + if [ "$result" == "in-progress" ]; then
>> + echo "CIRRUS patch_id=$patch_id belonging to series=$series_id is
>> not completed[$status]. Skipping" 1>&2
>> + continue
>> + fi
>> +
>> + echo
>> "pw|$pw_instance|build|$series_id|SHA|$sha|$result|$build_url|$patch_name|$repo_name|$test_name"
> ok
>> +done
>> diff --git a/series_db_lib.sh b/series_db_lib.sh
>> index c5f42e0..e415870 100644
>> --- a/series_db_lib.sh
>> +++ b/series_db_lib.sh
>> @@ -130,6 +130,15 @@ recheck_sync INTEGER
>> EOF
>> run_db_command "INSERT INTO series_schema_version(id) values (8);"
>> fi
>> +
>> + # 0009 - cirrus CI data
>> + run_db_command "select * from series_schema_version;" | egrep '^9$' >/dev/null 2>&1
>> + if [ $? -eq 1 ]; then
>> + sqlite3 ${HOME}/.series-db <<EOF
>> +ALTER TABLE git_builds ADD COLUMN cirrus_sync INTEGER;
>> +EOF
>> + run_db_command "INSERT INTO series_schema_version(id) values (9);"
> ok
>> + fi
>> }
>>
>> function series_db_exists() {
>> @@ -379,7 +388,7 @@ function set_synced_for_series() {
>>
>> series_db_exists
>>
>> - echo "update git_builds set gap_sync=1, obs_sync=1 where patchwork_instance=\"$instance\" and series_id=$series_id;" | series_db_execute
>> + echo "update git_builds set gap_sync=1, cirrus_sync=1, obs_sync=1 where patchwork_instance=\"$instance\" and series_id=$series_id;" | series_db_execute
> ok
>> }
>>
>> function set_unsynced_for_series() {
>> @@ -402,7 +411,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, obs_sync) VALUES($series_id, $patch_id, \"$patch_url\", \"$patch_name\", \"$sha\", \"$instance\", \"$project\", \"$repo_name\", 0, 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, cirrus_sync) VALUES($series_id, $patch_id, \"$patch_url\", \"$patch_name\", \"$sha\", \"$instance\", \"$project\", \"$repo_name\", 0, 0, 0);" | series_db_execute
> ok
>> }
>>
>> function get_patch_id_by_series_id_and_sha() {
>
>> --
>> 2.41.0
>>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-01-19 14:51 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-12 16:08 [PATCH] cirrus: add an initial polling mechanism Aaron Conole
2024-01-11 18:37 ` Aaron Conole
2024-01-11 19:01 ` Ilya Maximets
2024-01-12 17:53 ` Aaron Conole
2024-01-11 19:36 ` Michael Santana
2024-01-15 20:00 ` Michael Santana
2024-01-19 14:51 ` Aaron Conole
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).