Skip to content

check that only the last section of the changelog was modified #68

@edublancas

Description

@edublancas

we recently added an utility to throw an error if a file hasn't been modified: https://github.com/ploomber/pkgmt/blob/main/src/pkgmt/fail_if_not_modified.py

we're using this on github actions to throw an error when somebody opens a PR and doesn't update the CHANGELOG.md. However, when a new release is made (hence the changelog.md modified to reflect the new development version), the PR branch becomes outdated, making the changelog entry incorrect.

example:

  1. a new branch is created to work on a new feature, at this time. the development version is 0.1dev
  2. the feature author opens a PR and adds a changelog entry under the 0.1dev section
  3. the feature author asks for a review
  4. a new release is made using the master branch (release version=0.1.), new development version is 0.1.1dev
  5. the PR is reviewed and merged

After merging, the changelog is incorrect because the PR entry was created under 0.1dev instead of 0.1.1dev

I believe the only way to detect this problem is when merging the PR: we can check whether any new commit that appears on the master/main branch is modifying the CHANGELOG.md (some don't modify it and that's allowed), and if so, check which section is modifying. if the modification is outside of the development version, we should fail the CI.

note that this has some edge cases. for example, if I add a commit (A) to master/main and modify the first section, but then add another commit (B) and modify the latest one. the CI will pass, even though I modified the first section in commit A. But I don't know if there's anything better we can do. because we cannot detect this problem during the PR CI run (or can we?) - since the release can happen at any time: during the review, after the review, right before merging it. I guess the only way is if we only allow to merge PRs that have been merged/rebased with respect to master, which will guarantee that the CHANGELOG.md version in the PR has the latest development version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions