From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7B6C243C46; Tue, 5 Mar 2024 22:56:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 715D0402AC; Tue, 5 Mar 2024 22:56:30 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id D59BE40270 for ; Tue, 5 Mar 2024 22:56:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709675788; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+CBv4oWuYIXbjP5VifBw+cafdZNxSrFpy0CDcVLfdN0=; b=REkwtc8RHYFwr2AJfXl1Lv/IGRU75qFk6WWinqP3nKzJn7q32IzPhTyswUMgkQfEb2QHAO R8SszcfyYzLBBCrn24tDpf2+8ktLQFJ4h6a8UE8qZbfkzmYtDP/ygALgsmOc+A5WRU6shC QPAnmYxomI68M8I4E+SKjMH2BRN+8a4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-232-7Icb3f6gN2iFr2DG-N8P2Q-1; Tue, 05 Mar 2024 16:56:25 -0500 X-MC-Unique: 7Icb3f6gN2iFr2DG-N8P2Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D018A85A58C; Tue, 5 Mar 2024 21:56:24 +0000 (UTC) Received: from RHTPC1VM0NT.bos.redhat.com (dhcp-17-72.bos.redhat.com [10.18.17.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD4CF112131D; Tue, 5 Mar 2024 21:56:24 +0000 (UTC) From: Aaron Conole To: ci@dpdk.org Cc: Michael Santana , Ilya Maximets , Patrick Robb Subject: [PATCH v2] cirrus: Add an initial polling mechanism Date: Tue, 5 Mar 2024 16:56:24 -0500 Message-ID: <20240305215624.2517037-1-aconole@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: ci@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK CI discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ci-bounces@dpdk.org 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 --- v1->v2: Addressed comments from Ilya and Michael Added a User Agent to the curl command Tested with a few different patches Rebased on top of latest tree ci_mon | 5 ++- cirrus_mon | 103 +++++++++++++++++++++++++++++++++++++++++++++++ series_db_lib.sh | 13 +++++- 3 files changed, 118 insertions(+), 3 deletions(-) create mode 100755 cirrus_mon diff --git a/ci_mon b/ci_mon index 94ec1a3..81c80c3 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="|" \ diff --git a/cirrus_mon b/cirrus_mon new file mode 100755 index 0000000..0c60f67 --- /dev/null +++ b/cirrus_mon @@ -0,0 +1,103 @@ +#!/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= URL for pw" + echo "" + echo "Options:" + echo " --cirrus-token= Sets token for web requests" + echo "" + echo "Script invocation form (used by ci_mon):" + echo "$0 " + echo "" + echo " NOTE: For the script invocation from, pw_project is currently" + echo " ignored" + exit 0 + elif ! echo "$1" | grep -q -s -E ^-- ; then + break + fi +done + +if [ "X" = "X$pw_instance" -a "X$1" != "X" ]; then + pw_instance="$1" + shift +fi + +if [ "X" = "X$cirrus_token" -a "X$1" != "X" ]; then + cirrus_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 -A "(pw-ci) cirrus_mon" $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 0635469..4741d14 100644 --- a/series_db_lib.sh +++ b/series_db_lib.sh @@ -141,6 +141,15 @@ check_url STRING EOF run_db_command "INSERT INTO series_schema_version(id) values (9);" fi + + # 0010 - cirrus CI data + run_db_command "select * from series_schema_version;" | egrep '^10$' >/dev/null 2>&1 + if [ $? -eq 1 ]; then + sqlite3 ${HOME}/.series-db <