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

test(changelog): refactor changelog validation #809

Conversation

codejedi365
Copy link
Contributor

@codejedi365 codejedi365 commented Jan 17, 2024

Recommend Reviewing this PR through the commit by commit view as opposed to the Files Changed view, it will be easier to understand as you can match my commit message with the changes made.

Purpose

  1. Enable more granular testing of generated changelog & release notes from the provide templates
  2. Fix changelog & release notes to always end with a single newline (not extras)
  3. Fix a timezone determination bug which causes failures of changelog tests when executed left of the prime meridian, previous PSR would add time which can impact the date of when a release occurred.

Rationale

While I've been working on testing some improvements to the changelog functionality, I stumbled across some logic bugs within the testing framework which were producing false positives. One such example is the regenerate_content from the changelog test.

  1. Refactored some assertions so that the failure is readable and immediately identifiable in the logs rather than obscured.

  2. I identified & fixed that some of the angular commit messages that syntactically had the scope in the wrong spot.

  3. I ensured that changelogs are actually generated (the empty template directory disabled all default changelog creations) both before the tests and then after the tests.

The strategy I employ here when refactoring the testing for changelogs is to identify what should go as a unit test and what is a scenario based system test. Personally, I value system tests way more than unit tests. I believe that unit tests really should just focus on "prove it works" with basic default values. The scenarios should be extensive to try all variations as this will catch the most bugs that our users will actually encounter. I have been burned many times when the unit tests don't actually catch the problems users have. How does this apply to this PR? I removed more parametrize values from unit tests and instead beef up the scenario testing. One reason I think this applies more here is that the outputs are related to changelog and release notes is that these are the outputs the user receives from the entire program which should be vetted thoroughly as opposed to an internal function. If you disagree as I realize I am opinionated on this, then I can adjust accordingly.

How I tested

Related to purpose 3, If you try to execute the test cases on a machine in the Eastern Standard Time (EST) zone after 3PM, all the changelogs tests will fail due to a date mix match. My first assumption was UTC time, however, EST is only 4 or 5 hours off of UTC so at 3PM even UTC isn't on the next day. But if you interpret a timedelta incorrectly from git as PSR was you instead add 5 hours to UTC time, then you find yourself at 1AM (UTC+5) and Ah Ha!

@codejedi365 codejedi365 force-pushed the test/refactor-changelog-validation branch 5 times, most recently from e27c7da to 475bf52 Compare February 10, 2024 05:05
@codejedi365 codejedi365 force-pushed the test/refactor-changelog-validation branch 2 times, most recently from 02a438d to 6f88e0d Compare February 13, 2024 02:38
Drop the test related changelog template as that is one more thing to
maintain and does not actually match the embedded template provided to
the user.

Secondly, drop the context unit test as it does not provide value that
the template ultimately will fail in other unit tests.
Drop the test related release notes template as that is one more thing to
maintain and use the one provided to the user.
@codejedi365 codejedi365 force-pushed the test/refactor-changelog-validation branch from 6f88e0d to d6e15fe Compare February 25, 2024 19:04
@codejedi365 codejedi365 force-pushed the test/refactor-changelog-validation branch from d6c2106 to 0347dac Compare March 2, 2024 03:29
@codejedi365 codejedi365 force-pushed the test/refactor-changelog-validation branch from c65ed3b to a183229 Compare March 2, 2024 03:48
@codejedi365 codejedi365 marked this pull request as ready for review March 2, 2024 04:08
@codejedi365
Copy link
Contributor Author

@relekang, ready for review

@relekang relekang merged commit adce520 into python-semantic-release:master Mar 18, 2024
7 checks passed
@codejedi365 codejedi365 deleted the test/refactor-changelog-validation branch March 19, 2024 01:20
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.

None yet

2 participants