devtools: add pr-tool to automate PR review and merge#935
Merged
pstorz merged 27 commits intobareos:masterfrom Jan 20, 2023
Merged
devtools: add pr-tool to automate PR review and merge#935pstorz merged 27 commits intobareos:masterfrom
pr-tool to automate PR review and merge#935pstorz merged 27 commits intobareos:masterfrom
Conversation
Member
Author
|
do you think we will need to test this on the |
56247d8 to
51a7fd5
Compare
Member
Author
|
This cannot work right now, as we will have to adapt github permissions and branch protection to match our needs. |
6b2ec9d to
e85ceaf
Compare
dcd1f87 to
5858302
Compare
31f944a to
04fca20
Compare
Member
Author
|
I think it is now pretty much finished. There are some considerations we may discuss next year:
|
eb83e56 to
c8637cc
Compare
d505964 to
42e1eec
Compare
pr-tool to automate PR review and merge
Introduce a new devtool "pr-tool" that helps merging pull requests. It can check prerequisites, add CHANGELOG.md entries and automatically rebase to avoid CHANGELOG.md merge conflicts. Also add a python version of update-changelog-links.sh that is exposed as a program and used internally by pr-tool.
* Check that PR status is OPEN and not CLOSED or MERGED. * Display url of PR * Add parameter --admin-override to merge. Will call the 'gh pr merge' command with the --admin option to override required checks if possible * Look for github status checks and stop merge if not successful. Provide option --ignore-status-checks in merge to skip this check.
rerunning "pipenv lock" to get newer versions of everything we're using.
pr-tool will now also check if the status check with context "continuous-integration/jenkins/pr-merge" is present and fail the PR check otherwise.
"pr-tool merge" will now show if PR was merged or not before exiting.
The headline-check on pr-tool commit now allows up to 60 characters.
Enables pr-tool check to display the section to which the changelog record will be added.
The pr-tool is now able to select the section to which a ChangeLog entry should be added based on the PR's labels. Currently this will only check for the "documentation" label and set the section to Documentation (which was not possible before).
add_changelog_entry() did a bad job if there were existing multiline entries in the changelog. If the section where a new entry should be added ended in something like this: - normal changelog entry - with additional information - and more information it would misdetect the location to add the new record and insert it after the first line instead of at the end. Now it also skips lines where "- " is preceded by whitespace.
You can now pass absolute paths as a parameter to --file when running add-changelog-entry. The original add-changelog-entry would always interpret its --file argument relatively to the current git repository, even if the path was absolute.
The user can override the host or repository for the gh command using the environment variables GH_HOST or GH_REPO. As we will have to determine the repository and the name of the remote ourselves (gh does not provide a way to do that), setting GH_HOST or GH_REPO will probably break pr-tool at some point, so we disallow it. Also introduces logging options.
For doing a rebase, we need to know the (remote) branch we're rebasing onto. While this is usually "origin" you can call it whatever you want. We now determine the correct git remote in the same fashion as gh cli does.
When your local repository is not up to date, rebasing (and potentially other operations) will not lead to the desired result or may even fail. pr-tool will now check if your local repository's base branch points to the same commit as the remote repository's base branch and will issue a warning otherwise.
When checking commits, pr-tool will now look at the local history instead of the commits in the PR at github. So you can reword and recheck without pushing.
With this patch, you can now invoke check_sources.main_program() from your own code and get meaningful results.
When running pr-tool check or pr-tool merge, an automated run of bareos-check-sources --since=<your-merge-base-commit> happens and its result is evaluated as a checkmark result for the PR. As this is now automated, we can remove the checkmark from the PR template.
By using another approach to detect changed files per commit, the performance of bareos-check-sources could be drastically improved.
Instead of looking at the mime-type, we now simply check if the file is empty and try to read it as utf-8 otherwise. This turned out to be faster than guessing the mime-type first. We can probably improve this further by adding some filename patterns that should always be skipped (like *.gz, *.tgz, *.png, *.min.*).
This plugin shrinks block comments by merging alone standing begin and end of block comments (/* and */) into the second and in the last line, respectively. Block comments starting in the first column remain untouched, as these are usually file license information or function documentation.
Ran rm Pipfile.lock && pipenv install
d5c640c to
b0c0445
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a new tool
pr-toolto the set of existing devtools. The tool supports differents modes of operation.When invoked with
pr-tool checkit will run some sanity checks for the PR itself and look for some of the things the reviewer had to check manually before:With
pr-tool mergethe above checks will be run and if these are successful, a ChangeLog entry will be added if required (including a rebase onto the base-branch if otherwise there is a conflict) and then the PR will be merged.Finally
pr-tool add-changelogwill just add the ChangeLog record and commit CHANGELOG.md (without pushing).TODO
Thank you for contributing to the Bareos Project!
Please check
If you have any questions or problems, please give a comment in the PR.
Helpful documentation and best practices
Checklist for the reviewer of the PR (will be processed by the Bareos team)
General
Source code quality
bareos-check-sources --since-mergedoes not report any problemsgit statusshould not report modifications in the source tree after building and testing