From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (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 finch.gentoo.org (Postfix) with ESMTPS id 61B1F158041 for ; Thu, 7 Mar 2024 16:06:57 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5F172E29BD; Thu, 7 Mar 2024 16:06:56 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 36565E29BD for ; Thu, 7 Mar 2024 16:06:56 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0B55234306E for ; Thu, 7 Mar 2024 16:06:55 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3459F1049 for ; Thu, 7 Mar 2024 16:06:53 +0000 (UTC) From: "Arthur Zamarin" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Arthur Zamarin" Message-ID: <1709363706.2ed2a36a62f3bb9801c187c053ec67ec6bb47565.arthurzam@gentoo> Subject: [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, tests/checks/ X-VCS-Repository: proj/pkgcore/pkgcheck X-VCS-Files: src/pkgcheck/checks/git.py tests/checks/test_git.py X-VCS-Directories: tests/checks/ src/pkgcheck/checks/ X-VCS-Committer: arthurzam X-VCS-Committer-Name: Arthur Zamarin X-VCS-Revision: 2ed2a36a62f3bb9801c187c053ec67ec6bb47565 X-VCS-Branch: master Date: Thu, 7 Mar 2024 16:06:53 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 05a5c0b7-ce41-4b1d-b8cf-16a8d54fcb8f X-Archives-Hash: e3bfbc965517874e0eb109fa23dd652e commit: 2ed2a36a62f3bb9801c187c053ec67ec6bb47565 Author: Arthur Zamarin gentoo org> AuthorDate: Sat Mar 2 07:13:16 2024 +0000 Commit: Arthur Zamarin gentoo org> CommitDate: Sat Mar 2 07:15:06 2024 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=2ed2a36a NewerEAPIAvailable: committing new ebuilds with old EAPI Catch cases where new ebuilds are committed with old EAPIs. This is checked during `--commits` stage. Resolves: https://github.com/pkgcore/pkgcheck/issues/666 Signed-off-by: Arthur Zamarin gentoo.org> src/pkgcheck/checks/git.py | 45 +++++++++++++++++++++++++++++++++++++++++++-- tests/checks/test_git.py | 2 +- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/pkgcheck/checks/git.py b/src/pkgcheck/checks/git.py index 31f1dc69..a2619491 100644 --- a/src/pkgcheck/checks/git.py +++ b/src/pkgcheck/checks/git.py @@ -236,6 +236,23 @@ class OldPythonCompat(results.VersionResult, results.Warning): return f"old PYTHON_COMPAT target{s} listed: [ {targets} ]" +class NewerEAPIAvailable(results.VersionResult, results.Warning): + """Package is eligible for a newer EAPI. + + A new package version was added, using an older EAPI, than all supported by + inherited eclasses. You should consider bumping the EAPI to the suggested + value. + """ + + def __init__(self, eapi: int, **kwargs): + super().__init__(**kwargs) + self.eapi = eapi + + @property + def desc(self): + return f"ebuild eligible for newer EAPI={self.eapi}" + + class _RemovalRepo(UnconfiguredTree): """Repository of removed packages stored in a temporary directory.""" @@ -295,7 +312,7 @@ class GitPkgCommitsCheck(GentooRepoCheck, GitCommitsCheck): """Check unpushed git package commits for various issues.""" _source = (sources.PackageRepoSource, (), (("source", GitCommitsRepoSource),)) - required_addons = (git.GitAddon,) + required_addons = (git.GitAddon, sources.EclassAddon) known_results = frozenset( { DirectStableKeywords, @@ -311,6 +328,7 @@ class GitPkgCommitsCheck(GentooRepoCheck, GitCommitsCheck): PythonPEP517WithoutRevbump, EAPIChangeWithoutRevbump, OldPythonCompat, + NewerEAPIAvailable, } ) @@ -321,12 +339,13 @@ class GitPkgCommitsCheck(GentooRepoCheck, GitCommitsCheck): # package categories that are committed with stable keywords allowed_direct_stable = frozenset(["acct-user", "acct-group"]) - def __init__(self, *args, git_addon: git.GitAddon): + def __init__(self, *args, git_addon: git.GitAddon, eclass_addon: sources.EclassAddon): super().__init__(*args) self.today = datetime.today() self.repo = self.options.target_repo self.valid_arches: frozenset[str] = self.options.target_repo.known_arches self._git_addon = git_addon + self.eclass_cache = eclass_addon.eclasses self._cleanup = [] self.valid_python_targets = { use.removeprefix("python_targets_") @@ -354,6 +373,25 @@ class GitPkgCommitsCheck(GentooRepoCheck, GitCommitsCheck): """Create/load cached repo of packages added to git.""" return self._git_addon.cached_repo(git.GitAddedRepo) + def addition_checks(self, pkgs): + """Check for issues due to package additions.""" + pkg = pkgs[0] + try: + new_pkg = self.repo.match(pkg.versioned_atom)[0] + except IndexError: + # ignore missing ebuild + return + + if new_pkg.inherit: + eclass_eapis = ( + frozenset(map(int, self.eclass_cache[eclass].supported_eapis)) + for eclass in new_pkg.inherit + ) + current_eapi = int(str(new_pkg.eapi)) + common_max_eapi = max(frozenset.intersection(*eclass_eapis)) + if common_max_eapi > current_eapi: + yield NewerEAPIAvailable(common_max_eapi, pkg=new_pkg) + def removal_checks(self, pkgs): """Check for issues due to package removals.""" pkg = pkgs[0] @@ -526,6 +564,9 @@ class GitPkgCommitsCheck(GentooRepoCheck, GitCommitsCheck): pkg_map["A"].add(pkg) pkg_map["D"].add(pkg.old_pkg()) + # run added package checks + if pkg_map["A"]: + yield from self.addition_checks(list(pkg_map["A"])) # run removed package checks if pkg_map["D"]: yield from self.removal_checks(list(pkg_map["D"])) diff --git a/tests/checks/test_git.py b/tests/checks/test_git.py index ab6efee2..12c5e4f0 100644 --- a/tests/checks/test_git.py +++ b/tests/checks/test_git.py @@ -38,7 +38,7 @@ class TestGitCommitMessageCheck(ReportTestCase): check = git_mod.GitCommitMessageCheck(options) def test_sign_offs(self): - # assert that it checks for both author and comitter + # assert that it checks for both author and committer r = self.assertReport( self.check, FakeCommit(author="user1", committer="user2", message=["blah"]) )