From nobody Tue Feb 10 10:59:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709921617; cv=none; d=zohomail.com; s=zohoarc; b=BNRd/dVgSFRpyIhPbtDw/+9W32nzjEl1blJAAQ/cOCK32QmyUzmjmP4bdW8XLqFePjupPmnco65Nahxa0Wo1IzhtdIfgS7GVv8vfb5qWltSzvRnKMNzc1Gev/im3ASH6/7VSz/V6oGoumawGdtNhdD4bU4/QTAnuXYtYKxPOTjY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709921617; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Wm7tvlRtPpXlePloTVjRajx+JpxbgNJey9a3Qa3vQcU=; b=ethxhQnOuDOBFK0vi6x0lYl7vy02EkCvJ9T91UGaHegLSaKJ7N6CBpxRxtYhFgWo2kN66cxMzJn8ecnGC7tswo/6UkTBb5F10XLf4fdA2nUvD83b/rIKaBWp3b5pnMytI7XZBHoh3fLlQlnGcpw0v85NXgvrzi8OSUjN7zVgQ7A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709921617551557.7228818612031; Fri, 8 Mar 2024 10:13:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riehu-0007Fd-B3; Fri, 08 Mar 2024 13:12:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riehs-0007Ds-SG for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riehr-0005qF-1J for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:32 -0500 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-619-1CleVlx5OgytrLIznhq_gA-1; Fri, 08 Mar 2024 13:12:29 -0500 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a45ac612a4dso363314166b.0 for ; Fri, 08 Mar 2024 10:12:27 -0800 (PST) Received: from [192.168.10.118] ([151.49.77.21]) by smtp.gmail.com with ESMTPSA id i10-20020a1709061cca00b00a3f28bf94f8sm33677ejh.199.2024.03.08.10.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 10:12:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709921550; 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: in-reply-to:in-reply-to:references:references; bh=Wm7tvlRtPpXlePloTVjRajx+JpxbgNJey9a3Qa3vQcU=; b=dhxu0xCN71SuqofWqGWggFIyXm8mDsKjmBAMwJO5AKchGLqd2meJME6AXZZ6Lb+Q6TZNch 9Rgk6ub/TndScO5egb0SXJMlz3QGNhR1zeMdsopbILr+qlqLD5qRPcsj1iwOdPJ+wJZJZa j/oqmc8BYcegIis/YV7zunHLs5uMQiY= X-MC-Unique: 1CleVlx5OgytrLIznhq_gA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709921545; x=1710526345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wm7tvlRtPpXlePloTVjRajx+JpxbgNJey9a3Qa3vQcU=; b=tOLmAvKc+hV+pXaWqNHGEnPIdv5ycWGxwlL4TuSPfOVoHj1hyyXoJ5APbk4vPb3DrC a1Dr8FrivppOtcFxtRnm52TGZOPog9rniWnuUN7gWWfbvAtTI7EBZ9iWTVob+6mFYWJb qyqpg/jS2HXjK9f2SELZl5vIqLj158l2E7G9eo7vtfjpONJDvkvqNktoh124ECr4jcoJ i+v4Hgqje2NxHe7lV1DNzTFhKWjA7dUlKosj9GcETLA+EHnc+JRXM/DxIcme4Oh/JAYH m18elgQILS5De536+qcr/BaAk3556izsDV2OnZyEhYi9Xvx6v+gNWFG7YygqaUEcVaT2 YnpA== X-Gm-Message-State: AOJu0YyU7/4HR3g0xu9AgpLZ1xWesWvgwNk8lS/Ei0jfDy9Ld+P1pPNT c9k5iiQ2DZECrF5nrPSF5Dl83R9gJD2+YnKC49RHC2xaoPGAKT0nqBRfdqWoswTzn7SwT3pD9CF fVe8VzBFyHXrIxmPWzlNKYjBrouzr0JFuCwy/+SqWoUcRyuGyZatf2BdSKJ/8J8LUXTnXUwCnVd 2DeCzEzCHYV3mESWaG1pFyroWH+deKufbsegSI X-Received: by 2002:a17:906:68cd:b0:a45:af32:5e04 with SMTP id y13-20020a17090668cd00b00a45af325e04mr932649ejr.30.1709921545333; Fri, 08 Mar 2024 10:12:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IFoKUVenB5vA3VAfgooEXYtn6mNCEfmcVmEISv/gHiJ7o8U/9ZpLQtOH+7LnWWZJhZYbU+xug== X-Received: by 2002:a17:906:68cd:b0:a45:af32:5e04 with SMTP id y13-20020a17090668cd00b00a45af325e04mr932636ejr.30.1709921544992; Fri, 08 Mar 2024 10:12:24 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Peter Maydell Subject: [PULL 8/9] run-coverity-scan: add --check-upload-only option Date: Fri, 8 Mar 2024 19:12:00 +0100 Message-ID: <20240308181202.617329-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240308181202.617329-1-pbonzini@redhat.com> References: <20240308181202.617329-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709921619536100007 Content-Type: text/plain; charset="utf-8" Add an option to check if upload is permitted without actually attempting a build. This can be useful to add a third outcome beyond success and failure---namely, a CI job can self-cancel if the uploading quota has been reached. There is a small change here in that a failure to do the upload check changes the exit code from 1 to 99. 99 was chosen because it is what Autotools and Meson use to represent a problem in the setup (as opposed to a failure in the test). Reviewed-by: Peter Maydell Signed-off-by: Paolo Bonzini --- scripts/coverity-scan/run-coverity-scan | 59 ++++++++++++++++++------- 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/scripts/coverity-scan/run-coverity-scan b/scripts/coverity-sca= n/run-coverity-scan index d56c9b66776..43cf770f5e3 100755 --- a/scripts/coverity-scan/run-coverity-scan +++ b/scripts/coverity-scan/run-coverity-scan @@ -28,6 +28,7 @@ # project settings, if you have maintainer access there. =20 # Command line options: +# --check-upload-only : return success if upload is possible # --dry-run : run the tools, but don't actually do the upload # --docker : create and work inside a container # --docker-engine : specify the container engine to use (docker/podman/a= uto); @@ -57,18 +58,18 @@ # putting it in a file and using --tokenfile. Everything else has # a reasonable default if this is run from a git tree. =20 -check_upload_permissions() { - # Check whether we can do an upload to the server; will exit the script - # with status 1 if the check failed (usually a bad token); - # will exit the script with status 0 if the check indicated that we - # can't upload yet (ie we are at quota) - # Assumes that COVERITY_TOKEN, PROJNAME and DRYRUN have been initializ= ed. +upload_permitted() { + # Check whether we can do an upload to the server; will exit *the scri= pt* + # with status 99 if the check failed (usually a bad token); + # will return from the function with status 1 if the check indicated + # that we can't upload yet (ie we are at quota) + # Assumes that COVERITY_TOKEN and PROJNAME have been initialized. =20 echo "Checking upload permissions..." =20 if ! up_perm=3D"$(wget https://scan.coverity.com/api/upload_permitted = --post-data "token=3D$COVERITY_TOKEN&project=3D$PROJNAME" -q -O -)"; then echo "Coverity Scan API access denied: bad token?" - exit 1 + exit 99 fi =20 # Really up_perm is a JSON response with either @@ -76,25 +77,40 @@ check_upload_permissions() { # We do some hacky string parsing instead of properly parsing it. case "$up_perm" in *upload_permitted*true*) - echo "Coverity Scan: upload permitted" + return 0 ;; *next_upload_permitted_at*) - if [ "$DRYRUN" =3D yes ]; then - echo "Coverity Scan: upload quota reached, continuing dry = run" - else - echo "Coverity Scan: upload quota reached; stopping here" - # Exit success as this isn't a build error. - exit 0 - fi + return 1 ;; *) echo "Coverity Scan upload check: unexpected result $up_perm" - exit 1 + exit 99 ;; esac } =20 =20 +check_upload_permissions() { + # Check whether we can do an upload to the server; will exit the script + # with status 99 if the check failed (usually a bad token); + # will exit the script with status 0 if the check indicated that we + # can't upload yet (ie we are at quota) + # Assumes that COVERITY_TOKEN, PROJNAME and DRYRUN have been initializ= ed. + + if upload_permitted; then + echo "Coverity Scan: upload permitted" + else + if [ "$DRYRUN" =3D yes ]; then + echo "Coverity Scan: upload quota reached, continuing dry run" + else + echo "Coverity Scan: upload quota reached; stopping here" + # Exit success as this isn't a build error. + exit 0 + fi + fi +} + + build_docker_image() { # build docker container including the coverity-scan tools echo "Building docker container..." @@ -152,9 +168,14 @@ update_coverity_tools () { DRYRUN=3Dno UPDATE=3Dyes DOCKER=3Dno +PROJNAME=3DQEMU =20 while [ "$#" -ge 1 ]; do case "$1" in + --check-upload-only) + shift + DRYRUN=3Dcheck + ;; --dry-run) shift DRYRUN=3Dyes @@ -251,6 +272,11 @@ if [ -z "$COVERITY_TOKEN" ]; then exit 1 fi =20 +if [ "$DRYRUN" =3D check ]; then + upload_permitted + exit $? +fi + if [ -z "$COVERITY_BUILD_CMD" ]; then NPROC=3D$(nproc) COVERITY_BUILD_CMD=3D"make -j$NPROC" @@ -266,7 +292,6 @@ if [ -z "$SRCDIR" ]; then SRCDIR=3D"$PWD" fi =20 -PROJNAME=3DQEMU TARBALL=3Dcov-int.tar.xz =20 if [ "$UPDATE" =3D only ]; then --=20 2.43.2