Skip to content

Commit

Permalink
GitPkgCommitsCheck: add check for EAPI change without revbump
Browse files Browse the repository at this point in the history
Resolves: #557
Signed-off-by: Arthur Zamarin <[email protected]>
  • Loading branch information
arthurzam committed Mar 5, 2023
1 parent 1eb9de2 commit ea78fb2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
16 changes: 16 additions & 0 deletions src/pkgcheck/checks/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,18 @@ class PythonPEP517WithoutRevbump(results.PackageResult, results.Warning):
desc = "changed DISTUTILS_USE_PEP517 without new revision"


class EAPIChangeWithoutRevbump(results.PackageResult, results.Warning):
"""Package has changed EAPI without revbump.
The package has changed EAPI without a new revision. An EAPI bump
might affect the installed files (EAPI changes, eclass functions
may change behavior, new portage features might be used, etc.).
The change should also be reflected in the vdb's EAPI file.
"""

desc = "changed EAPI without new revision"


class SrcUriChecksumChange(results.PackageResult, results.Error):
"""SRC_URI changing checksum without distfile rename."""

Expand Down Expand Up @@ -278,6 +290,7 @@ class GitPkgCommitsCheck(GentooRepoCheck, GitCommitsCheck):
SrcUriChecksumChange,
SuspiciousSrcUriChange,
PythonPEP517WithoutRevbump,
EAPIChangeWithoutRevbump,
]
)

Expand Down Expand Up @@ -392,6 +405,9 @@ def found_pep517_lines(cmp_pkg):
if found_old_pep517_line ^ found_new_pep517_line:
yield PythonPEP517WithoutRevbump(pkg=new_pkg)

if old_pkg.eapi != new_pkg.eapi:
yield EAPIChangeWithoutRevbump(pkg=new_pkg)

old_slot, new_slot = old_pkg.slot, new_pkg.slot
if old_slot != new_slot:
slotmoves = (
Expand Down
16 changes: 13 additions & 3 deletions tests/checks/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def _setup(self, tmp_path, tool, make_repo, make_git_repo):
self.parent_repo = make_repo(self.parent_git_repo.path, repo_id="gentoo", arches=["amd64"])
self.parent_git_repo.add_all("initial commit")
# create a stub pkg and commit it
self.parent_repo.create_ebuild("cat/pkg-0")
self.parent_repo.create_ebuild("cat/pkg-0", eapi="7")
self.parent_git_repo.add_all("cat/pkg-0")

# initialize child repo
Expand Down Expand Up @@ -694,6 +694,16 @@ def test_python_pep517_change(self):
expected = git_mod.PythonPEP517WithoutRevbump(pkg=CPV("newcat/newpkg-1"))
assert r == expected

def test_eapi_change(self):
# bump eapi
self.child_repo.create_ebuild("cat/pkg-0", eapi="8")
self.child_git_repo.add_all("cat/pkg-0")
# pull changes to child repo
self.init_check()
r = self.assertReport(self.check, self.source)
expected = git_mod.EAPIChangeWithoutRevbump(pkg=CPV("cat/pkg-0"))
assert r == expected

def test_src_uri_change(self):
distfile = [
"DIST",
Expand Down Expand Up @@ -721,8 +731,8 @@ def test_src_uri_change(self):
assert r == git_mod.SuspiciousSrcUriChange(old_url, new_url, distfile[1], pkg=CP("cat/pkg"))
# revert change and check for no report with same mirror url
self.child_git_repo.run(["git", "reset", "--hard", "origin/main"])
self.child_repo.create_ebuild("cat/pkg-1", src_uri=old_url, eapi="8")
self.child_git_repo.add_all("cat/pkg: bump EAPI", signoff=True)
self.child_repo.create_ebuild("cat/pkg-1", src_uri=old_url, homepage="https://gentoo.org")
self.child_git_repo.add_all("cat/pkg: update HOMEPAGE", signoff=True)
self.init_check()
self.assertNoReport(self.check, self.source)

Expand Down

0 comments on commit ea78fb2

Please sign in to comment.