Skip to content

Conversation

@SevaZhukov
Copy link

@SevaZhukov SevaZhukov commented Dec 13, 2022

Our current running changelog strategy is a reason for merge conflicts in every 1-3 PR. The new Multi-file running changelog strategy will solve this problem. How will it work you can read here.

@VysotskiVadim already tried to run Multi-file running changelog strategy in #5354 but he was faced with the need for maintaining a lot of code on CI for assembling changes. Now we can delegate assembling to the release train app.

  • create README.md about the new strategy
  • move unreleased features to json files
  • refactor CI scripts with verification changelog
  • fix tests of these scripts
  • refactor the train's changelog steps

[
{
"type": "Bug fixes and improvements",
"title": "Fixed approaches list update in `RouteOptionsUpdater`(uses for reroute). It was putting to the origin approach corresponding approach from legacy approach list."
Copy link
Contributor

Choose a reason for hiding this comment

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

Will the PR links be added automatically?

Copy link
Author

Choose a reason for hiding this comment

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

Yes

@@ -0,0 +1,6 @@
[
{
"type": "Bug fixes and improvements",
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 how we can easily make a typo here and get a weird header. Can we make it fool-proof? For example:
We only have a finite number of headers. Features, Bug fixes and improvements, Known issues.
Can we create directories for them? And then what's left is place a change entry as a plain string.
So for this example it would be:

  1. find directory "changelog/unreleased/Bug fixes and improvements"
  2. Create a file "6540.json"
  3. The file contents:
[
"Fixed approaches list update in `RouteOptionsUpdater`(uses for reroute). It was putting to the origin approach corresponding approach from legacy approach list."
]

If there are multiple entries, we just add a second array item.

What I want to do here is to not use any json keys. Because it creates room for errors as well as typing "Bug fixes and improvements" every time.
I think an array of string would be sufficient, WDYT?

Copy link
Contributor

@VysotskiVadim VysotskiVadim Dec 14, 2022

Choose a reason for hiding this comment

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

If the only field that left in file is title, maybe we can replace json with md?

Copy link
Author

Choose a reason for hiding this comment

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

I think it's a good point. In our case we have only 2 main parts: features and bugfixes, we can move type to path and make changelog file as md file

@@ -0,0 +1,59 @@
# Multi-file running changelog
Copy link
Contributor

Choose a reason for hiding this comment

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

We should definitely adapt changelog verification script... But first we have to agree on a format. I've left some suggestions.
I think we will have to check then:

  1. A file (at least one) has been added to "changelog/unreleased";
  2. The file is called PR_NUMBER.json;
  3. It's a valid json array of strings;
  4. Maybe something else, I'll have to look at the current checks.

@tomaszrybakiewicz
Copy link
Contributor

Few things to keep in mind. Changelog entries may have:

  • code snippets
    fun foo(bar: String) = "lorem ipsum dolor sit ammet..."
  • foldable sections (<details><summary></summary></details>)
    Open for cakeCake is a lie!!!
  • bold, italic and inline code text style
  • emojis ⚠️
  • images

@kmadsen
Copy link
Contributor

kmadsen commented Dec 14, 2022

Spent some time thinking/discussing and am sharing that I'm in favor. Great idea, and I like how it is something that GitLab had an issue with and came to a similar conclusion. They liked the solution enough to write a blog post https://about.gitlab.com/blog/2018/07/03/solving-gitlabs-changelog-conflict-crisis/

I have some minor opinions on the details, but overall I'm in favor. Cleaner solution than what we're doing now, the issue will be fixed, and it can be expanded for more improvements 👍

- Mapbox Java `v6.8.0` ([release notes](https://github.com/mapbox/mapbox-java/releases/tag/v6.8.0))
- Mapbox Android Core `v5.0.2` ([release notes](https://github.com/mapbox/mapbox-events-android/releases/tag/core-5.0.2))
```
* write the changelog to the `CHANGELOG.md` file
Copy link
Contributor

@kmadsen kmadsen Dec 14, 2022

Choose a reason for hiding this comment

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

capturing @tomaszrybakiewicz comment: Instead of generating CHANGELOG during release, do this on PR merge.

I'm also +1'ing that. It is nice to see a running changelog, instead of needing to dig through each new file created.

Considering that may re-introduce the merge conflict issue, maybe it could be part of a script where we can say sh scripts/show-unreleased-changelog.sh? Preferably, there is a way to make it so we can have a running changelog

Copy link
Contributor

@kmadsen kmadsen Dec 14, 2022

Choose a reason for hiding this comment

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

an idea is to have a file that represent the latest. every time a new pull request is merged the other one is deleted.

pr 01 is merged
01-changelog.md is created

pr 02 is merged
01-changelog.md is deleted
02-changelog.md is created

not the best solution considering that the unreleased changelog link would have a short life https://github.com/mapbox/mapbox-navigation-android/blob/main/unreleased/01-changelog.md

Copy link
Contributor

Choose a reason for hiding this comment

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

Considering that may re-introduce the merge conflict issue,...

After merging a PR, the automation would append a new entry to the latest CHANGELOG.md file on the main branch. How would that create a conflict?

(main)
* PR 1 merged 
* CHANGELOG.md update: PR 1 entry
* PR 2 merged
* CHANGELOG.md update: PR 2 entry

Copy link
Contributor

@VysotskiVadim VysotskiVadim Dec 14, 2022

Choose a reason for hiding this comment

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

Do we want to keep current not released version of running changelog publicly available?
If no, maybe we can generate current changelog by request inside the release train app?

Copy link
Contributor

Choose a reason for hiding this comment

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

After merging a PR,

it means that changelog must be merged separately, in another commit, out of PR merge. It seems risky: make it in 1 step (aka transaction) safer, than drop to a few

Copy link
Contributor

Choose a reason for hiding this comment

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

also, this way we will have 2x commits in the branch (1 is changed + 1 changelog)

Copy link
Author

Choose a reason for hiding this comment

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

Do we really need unreleased changelog in one file before release?

Copy link
Contributor

Choose a reason for hiding this comment

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

it means that changelog must be merged separately, in another commit, out of PR merge. It seems risky: make it in 1 step (aka transaction) safer, than drop to a few

@RingerJK It's as risky as Release Train or CI release workflows making additional commits.

also, this way we will have 2x commits in the branch (1 is changed + 1 changelog)

And why is that a problem?

Copy link
Author

Choose a reason for hiding this comment

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

I think we can add one more job for the main branch to generate a running changelog file. This job will be executed after every merge

[
{
"type": "Features",
"title": "Description of changes"
Copy link
Contributor

Choose a reason for hiding this comment

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

is title a string that contains markdown?


To avoid merge conflicts in the CHANGELOG.md file we accepted the multi-file running changelog strategy.

To follow this strategy you should create a `changelog/unreleased/${PR_NUMBER}.json` file for every PR like:
Copy link
Contributor

Choose a reason for hiding this comment

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

we usually add many lines during bump of NN and common dependencies. Does it mean that we will have to add as many files as many line we want to add during update of NN?

Copy link
Author

Choose a reason for hiding this comment

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

yeah, if we move features/bugfixes type to the path we can add files with additional info like this in the unreleased directory and structure will be like:

changelog
--unreleased
----features
------feature_1.md
----bugfixes
------bugfix_1.md
----other_change_1.md
----other_change_2.md

@VysotskiVadim
Copy link
Contributor

Should we let to insert sections like this or it should be done manually during release?


To avoid merge conflicts in the CHANGELOG.md file we accepted the multi-file running changelog strategy.

To follow this strategy you should create a `changelog/unreleased/${PR_NUMBER}.json` file for every PR like:
Copy link
Contributor

Choose a reason for hiding this comment

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

for that approach, we have to add a changelog in another commit (first create PR, get the PR number, and put the changelog and PR number into the branch).

Can it be modified so that we don't add the PR number manually? Can it be added under the hood when PR has been created?

Copy link
Contributor

Choose a reason for hiding this comment

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

for that approach, we have to add a changelog in another commit

I like to use the -f option but yes, I agree that it can get annoying.

Copy link
Author

Choose a reason for hiding this comment

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

I understand that it's not comfortable to write a changelog only after creating PR. I can propose creating an action that will rename the changelog file to ${PR_NUMBER}.md:

  1. You create a PR (with changelog file feature_1.md)
  2. The action executes and rename the changelog file to ${PR_NUMBER}.md
    Action will be executed only on open/reopen/redy for review moments
    WDYT

Copy link
Contributor

Choose a reason for hiding this comment

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

lgtm 👍

how does it works for release branches where we mostly cherry-pick changes (sometimes already released)? ref #6740 (comment)

Copy link
Author

Choose a reason for hiding this comment

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

oh it's a good moment, I think we can create a PR to the release branch first. Then, the action will rename the changelog file. Then, we can cherry-pick commits (changes + renaming commit) to the main branch

Copy link
Contributor

Choose a reason for hiding this comment

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

oh it's a good moment, I think we can create a PR to the release branch first. Then, the action will rename the changelog file. Then, we can cherry-pick commits (changes + renaming commit) to the main branch

Typically we merge into main branch, and then cherry-pick into the release branch(es). Maybe minor detail but I don't think we want it to require release commits first.

@RingerJK
Copy link
Contributor

@SevaZhukov would be any corner cases for release branches? Could you mention if any in readme

@SevaZhukov
Copy link
Author

Should we let to insert sections like this or it should be done manually during release?

Good point, I have added this section

@codecov
Copy link

codecov bot commented Dec 15, 2022

Codecov Report

Merging #6740 (f8d89a7) into main (14571b9) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##               main    #6740   +/-   ##
=========================================
  Coverage     72.51%   72.51%           
  Complexity     5551     5551           
=========================================
  Files           779      779           
  Lines         30072    30072           
  Branches       3548     3548           
=========================================
  Hits          21806    21806           
  Misses         6841     6841           
  Partials       1425     1425           

```

You can choose any name for your changelog files because the GitHub action will rename files in
`changelog/unreleased/features` and `changelog/unreleased/bugfixes` directories to `${PR_NUMBER}.md` when you open a PR.
Copy link
Contributor

Choose a reason for hiding this comment

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

What about the issues directory and just changelog/unreleased?

Copy link
Author

Choose a reason for hiding this comment

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

we need PR's links only for bugfixes and features

```

* write the changelog to the `CHANGELOG.md` file
* delete all files from `changelog/unreleased`
Copy link
Contributor

Choose a reason for hiding this comment

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

Just make sure patch releases won't erase all main changelog entries...

Copy link
Author

Choose a reason for hiding this comment

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

Releases since rc.1 will erase changelog/unreleased dir only in release branches

@@ -0,0 +1 @@
Fixed approaches list update in `RouteOptionsUpdater`(uses for reroute). It was putting to the origin approach corresponding approach from legacy approach list. No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't there be a - in the beginning?

Copy link
Author

Choose a reason for hiding this comment

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

I think the script will add - during assembling

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 not a very good idea. If the entry is multi-line, how will the script understand where to add the -?

Copy link
Author

Choose a reason for hiding this comment

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

if you have only one feture/bugfix you can don't use - before, if you have more you should

@@ -0,0 +1 @@
Updated the `MapboxRestAreaApi` logic to load a SAPA map only if the upcoming rest stop is at the current step of the route leg. No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't there be a - in the beginning?

@@ -0,0 +1 @@
It is an example of known issues No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't there be a - in the beginning?

diff_file_start_regex = "^([\s]*)\@\@(.*)\@\@"
pr_link_regex = "\[#\d+]\(https:\/\/github\.com\/mapbox\/mapbox-navigation-android\/pull\/\d+\)"


Copy link
Contributor

Choose a reason for hiding this comment

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

That's not what I meant when saying we should adapt the checks...

Copy link
Author

Choose a reason for hiding this comment

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

I didn't do anything with it))

Copy link
Contributor

Choose a reason for hiding this comment

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

But there are changes in the diff...

Copy link
Author

Choose a reason for hiding this comment

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

only autoformating

- Description of changes in md format also
```

You can choose any name for your changelog files because the GitHub action will rename files in
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's worth mentioning that you can't create 2 files in 1 directory in 1 PR. I don't think we someone would want that (I don't see any cases for that) but still we should note that.

Copy link
Author

Choose a reason for hiding this comment

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

but I mentioned it here

Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't say you can't create mmultiple files.

@SevaZhukov
Copy link
Author

hey team, I added two GitHub actions

  1. Rename changelog files. It executes every update and looking for and renaming new changelog files in features and bugfixes dirs from any-feature-name.md to ${PR_NUMBER}.md. After it pushes to the current branch.
  2. Assemble changelog. It executes only on the main and release branches. This action compile changelog from features, bugfixes and issues dirs like:
#### Features
- Test changes to check renaming
- Introduced `MapboxSpeedInfoApi` and `MapboxSpeedInfoView`. The combination of API and View can be used to render posted and current speed limit at user's current location.
- :warning: Deprecated `MapboxSpeedLimitApi` and `MapboxSpeedLimitView`.

#### Bug fixes and improvements
- Updated the `MapboxRestAreaApi` logic to load a SAPA map only if the upcoming rest stop is at the current step of the route leg.
- Fixed approaches list update in `RouteOptionsUpdater`(uses for reroute). It was putting to the origin approach corresponding approach from legacy approach list.

#### Known issues :warning:
- It is an example of known issues

After it commits and pushes to the current branch. Commit name contains [skip actions] label to skip this commit for the actions.

@tomaszrybakiewicz @kmadsen @VysotskiVadim @RingerJK @dzinad


You can use anything that allow .md format in changelog files.

If you have implemented some features or bugfixes you should describe all of them:
Copy link
Contributor

Choose a reason for hiding this comment

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

some -> several/multiple

You can choose any name for your changelog files because the GitHub action will rename files in
`changelog/unreleased/features` and `changelog/unreleased/bugfixes` directories to `${PR_NUMBER}.md` when you open a PR.

Every release the release train app will:
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 not only on every release, right? It will happen after every merge? Can you actualize README? Because that's all I'm reviewing actually: this file and the examples. :)

Copy link
Author

Choose a reason for hiding this comment

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

updated

@@ -0,0 +1,11 @@
#### Features
- Test changes to check renaming
Copy link
Contributor

Choose a reason for hiding this comment

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

What about the PR links? They should be here because we've lost all the info about where this entry came from at this point, right?

Copy link
Author

Choose a reason for hiding this comment

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

I added links to assembled changelog, thanks

Some other changes
```

* write the changelog to the `changelog/unreleased/CHANGELOG.md` file
Copy link
Contributor

Choose a reason for hiding this comment

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

What about the release process? Shouldn't we move the changelog from unreleased directory to the project root and delete the unreleased one?

Copy link
Author

Choose a reason for hiding this comment

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

Added more information

You can choose any name for your changelog files because the GitHub action will rename files in
`changelog/unreleased/features` and `changelog/unreleased/bugfixes` directories to `${PR_NUMBER}.md` when you open a PR.

Every push to the main or release branch Assemble changelog GitHub action will be executed:
Copy link
Contributor

Choose a reason for hiding this comment

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

The temporary files will be deleted, right?

Copy link
Author

Choose a reason for hiding this comment

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

no, let's keep they before the release

@dzinad
Copy link
Contributor

dzinad commented Dec 21, 2022

The docs and the examples look good. And I believe you know what you're doing with the scripts. :)

@SevaZhukov SevaZhukov marked this pull request as ready for review December 21, 2022 14:04
- Mapbox Android Core `v5.0.2` ([release notes](https://github.com/mapbox/mapbox-events-android/releases/tag/core-5.0.2))
```
* add compiled changelog to `CHANGELOG.md` file
* delete all files in `changelog/unreleased` dir
Copy link
Contributor

Choose a reason for hiding this comment

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

@SevaZhukov will this system work with the android auto changelog https://github.com/mapbox/mapbox-navigation-android/blob/main/libnavui-androidauto/CHANGELOG.md

All good to consider it out of scope but it would be nice if it supported multiple release channels

You can choose any name for your changelog files because the GitHub action will rename files in
`changelog/unreleased/features` and `changelog/unreleased/bugfixes` directories to `${PR_NUMBER}.md` when you open a PR.

Every push to the main or release branch Assemble changelog GitHub action will be executed:
Copy link
Contributor

Choose a reason for hiding this comment

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

Will those commit trigger metrics run? For now it seems so, because each PR merge produces 2 commits in the main branch.

Copy link
Author

Choose a reason for hiding this comment

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

[skip ci] tag allows skipping CircleCI jobs and GitHub Actions

import git


def get_changes(path):
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the testing strategy for the changelog logic? Do I understand correctly that after each change I need to manually run script locally simulating different scenarios that my change may affect? Do you think it makes sense to add auto tests, so that developers could enhance this logic without being afraid break a different scenario?

I think this question isn't a blocker for this particular PR, but it's worth to discuss 🙂

Copy link
Author

Choose a reason for hiding this comment

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

yeah, good point, let's add tests for this logic


To follow this strategy you should create a `.md` file for every PR. Choose a directory:

- `changelog/unreleased/features` for **Features** changes
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO would be nice to have a script to add changelog like python add_changelog.py -f "Changelog string", where -f is feature (also should be other flags), "Changelog string" is the entry of changelog

Copy link
Author

Choose a reason for hiding this comment

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

done

@SevaZhukov SevaZhukov merged commit b329337 into main Jan 4, 2023
@SevaZhukov SevaZhukov deleted the NAVSDK-646 branch January 4, 2023 13:48
SevaZhukov pushed a commit that referenced this pull request Jan 10, 2023
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.

6 participants