From patchwork Mon Nov 14 13:49:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 624820 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2691843pvb; Mon, 14 Nov 2022 17:02:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Yy2m6hC95Fvi+M0sw7Lz3fczYxf51YFJzfhgybqOFP8U7evuKLrZnGFLtYnkJ87Ofg17j X-Received: by 2002:a05:622a:1a28:b0:3a5:280a:3c9a with SMTP id f40-20020a05622a1a2800b003a5280a3c9amr14365632qtb.285.1668474171944; Mon, 14 Nov 2022 17:02:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668474171; cv=none; d=google.com; s=arc-20160816; b=wAyk3KFem1BjDhUeFxblkQ2Ih5sNqJ+1NnySMXN4jrvrBckE2EpYkgbcuA3V3Fm4T7 QtvItc7P4CME8waqZveQyeYWKMcCG1DT76LDzCpfjrqibb0Yh0sEAzZ7w91Y5qxvJdKW 0fxQfryKIzlLnP/SlgbdNSoi3DaEZXKMmcFg+YWpob9oGj9/AL86fitzkS9FDICJfYkf wplh662qSJQUSSFAZfiONdrKOcOrHLdvCC8WPoNEwHsa5ZhewwQkoXjn07aHF4zwC23o MX1Enkz1R6c6Iu029sC+unr0kH9eB/QwtQ+hg60nkG52UyScFA1J6DixdOo8xSTbVYie ITPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=NessA7feBX5JaP44J04zcRgMiQOjCRQhmP6PzLSK3Mw=; b=kMYW7VBijEMp7WP0zVAV7jX5OifsWavc7YgP/v/4da+RSpgg4MRJ7l5ZOx5rVSRZQM Q7Fu7H6WT4L1kydnOjkfL7Fo5pIknLpuwO7i93EBAQKzQ5KSq/FaubTMNMvhdF/l+xnc HtvNRGevxSZ3n686bUSCn08WyBTdtueyNuN74mtBWQyFGXYvj/6AbcxMZZIf2Qaux/HN nNeAbvjWIro9i7tzoSiUaSrFwJN+CSxv+njAyIP5jseb3vHkZhSOcn4phBeEEtBBGCyi c331tqcBP/Uu758Iv5YjvfrKi+SmjfGTBw4TzRFr+SAVMDAxYw6UjCk7HrZTjBusIe0X lhdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MBqohNsm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fb9-20020a05622a480900b00343a6e631c4si6699504qtb.764.2022.11.14.17.02.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Nov 2022 17:02:51 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MBqohNsm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouinr-00087F-6v; Mon, 14 Nov 2022 18:23:47 -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 1ouifG-0004Q9-DW for qemu-devel@nongnu.org; Mon, 14 Nov 2022 18:14:55 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ouZqd-000637-Ek for qemu-devel@nongnu.org; Mon, 14 Nov 2022 08:50:05 -0500 Received: by mail-wm1-x32f.google.com with SMTP id fn7-20020a05600c688700b003b4fb113b86so7962733wmb.0 for ; Mon, 14 Nov 2022 05:50:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=NessA7feBX5JaP44J04zcRgMiQOjCRQhmP6PzLSK3Mw=; b=MBqohNsmPGnZjZTDlfySJF8dgGl8w/6k8MAi6IpCM6rHKUswogzR8jyKQFqdaVS7p9 WB2Jzl5tesNfFggZB3RcHrvuPSE+iXD8SLvNEr4jpwlxXLNKh7Vdtx2nUCA/KxeNO5Ei OWM8js8r8tkLwM7U9OVzQJbDRBaatDjOJqMbdBKTYtzxpdDOVt+NVjXSOkJLILQKHreM f7pjPobl6ClrO5RviyObiJ2SH+ei6SOmEmvpjPNfktastqT7B59EF48GD50mjsJiAlmW QzCwOgGxQZ8ajbBPoz4Ju5tCSb7ZOuzSBXfrae2eiw1AGyS8XnE5dU/yfQBH6/0o7VbX qcUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NessA7feBX5JaP44J04zcRgMiQOjCRQhmP6PzLSK3Mw=; b=ttzGr/1GMcr+qoxy7tHW7YUW8WXjWvMLEbuH40cDDrosew0sftKzYkcam/HjLwPRkC A3f5oBX92QY7XQXktpOAhefCMegl/u/sk3nrMz6nv2vkdy9pbCNyXT79MWojh/t+cb07 Vw/pp488eamm0LAUJL4jvOS/JcI6PBJgDwA9DRiV4PbL6tzqXiFYd2a4unzEG3IYqpVg jG+GqjZqxcIuTX7FgFpI3mV+aeqYLl3ADu1XrcyUaegzkWVVndlYikShO4r0Mc7hF3S6 zTrbCu2+tdq85GCuzLFzRj3fr1uXxLCUBIVjzASRqhMpx0K84YRqmH9O6xcGqvaRNCXl 0CPQ== X-Gm-Message-State: ANoB5plPfu6IO+FyYGM3ReXMGT/w0gq+yxnZJCWdJ69AIuhIWwtx6BI/ I75RiwnkaL1n7wr7pcvGlIjH5w== X-Received: by 2002:a1c:26c1:0:b0:3cf:b1c2:c911 with SMTP id m184-20020a1c26c1000000b003cfb1c2c911mr7819038wmm.16.1668433801430; Mon, 14 Nov 2022 05:50:01 -0800 (PST) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id n4-20020a7bc5c4000000b003c6c182bef9sm22195137wmk.36.2022.11.14.05.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 05:50:00 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 67D401FFB7; Mon, 14 Nov 2022 13:49:59 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: fam@euphon.net, berrange@redhat.com, f4bug@amsat.org, aurelien@aurel32.net, pbonzini@redhat.com, stefanha@redhat.com, crosa@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth , Wainer dos Santos Moschetta , Beraldo Leal Subject: [RFC PATCH] gitlab: add new dynamic check-gcov target for coverage Date: Mon, 14 Nov 2022 13:49:54 +0000 Message-Id: <20221114134954.1670860-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The aim of this was to expand the coverage checking to only target builds affected by the current branch. Unfortunately first time out the build falls over at the asset uploading stage exceeding some size limit. So for now I'm posting this as a proof-of-concept until I can figure out a better way forward. The highlighting of which changes are tested in the GitLab UI is quite nice though. Signed-off-by: Alex Bennée --- .gitlab-ci.d/buildtest.yml | 24 ++++++++-- .gitlab-ci.d/pick-targets.py | 87 ++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 4 deletions(-) create mode 100755 .gitlab-ci.d/pick-targets.py diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml index d21b4a1fd4..aa2c52ab11 100644 --- a/.gitlab-ci.d/buildtest.yml +++ b/.gitlab-ci.d/buildtest.yml @@ -479,20 +479,36 @@ build-gprof-gcov: variables: IMAGE: ubuntu2004 CONFIGURE_ARGS: --enable-gprof --enable-gcov - TARGETS: aarch64-softmmu ppc64-softmmu s390x-softmmu x86_64-softmmu + TARGETS: aarch64-softmmu ppc64-linux-user artifacts: expire_in: 1 days paths: - build -check-gprof-gcov: +# This is special as the target list is dynamic +build-gcov: + extends: .native_build_job_template + needs: + job: amd64-ubuntu2004-container + before_script: + - TARGETS=$(.gitlab-ci.d/pick-targets.py) + variables: + IMAGE: ubuntu2004 + CONFIGURE_ARGS: --enable-gcov + artifacts: + expire_in: 1 days + paths: + - build + +# This is special +check-gcov: extends: .native_test_job_template needs: - - job: build-gprof-gcov + - job: build-gcov artifacts: true variables: IMAGE: ubuntu2004 - MAKE_CHECK_ARGS: check + MAKE_CHECK_ARGS: check check-avocado after_script: - cd build - gcovr --xml-pretty --exclude-unreachable-branches --print-summary diff --git a/.gitlab-ci.d/pick-targets.py b/.gitlab-ci.d/pick-targets.py new file mode 100755 index 0000000000..db1eff0119 --- /dev/null +++ b/.gitlab-ci.d/pick-targets.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python3 +# +# pick-targets: pick a set of targets that are worth testing. +# +# Running code coverage is too expensive to run over all the builds. +# Try and figure out a subset of targets that would be worth running +# for the files touched between origin/master and the current HEAD. +# +# Copyright (C) 2022 Linaro Ltd +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +import os.path +import sys +import subprocess + +# Dumb mapping from a target directory name to a list of +# targets. Should we bother for those we know we don't have compilers for? +multi_targets = { + 'arm' : ['arm', 'aarch64'], + 'i386' : ['i386', 'x86_64'], + 'microblaze' : ['microblaze' ], # no softmmu, 'microblazel' ], + 'mips' : ['mips', 'mips64', 'mips64el', 'mipsel' ], + 'ppc' : ['ppc', 'ppc64' ], + 'riscv' : ['riscv32', 'riscv64'], + 'sh4' : ['sh4', 'sh4eb'], + 'sparc' : ['sparc', 'sparc64'], + 'xtensa' : ['xtensa', 'xtensaeb'] +} + +def map_dir_to_targets(name): + if name in multi_targets: + return multi_targets[name] + else: + return name + +namespace = "qemu-project" +if len(sys.argv) >= 2: + namespace = sys.argv[1] + +cwd = os.getcwd() +reponame = os.path.basename(cwd) +repourl = f"https://gitlab.com/{namespace}/{reponame}" + +# Add remote, fetch master and save the common ancestor +subprocess.check_call(["git", "remote", "add", "pick-target", repourl]) +subprocess.check_call(["git", "fetch", "pick-target", "master"], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL) + +ancestor = subprocess.check_output(["git", "merge-base", + "pick-target/master", "HEAD"], + universal_newlines=True) + +ancestor = ancestor.strip() + +subprocess.check_call(["git", "remote", "rm", "pick-target"]) + +# calculate the diff and extract list of touched files +diff = subprocess.check_output(["git", "diff", "--numstat", + f"{ancestor}..HEAD"]) + +files = [l.split("\t")[2] for l in diff.decode().split("\n") if "\t" in l] + +# Build options to track +system = False +user = False +targets = [] + +for f in files: + if f.startswith("hw"): + system = True + if f.startswith("linux-user"): + user = True + if f.startswith("target"): + t = f.split("/")[1] + targets.extend(map_dir_to_targets(t)) + +target_list = [] +for t in sorted(set(targets)): + if system: + target_list.append(f"{t}-softmmu") + if user: + target_list.append(f"{t}-linux-user") + +print(" ".join(target_list))