Skip to content

Conversation

@vivus-ignis
Copy link
Contributor

@vivus-ignis vivus-ignis commented Oct 13, 2025

What this PR does / why we need it:
Adds semver support to release notes generation code.

Which issue(s) this PR fixes:
Fixes gardenlinux/gardenlinux#3645 (comment)

@vivus-ignis vivus-ignis changed the base branch from main to release-notes-image-ids October 13, 2025 14:14
@codecov
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

❌ Patch coverage is 93.44262% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.24%. Comparing base (2c47ca5) to head (1612d07).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/gardenlinux/github/release_notes/sections.py 84.21% 3 Missing ⚠️
src/gardenlinux/distro_version/__init__.py 97.61% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #219      +/-   ##
==========================================
+ Coverage   89.81%   90.24%   +0.42%     
==========================================
  Files          41       42       +1     
  Lines        1974     2009      +35     
==========================================
+ Hits         1773     1813      +40     
+ Misses        201      196       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Base automatically changed from release-notes-image-ids to main October 14, 2025 17:58
@vivus-ignis vivus-ignis marked this pull request as ready for review October 14, 2025 18:06
Copy link
Contributor

@ByteOtter ByteOtter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some smaller issues with typing and Codecov reports that the test coverage is insufficient (99 lines missing).
The biggest thing is the multiple function declaration though, which I would like to see addressed as this would also be a functional bug though as Python afaik only keeps the last definition it loads.

Personally I would prefer returning an empty string or something like 0.0.0 in case of error instead of None, this makes working with it easier down the line.
Also, maybe for this it would be worth investigating if the packaging.version is worth using here. It's part of the standard library.

Comment on lines 124 to 133
if patch > 0:
previous_version = f"{major}.{minor}.{patch - 1}" if minor else f"{major}.{patch - 1}"

output += (
f"## Changes in Package Versions Compared to {previous_version}\n"
)
output += compare_apt_repo_versions(
previous_version, gardenlinux_version
)
elif patch == 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In these lines patch, major and minor are possibly unbound. Initializing them with a default value would be the easiest way to fix this if this is feasible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably I'm missing something, but I can't find how they can be unbound. We check explicitly that there are 2 or 3 version components and then assign those major, minor, patch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's about these blocks:

    if len(version_components) == 2:
        minor = None
        patch = int(version_components[1])
    if len(version_components) == 3:
        minor = int(version_components[1])
        patch = int(version_components[2])

Logically speaking you are right and they can't really be unbound in reality. However, pyright remains conservative and cannot infer that the remaining possible lengths are 2 or 3. So it sees the possibility that none of these if statements execute.

The easiest way to fix this would be to simply initialize these value beforehand like this:

major = int(version_components[o])
minor: int | None = None # This one can be missing
patch: int = 0 # Or this one can be int | None depending on the interpretation for versions with only 2 digits.

I just tested it on my machine and it should ™️ fix the issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue is not yet been solved.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you initialize the versions before the if statements now which is good. But due to initializing patch with None another issue shows up for anything after if patch > 0, as we never check for if patch is not None.

I'd just go ahead and interpret patch as the second number in a two digit version and treat the value as a number by initializing patch: int = 0 to avoid that. This would mean, if we encounter a two digit version number that we define the first one as major and the second as patch and minor is missing as there are no minor versions when going by two digit versioning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the code to use OOP-style version handling and hopefully make type checker happier. Please recheck.

@vivus-ignis vivus-ignis requested a review from ByteOtter October 16, 2025 08:40
Copy link
Contributor

@ByteOtter ByteOtter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is okay for now. So, unless @NotTheEvilOne has something more to add, I think we can merge this.

@vivus-ignis vivus-ignis merged commit 133a236 into main Oct 21, 2025
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants