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

Add regression tests for changelog text manipulation #12

Merged
merged 10 commits into from
Sep 24, 2024

Conversation

nwiltsie
Copy link
Member

@nwiltsie nwiltsie commented Sep 23, 2024

Description

This is what I get for being so terse with #6 and #7...

This actually fixes the issue I ran into with /~https://github.com/uclahs-cds/tool-BoutrosLab-utils/pull/23. The auto-generated links at the end had extra vs:

[0.2.0]: /~https://github.com/uclahs-cds/tool-BoutrosLab-utils/compare/vv0.0.1...v0.2.0
[v0.0.1]: /~https://github.com/uclahs-cds/tool-BoutrosLab-utils/releases/tag/vv0.0.1

I thought I fixed that with #7, but that would have resulted in these links (the first one is broken):

[0.2.0]: /~https://github.com/uclahs-cds/tool-BoutrosLab-utils/compare/v0.0.1...0.2.0
[v0.0.1]: /~https://github.com/uclahs-cds/tool-BoutrosLab-utils/releases/tag/v0.0.1

The real issue was that the changelog included v0.0.1 as a version, which is what this PR fixes.


The README now includes a note that versions must begin with a digit, and that the corresponding git tags must begin with a v. The actual fix for #6 is to strip leading vs from versions in the changelog, and go back to appending that v when constructing the tag links.

To make this more explicit I added some regression tests with bundled changelog files. The "original" file includes non-standard formatting and v2.5.0 as a version. The formatted file is the result of parsing and re-serializing the original, and shows that v2.5.0 is changed to 2.5.0. Finally, there is an updated file with a minor version bump.

Diff between `original` and `formatted`
--- tests/resources/original.md	2024-09-23 12:32:40
+++ tests/resources/formatted.md	2024-09-17 13:39:37
@@ -4,39 +4,33 @@

 This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

----
+## [Unreleased]

-## Unreleased
+### Security

-### Added
+- Security item

-### Security
+## [2.5.1] - 2024-02-01

-* Security item
+### Added

-## 2.5.1 - 2024-02-01
+- Add one
+- Add two

-## fix
+### Fixed

 - Fix one
 - Fix two

+## [2.5.0] - 2024-01-01

+Stray text

+### Changed

-### add
-
-* Add one
-* Add two
-
----
-
-
-## [v2.5.0] - 2024-01-01
-
-## change
-
 - Change one
 - Change two

-Stray text
+[2.5.0]: /~https://github.com/foo/bar/releases/tag/v2.5.0
+[2.5.1]: /~https://github.com/foo/bar/compare/v2.5.0...v2.5.1
+[unreleased]: /~https://github.com/foo/bar/compare/v2.5.1...HEAD
Diff between `formatted` and `2.5.3`
--- tests/resources/formatted.md	2024-09-17 13:39:37
+++ tests/resources/2.5.3.md	2024-09-17 13:39:37
@@ -4,7 +4,7 @@

 This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

-## [Unreleased]
+## [2.5.3] - 2024-05-05

 ### Security

@@ -33,4 +33,4 @@

 [2.5.0]: /~https://github.com/foo/bar/releases/tag/v2.5.0
 [2.5.1]: /~https://github.com/foo/bar/compare/v2.5.0...v2.5.1
-[unreleased]: /~https://github.com/foo/bar/compare/v2.5.1...HEAD
+[2.5.3]: /~https://github.com/foo/bar/compare/v2.5.1...v2.5.3

Checklist

  • This PR does NOT contain Protected Health Information (PHI). A repo may need to be deleted if such data is uploaded.
    Disclosing PHI is a major problem1 - Even a small leak can be costly2.

  • This PR does NOT contain germline genetic data3, RNA-Seq, DNA methylation, microbiome or other molecular data4.

  • This PR does NOT contain other non-plain text files, such as: compressed files, images (e.g. .png, .jpeg), .pdf, .RData, .xlsx, .doc, .ppt, or other output files.

  To automatically exclude such files using a .gitignore file, see here for example.

  • I have read the code review guidelines and the code review best practice on GitHub check-list.

  • I have set up or verified the main branch protection rule following the github standards before opening this pull request.

  • The name of the branch is meaningful and well formatted following the standards, using [AD_username (or 5 letters of AD if AD is too long)]-[brief_description_of_branch].

  • I have added the major changes included in this pull request to the CHANGELOG.md under the next release version or unreleased, and updated the date.

Footnotes

  1. UCLA Health reaches $7.5m settlement over 2015 breach of 4.5m patient records

  2. The average healthcare data breach costs $2.2 million, despite the majority of breaches releasing fewer than 500 records.

  3. Genetic information is considered PHI.
    Forensic assays can identify patients with as few as 21 SNPs

  4. RNA-Seq, DNA methylation, microbiome, or other molecular data can be used to predict genotypes (PHI) and reveal a patient's identity.

@nwiltsie nwiltsie requested a review from a team September 23, 2024 20:05
@yashpatel6 yashpatel6 self-assigned this Sep 23, 2024
bumpchanges/changelog.py Outdated Show resolved Hide resolved
bumpchanges/changelog.py Outdated Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
tests/conftest.py Show resolved Hide resolved
tests/conftest.py Show resolved Hide resolved
@nwiltsie nwiltsie requested a review from aholmes September 23, 2024 22:51
@nwiltsie nwiltsie merged commit abbe8ec into main Sep 24, 2024
7 checks passed
@nwiltsie nwiltsie deleted the nwiltsie-regression-tests branch September 24, 2024 20:53
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.

3 participants