Skip to content

Add changelog generator based on PR data#7461

Merged
mrcasals merged 8 commits intodevelopfrom
chore/add-changelog-generator
Feb 26, 2021
Merged

Add changelog generator based on PR data#7461
mrcasals merged 8 commits intodevelopfrom
chore/add-changelog-generator

Conversation

@mrcasals
Copy link
Copy Markdown
Contributor

@mrcasals mrcasals commented Feb 25, 2021

🎩 What? Why?

This PR improves how to generate the changelog.

The current (undocumented) process to generate the changelog is this one, using git notes:

  1. Merge a PR, get the SHA of the merge commit
  2. In your local machine, run git fetch origin refs/notes/*:refs/notes/* to download the latest notes in the commits
  3. Add notes to the merge commit with git notes add <SHA>
    • The text should be something like Added: **decidim-core**, **decidim-admin**
  4. Push the notes with git push origin refs/notes/*

The process implies manual work for every merged PR. If you forget about performing the steps for a PR, the PR won't appear in the changelog.

Since we squash PRs before merging, and the squashed commit contains the reference of the PR it squashes, we can use that to get to the PR and gather data from it. This PR does just that:

  1. Parse the list of commits from a given SHA to the current state of the branch
  2. For each commit, fetch the related PR ID from the title. If it exists, fetch the GitHub API for the PR title and labels.
  3. From labels, build the changelog

If a PR can't be classified, or it doesn't have a way to link it to a PR, then the commit title appears under an Unsorted section. This can be used to list all the PRs that haven't yet been classified, so you can classify them easily by changing the labels of the PR.

This means we can improve the Changelog shape by modifying the PR title and labels.

Part of the changelog will still need to be changed manually:

  • Links to the previous version
  • Explanation of the changes

This is what the code generates for the current develop branch (head e417144):

### Added

Nothing.

### Changed

- **decidim-admin**: Migrate Admin menus to Menu Registry [\#7368](https://github.com/decidim/decidim/pull/7368)
- **decidim-core**: Align Data Picker selected values styles [\#7448](https://github.com/decidim/decidim/pull/7448)

### Fixed

- **decidim-admin**: Fix to avoid registered users being invited again [\#7392](https://github.com/decidim/decidim/pull/7392)

### Removed

Nothing.

### Developer improvements

- Split Election tests suite into 3 workflows [\#7451](https://github.com/decidim/decidim/pull/7451)

Notes:

  • The script requires a Personal Access Token for the GitHub API. The limit is 5000requests/hour/user, so all tokens generated by the same user count towards this limit of 5000. That's still a lot, I think we're safe. Source is https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting
  • The script has a "help" mode if no token is passed, or if called as bin/changelog_generator --help, which shows the usage
  • For testing purposes, by default it generates the changelog for the last 5 commits. You can change that by adding the SHA from which to generate it (as a 2nd parameter of the command)
  • It ignores any Crowdin PR
  • Output is stored in a temporary_changelog.md file, on purpose. This helps keep the output safe (since calculating the changelog is time-consuming action) and lets us show a progress bar to the terminal output.

📌 Related Issues

None

Testing

Nothing.

@mrcasals mrcasals force-pushed the chore/add-changelog-generator branch from ec7282a to 5767582 Compare February 25, 2021 08:38
mrcasals and others added 2 commits February 25, 2021 10:45
Co-authored-by: Oriol Gual <oriolgual@users.noreply.github.com>
@mrcasals mrcasals marked this pull request as ready for review February 25, 2021 10:35
@mrcasals mrcasals dismissed oriolgual’s stale review February 25, 2021 10:35

Feedback addressed

@mrcasals mrcasals force-pushed the chore/add-changelog-generator branch from 134adf1 to d52edac Compare February 25, 2021 11:27
@mrcasals mrcasals changed the title Add changelog generator from PR data Add changelog generator based on PR data Feb 26, 2021
@mrcasals mrcasals merged commit 43860ef into develop Feb 26, 2021
@mrcasals mrcasals deleted the chore/add-changelog-generator branch February 26, 2021 10:15
entantoencuanto added a commit that referenced this pull request Mar 2, 2021
* develop: (25 commits)
  Add css selectors to emails to improve design customization (#7493)
  Only share tokens if component exists (#7499)
  Fix record encryptor hash values JSON parsing for legacy unencrypted hash values (#7494)
  Fix NULL error with weight field in assemblies & processes (#7486)
  Fix proposals to budget import (#7449)
  Fix cost display on proposals (#7450)
  Fix #7487 - Invalid signature on message decryption (#7488)
  New Crowdin updates (#7482)
  Move specs file to correct folder (#7476)
  Improve changelog generator (#7475)
  New Crowdin updates (#7472)
  Prepare 0.25-dev version (#7473)
  New Crowdin updates (#7470)
  New Crowdin updates (#7468)
  Feature proposal infinite edit time (#7406)
  New Crowdin updates (#7457)
  Trigger docs build on folder changes (#7360)
  Add changelog generator based on PR data (#7461)
  Add Votings to Open Data export (#7388)
  Add order in not highlighted assemblies by weight (#7444)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants