From: "Arthur Zamarin" <arthurzam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, tests/checks/
Date: Thu, 7 Mar 2024 16:06:53 +0000 (UTC) [thread overview]
Message-ID: <1709363706.2ed2a36a62f3bb9801c187c053ec67ec6bb47565.arthurzam@gentoo> (raw)
commit: 2ed2a36a62f3bb9801c187c053ec67ec6bb47565
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 2 07:13:16 2024 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> 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 <arthurzam <AT> 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"])
)
next reply other threads:[~2024-03-07 16:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-07 16:06 Arthur Zamarin [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-01-16 12:17 [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, tests/checks/ Arthur Zamarin
2023-07-15 8:52 Arthur Zamarin
2023-03-11 7:14 Arthur Zamarin
2023-03-05 17:13 Arthur Zamarin
2023-03-04 5:59 Arthur Zamarin
2023-01-21 9:46 Arthur Zamarin
2023-01-20 20:47 Arthur Zamarin
2022-11-26 11:47 Arthur Zamarin
2022-11-26 11:47 Arthur Zamarin
2022-10-28 13:34 Arthur Zamarin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1709363706.2ed2a36a62f3bb9801c187c053ec67ec6bb47565.arthurzam@gentoo \
--to=arthurzam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox