Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changelog validation: ensure changelog filename matches the package name #9633

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@

# Uyuni Code Owners

# Workflows reviewers
.github/workflows @uyuni-project/workflows-reviewers

# Release Engineering
rel-eng/ @uyuni-project/release-engineering
tito.props @uyuni-project/release-engineering
Expand All @@ -48,6 +45,9 @@ java/conf/cobbler/snippets/ @uyuni-project/python
# This file only holds data, no Python code
mgr_bootstrap_data.py

# Workflows reviewers
.github/workflows @uyuni-project/workflows-reviewers

# Frontend
web/html/ @uyuni-project/frontend
web/setup.sh @uyuni-project/frontend
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/changelogs/changelogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class IssueType:
MISSING_CHLOG = "Changelog not added"
WRONG_CHLOG = "Changelog added without changes"
EMPTY_CHLOG = "No changelog entries found"
INVALID_CHLOG_FILENAME = "Changelog filename must be in format: '{}.changes.<author>.<feature>'"
MISSING_NEWLINE = "Missing newline at the end"
WRONG_CAP = "Wrong capitalization"
WRONG_SPACING = "Wrong spacing"
Expand Down Expand Up @@ -265,7 +266,7 @@ def get_modified_files_for_pkg(self, pkg_path: str, pkg_name: str, files: list[s
for f in files:
# Check if the file exists in a subdirectory of the base path of the package
if f.startswith(pkg_path):
if os.path.basename(f).startswith(pkg_name + ".changes."):
if ".changes." in os.path.basename(f):
# Ignore if the change is a removal
if os.path.isfile(os.path.join(self.uyuni_root, f)):
pkg_chlogs.append(f)
Expand Down Expand Up @@ -629,6 +630,9 @@ def validate(self, file_list: list[str]) -> list[Issue]:
if not files["changes"]:
# Files are modified but no changelog file added
issues.append(Issue(IssueType.MISSING_CHLOG, package=pkg))
for chlog_file in files["changes"]:
if not os.path.basename(chlog_file).startswith(f"{pkg}.changes."):
issues.append(Issue(IssueType.INVALID_CHLOG_FILENAME.format(pkg), package=pkg))

# Validate each changelog file and gather all the issues
for file in files["changes"]:
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/changelogs/test_changelogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def test_validate_chlog_file_multiple_issues_and_entries(validator, chlog_file):
),
(
"- This entry has an extra whitespace\n",
IssueType.MULTI_WHITESPACEi
IssueType.MULTI_WHITESPACE
),
(
" - This is an invalid changelog entry\n",
Expand Down Expand Up @@ -491,6 +491,14 @@ def test_validate_chlog_for_wrong_pkg(validator, chlog_file):
)


def test_validate_chlog_invalid_filename(validator, base_path):
chlog_file = base_path / "pkg/path/invalid.changes.my.feature"
chlog_file.write_text("- This is a changelog entry.\n")
issues = validator.validate(["pkg/path/invalid.changes.my.feature", "pkg/path/myfile.txt"])
assert len(issues) == 1, issues_to_str(issues, 1)
assert IssueType.INVALID_CHLOG_FILENAME.format("mypkg") in str(issues[0]) and "mypkg" in str(issues[0])


def test_validate_change_in_subdir(validator, base_path):
chlog_file = base_path / "pkg/other/otherpkg.changes.my.feature"
chlog_file.write_text("- This is a changelog entry.\n")
Expand Down
Loading