From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id GJjxEhyELmfLSgEAe85BDQ:P1 (envelope-from ) for ; Fri, 08 Nov 2024 21:35:24 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id GJjxEhyELmfLSgEAe85BDQ (envelope-from ) for ; Fri, 08 Nov 2024 22:35:24 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=f9VeXMRQ; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20230601 header.b="FaNW/KHf"; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1731101724; h=from:from:sender:sender: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:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=nSDZLXYcW3L2pgOV9KecQ3Rl2zvPJJ1E1LFO6V2n00M=; b=JAxspOM9vT08ulzy4kbJmjSxN8poyXAC8IocZXmn4PyIjLHpQDJZ53GmQ1r9mr+TRUFvWn WkrbE+b9zc/BFh+q1y8F54jQWGj0eSK+lCA2vdH9RArrksj/EPy22IMG5luNqQwQoCzlCR 1B8cY807FqGipYMs9GuJZYq0WMb1dPedQDgmTXwd2YsmTS2BJZ8+zvqBKqXAQFBuXfsdEK 1M1pcEaVqDpGZTLB6THceLd+wsZ1VeUh3oCeyK0z1v+SRSSvb+VZLROnl9NBIc8cHCWQ5Z emaoOyhTha2UfxxeqokC788XQHV/lLoePB7WdgICSg7a64MboPDal4eavdVK3w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1731101724; a=rsa-sha256; cv=none; b=OncL4J7V+hi/XBJb34McVErOb+5LoMjVFrFXpmNfi7RFW+4K1WmQRNewE8NhtQGMudlxRj RIGNMKf/5ApjQ4r6Fq5IJJKU1QDxeNxByjAOLc2Mvq6VSq4EQi0V8t8quZZjNcfxltOD5X fomFOqxOVAKRQQy2HOyTGNbjo7O3my0Ftcxl0yyHGqFjjw5+4UYB/gej58KKBUsch+UjD/ D4+pfVK2v8qa+kM/mnl8vk1n+rnOgwrxDdSfZmMlNGXV4wegBVkhRvio+dUoqBgde+5pgu +oEmhIomeTC8KB3frbVTTfOQcr6dsVA9EqOT/yfEWDEGe/me//qOo5HlxKtINg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=f9VeXMRQ; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20230601 header.b="FaNW/KHf"; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 8F062784B4 for ; Fri, 08 Nov 2024 22:35:23 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9WdE-0003g6-8n; Fri, 08 Nov 2024 16:35:04 -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 1t9WdC-0003fq-St for guix-patches@gnu.org; Fri, 08 Nov 2024 16:35:02 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t9WdC-0000XS-IE for guix-patches@gnu.org; Fri, 08 Nov 2024 16:35:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=UmSCZzV1+O3cUp3OiEwHQX6TCgLSeNy4F6RDQLapFeI=; b=f9VeXMRQepkLu69rLnSxxMPvWKnXIIhLpAM9t5szG0sQq5zVt6HINd6lSPBlwb3LkB4vOgB75OQ5tS8uWHdSkYEjiv1l+h0veO/CbxctTc6yQUPGv7iQTlg2tLxY2uWAuM0zX25EwxDgjHGWL3hJYLV5aRyYQBnLQ0/i6vmwnL+o0gR2DSbuzTuTZy0fKRt34EtfjWNxBX5OM3/02M/mlq6UCk+FQHpiYu6LynaHcUyQamcLKoKpba8/6I3YSOt8b0JH7LebPP6bIL39mO523fVGsdsbzgQgzhQSwvU2758Ohca7ytn3gJZZoW4dIEp/8ICs69Je8bhq1ISv0SoWOQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t9WdC-0003ve-CH for guix-patches@gnu.org; Fri, 08 Nov 2024 16:35:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74268] [PATCH 1/1] etc: Add teams-packages-stats script. Resent-From: Sharlatan Hellseher Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 08 Nov 2024 21:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74268 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74268@debbugs.gnu.org Cc: Sharlatan Hellseher Received: via spool by 74268-submit@debbugs.gnu.org id=B74268.173110165315038 (code B ref 74268); Fri, 08 Nov 2024 21:35:02 +0000 Received: (at 74268) by debbugs.gnu.org; 8 Nov 2024 21:34:13 +0000 Received: from localhost ([127.0.0.1]:52371 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t9WcO-0003uU-Gk for submit@debbugs.gnu.org; Fri, 08 Nov 2024 16:34:13 -0500 Received: from mail-wm1-f53.google.com ([209.85.128.53]:44474) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t9WcM-0003uG-GD for 74268@debbugs.gnu.org; Fri, 08 Nov 2024 16:34:11 -0500 Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4314fa33a35so21386265e9.1 for <74268@debbugs.gnu.org>; Fri, 08 Nov 2024 13:34:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731101585; x=1731706385; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UmSCZzV1+O3cUp3OiEwHQX6TCgLSeNy4F6RDQLapFeI=; b=FaNW/KHfGy5ZrFdVCMnR8AEewpdDcLHlM8VGXFyMoQzwKFTgQ7mO/nFdiY8o7S9fO2 oZZN6J5+ba4gcGFV6z/O55Bh9U8R5bO+UAQSbytoKh+VurgfxU2fJ8nrlxNpBVhfpwRC AcH9ePSkSKWCctdLwjuJ4QzH77367cu9TUSWkmVYBVRWIlFEgwL33COwa3obTXWzdFSj 0MrjiKVtDEU9N91dRBP153N2NGCOsVLKbl0kNKdDt/fGXbvhyLWq94mJ3QkQZmin1NHd bzgvhLaoDa7MoGfTvNRMKznSiwESzxzmqY+WFRvU4pkmPJHzH8aaou5fn17WQKVizTiU QpHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731101585; x=1731706385; 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=UmSCZzV1+O3cUp3OiEwHQX6TCgLSeNy4F6RDQLapFeI=; b=oljGdkYQHToyjGMEq7TXKBU16kVWWyLPbZ9fyZNfogG89TF4mFbijoQy7YTcj5yZrn 4JeUEmmsbpRabb458N2rkyT8Cwx3PIQo8JRwwnG47miUpULOjSJxXMcX2D2qwlKZrFjz hfLqCrLa6s4OczHSwuNBv713l2EBfisz3YhqCgDhVzSYyU7O6bme9EgyTYmZZcGU8pev 2+8MSxmwrxSQs0D5w69YiNZLG+/RNlX64mIWFGWEvLzHPo/iPS6wOpsaOdSFHRlu+2k1 DvX07npkOhBHpxK0lMvKcfPWQ+7rD8S8w+vr3xLDoHQ7ULx+b6kxVZhdgr8JQ/n44pBM 974g== X-Gm-Message-State: AOJu0Yyo/+/bQXSPyZ0Wf9+Wh8cN2pHOTIhK4IMEeZ2Xqrm7KXPtYDpr dgalDj70Hf9Vbu4QGEaMAqyhgDscuTtW5FeLZ7h8LtB5mV6RWJl44J6CAO7l X-Google-Smtp-Source: AGHT+IE1PPbT8Hb7u/U3bT96i+lDovIJL2YsFiNJQzNuoF5WXKUyCGht7NJswL5kTWYv65semmjg+Q== X-Received: by 2002:a05:600c:3b1f:b0:42c:b80e:5e50 with SMTP id 5b1f17b1804b1-432b7490d35mr40058475e9.0.1731101584375; Fri, 08 Nov 2024 13:33:04 -0800 (PST) Received: from guxtil.incerto.xyz (cpc100684-bagu15-2-0-cust967.1-3.cable.virginm.net. [86.8.111.200]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432aa73a2d8sm115911135e9.41.2024.11.08.13.33.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 13:33:03 -0800 (PST) From: Sharlatan Hellseher Date: Fri, 8 Nov 2024 21:32:59 +0000 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: 8.85 X-Migadu-Spam: Yes X-Migadu-Queue-Id: 8F062784B4 X-Spam: Yes X-Migadu-Scanner: mx13.migadu.com X-Spam-Score: 8.85 X-TUID: sA8SIKmBWJBv This is a proposal of the helper script which aims to asist in decision making during cascade packages refresh task in the team scope. * etc/teams-packages-stats.scm: New file. Change-Id: I4af5ce1c3cbebed1793628229b29acba1f737c9d --- etc/teams-packages-stats.scm | 218 +++++++++++++++++++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100755 etc/teams-packages-stats.scm diff --git a/etc/teams-packages-stats.scm b/etc/teams-packages-stats.scm new file mode 100755 index 0000000000..a95d913a79 --- /dev/null +++ b/etc/teams-packages-stats.scm @@ -0,0 +1,218 @@ +#!/bin/sh +# -*- mode: scheme; -*- +# Extra care is taken here to ensure this script can run in most environments, +# since it is invoked by 'git send-email'. +pre_inst_env_maybe= +command -v guix > /dev/null || pre_inst_env_maybe=./pre-inst-env +exec $pre_inst_env_maybe guix repl -- "$0" "$@" +!# + +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2024 Sharlatan Hellseher +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +;;; This file returns a manifest containing origins of all the packages. The +;;; main purpose is to allow continuous integration services to keep upstream +;;; source code around. It can also be passed to 'guix weather -m'. + +;;; Commentary: + +;; This code defines helpers for cascade packages refresh withing team scopes. +;; The output may be piped to CLI commands like awk, column to compile a +;; dataframe (e.g. JSON). +;; +;; ~$ column \ +;; --json \ +;; --table \ +;; --separator=, \ +;; --table-columns=module-file-name,build-system-name,package-name,\ +;; package-guix-version,package-upstream-version,all-inputs-count,\ +;; dependents-count,affect-ratio \ +;; \ +;; > .json +;; +;; TODO: +;; - Implement manifests per team on some gradual criterias +;; - Add more controls via command-line options +;; - Improve the performance of dependents calculation, it takes about 30min +;; to provide a list for packages with python/pyproject build system +;; - Add save as JSON,CSV data formats for father analysis + + +;;; Code: + +(use-modules (git) + (gnu packages) + (guix build-system) + (guix diagnostics) + (guix discovery) + (guix gnupg) + (guix graph) + (guix hash) + (guix monads) + (guix packages) + (guix profiles) + (guix scripts graph) + (guix scripts) + (guix store) + (guix ui) + (guix upstream) + (guix utils) + (ice-9 format) + (ice-9 match) + (ice-9 rdelim) + (ice-9 regex) + (srfi srfi-1) + (srfi srfi-26) + (srfi srfi-37) + (srfi srfi-71) + (srfi srfi-9)) + +(define* (packages-by-team #:key (team "all")) + "Return the list of packages for the TEAM by certain criteria or fail over +to all packages available." + (cond + ((string=? team "go") + (fold-packages + (lambda (package result) + (if (or (eq? (build-system-name (package-build-system package)) + (quote go)) + ;; XXX: Add other checks such Go is in inputs*. + ) + (cons package result) result)) (list))) + ((string=? team "python") + (fold-packages + (lambda (package result) + (if (or (eq? (build-system-name (package-build-system package)) + (quote pyproject)) + (eq? (build-system-name (package-build-system package)) + (quote python))) + (cons package result) result)) (list))) + ((string=? team "ruby") + (fold-packages + (lambda (package result) + (if (or (eq? (build-system-name (package-build-system package)) + (quote ruby)) + ;; XXX: Add other checkes such Ruby is in inputs*. + ) + (cons package result) result)) (list))) + (else + (fold-packages + (lambda (package result) + (if (package-superseded package) + result + (cons package result))) + '() + #:select? (const #true))))) + +(define (dependents-count package) + "Return the count of requiring rebuild packages when PACKAGE is updated." + (with-error-handling ;; XXX: Taken from guix scripts refresh + (with-store store + (run-with-store store + (mlet %store-monad ((edges + (node-back-edges %bag-node-type + (package-closure (packages-by-team))))) + (let* ((dependents + (node-transitive-edges (list package) edges))) + (return (length dependents)))))))) + +(define* (stats team + #:key (build-systems '()) + (check-dependents? #false) + (check-deprecated? #false) + (check-upstream-version? #false) + (dependents-threshold-ratio 0.001) + (inputs-threshold 0)) + "Return a detailed stats for the given TEAM packages which may help to make +a decision during cascade updates. + +Parameters: +- build-system :: The optional list of build system names to select. + +- check-dependents? :: Whether to query or not the dependents count, it might +take time for a long list of provided packages. + +- check-deprecated? :: Whether to show or not the deprecated packages. + +- check-upstream-version? :: Check for the latest available version on +upstream. + +- dependents-threshold-ratio :: Print out only packages which dependent count +ration is bigger or equal given threshold. (dependents/all-packages * 100.0). + +- inputs-threshold :: The minimum number of inputs which package needs to +have. + +Returns: +- module-file-name +- build-system-name +- package-name +- package-guix-version +- package-upstream-version +- all-inputs-count +- dependents-count +- affect-ratio" + (let ((team-packages (packages-by-team #:team team)) + (all-packages-count (length (packages-by-team)))) + (map (lambda (package) + (let ((all-inputs-count + (+ (length (package-inputs package)) + (length (package-native-inputs package)) + (length (package-propagated-inputs package)))) + (module-path + (false-if-exception + (location-file (package-definition-location package)))) + (build-system-name + (build-system-name (package-build-system package)))) + (if (>= all-inputs-count inputs-threshold) + (let* ((dependents + (if check-dependents? + (dependents-count package) + "nil")) + (affect-ratio + (if check-dependents? + (* (/ dependents all-packages-count) 100.0) + "nil"))) + (format #true "~{~a,~}~8f~%" + (list + (if (string? module-path) + module-path + "deprecated-package") + build-system-name + (package-name package) + (package-version package) + (if check-upstream-version? "TBA" "nil") + all-inputs-count + dependents) + affect-ratio))))) + team-packages))) + +(define (main . args) + (match args + (("stats" . team-name) + (apply (stats (car team-name) #:check-dependents? #true))) + (anything + (format (current-error-port) + "Usage: etc/teams-packages-stats.scm [] + +Commands:~ + stats + get a list of packages belonging to the given with basic + affect ratio, which may help to plan cascade packages refresh task.%")))) + +(apply main (cdr (command-line))) -- 2.46.0