Git Product home page Git Product logo

rebazer's Introduction

rebazer

Build Status Quality Gate Status license PRs welcome code with hearth by retest

Helper service to handle pull requests (PRs) on GitHub or Bitbucket. Primary it rebases the source branch of PRs against target branch to streamline commit history.

The rebazer polls in a configurable interval GitHub and Bitbucket repositories. The processing for each repository is described below:

  • Has PR changed since last run?
    • If no wait again for source/target branch, build result or approval change
  • Is the corresponding build green?
    • If no wait again for green build
  • Is source branch on top of target branch?
    • Rebase source branch
    • Conflict while rebasing?
      • On conflict abort rebase and comment PR
    • Wait for green build
  • Is PR approved?
    • Wait for approval
  • Merge PR into
  • Delete merged branch

Illustrated as a flowchart:

rebazer flowchart

Configuration

The rebazer relies on several parameters to configure the handled repositories. The configuration can be specified in any way supported by spring boot. Recommended is to use a application.yml file. The roll out of the application.yml depends on type of deployment.

Minimal configuration example:

rebazer: hosts: - type: GITHUB teams: - name: your_company user: service_user pass: dont_use_this_pass_at_home repos: - name: foo - name: bar

An example in-depth can be found in application-example.yml.

Mandatory parameter

Parameter Explanation
rebazer.hosts[ ].type Hosting platform type, possible values GITHUB or BITBUCKET
rebazer.hosts[ ].teams[ ].name Team/company/project name of the repos, first part of the slug
rebazer.hosts[ ].teams[ ].pass Password to access the repositories
rebazer.hosts[ ].teams[ ].repos[ ].name Name/Key of a specific repository

Optional parameter

Parameter Explanation Default Value
rebazer.workspace Workspace Directory for checkouts ./rebazer-workspace
rebazer.garbageCollectionCountdown Number of rebases before a git GC is triggered 20
rebazer.pollInterval Delay in seconds between checks for changes on configured repos 60
rebazer.hosts[ ].url Base URL to the hosting platform api Depents on ..hosts[ ].type, e.g. https://api.github.com
rebazer.hosts[ ].teams[ ].user User for the specific team to access repositories Same as ..teams[ ].name
rebazer.hosts[ ].teams[ ].repos[ ].mainBranch Branch to reset git repo on cleanup after rebase main

Deployment

Spring Application JAR

This JAR can basically be run everywhere a JVM is present; there are no further dependencies. However, for a successful start, several parameters need to be configured (see configuration section for details). There are quite a number of ways to specify these parameters.

If e.g. all parameters are specified in a file called application.yml, the following command should be sufficient for starting rebazer:

java -jar rebazer-VERSION.jar --spring.config.location=file:./application.yml

Docker

We provide a docker image on docker hub. An example configuration for the docker container is placed in the docker-compose.yml.

To configure the rebazer mount the configuration file at /application.yml. To optimize production setups it is recommended to mount /rebazer-workspace as an external storage or ram disk.

Example:

docker run -v $(pwd)/application.yml:/application.yml -e SPRING_CONFIG_LOCATION=file:/application.yml retest/rebazer

Debian package

Attention: We don't ship a fully functional configuration for this package. So after installation, one must ensure that a proper configuration is placed in /etc/rebazer. Also make sure that the configuration file is accessible by the user rebazer.

This package automatically creates:

  • System user for running rebazer
  • Proper logging via systemd/syslog (to /var/log/rebazer)
  • Systemd service named rebazer.service
  • Workspace in /var/lib/rebazer (can be configured in /etc/defaults/rebazer)

The debian package overwrites the rebazer.workspace parameter via an environment variable.

Troubleshooting

Symptom: Errors during startup

Solution: Please make sure the folder /etc/rebazer contains a valid configuration and the user rebazer has access to it.

chmod 755 /etc/rebazer
chmod 600 /etc/rebazer/application.yml
chown rebazer:rebazer /etc/rebazer/application.yml

Build

Build prerequisites

Before building the rebazer application, please make sure that the following tools are installed:

  • Java 8
  • Maven (3.3+)
  • Git

A typical build involves calling the package target via maven from the root of the cloned repository:

mvn clean package

The major artifacts are then build inside the target directory: rebazer-$VERSION.jar.

There are maven profiles to build docker or deb packages.

mvn clean package -P deb

mvn clean package -P docker

mvn clean package -P deb,docker

rebazer's People

Contributors

alig01 avatar beatngu13 avatar creepow avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar jakobherdt avatar martin-v avatar mergify[bot] avatar modulo11 avatar rebazer avatar soffietto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

rebazer soffietto

rebazer's Issues

Do not merged unrebased PRs

Should not happen:

[retest/rebazer] Feature/better exception handling (#47)
Rebase failed, this pull request needs some manual love ...

[retest/rebazer] Feature/better exception handling (#47)
@roesslerj approved this pull request.

[retest/rebazer] Feature/better exception handling (#47)
Merged #47 into develop.

BitbucketConnector.getLastPage returns wrong values

It didn't return the last commit, because it don't uses the last page. Fix: Get the actual last page, not just the last of 10 or increase the number of commits in json to display all.

Addon: Fix the misleading name of the method, e.g. getParentIdOfFirstCommitInBranch.

Clean up logs

First, we should adapt the log level globally. For instance, processing a repo or a pull request should be on DEBUG level.
Second, we should use parameterized messages via the SLF4J API.

Proper handling of external PRs

Before PR#99 rebazer crashed when trying to checkout an external PRs branch which does not exist in our origin repository. We should discuss how we want to handle this within rebazer:

  • Ignore the handling of external PRs
  • Don't try to rebase external PRs, but merge if conditions are met
  • ...

Logging to slack?

Do we want to logging informations in a separate slack channel?

https://github.com/maricn/logback-slack-appender
https://github.com/wpic/logback-slack-appender

Current log locks like:

...
Dec  1 17:11:59 rebazer rebazer[6507]: 2017-12-01 17:11:59.598  INFO 6509 --- [taskScheduler-1] o.r.rebazer.service.BitbucketService     : Processing PR976 ( feature/generic-launcher -> develop )
Dec  1 17:11:59 rebazer rebazer[6507]: 2017-12-01 17:11:59.819  INFO 6509 --- [taskScheduler-1] o.r.rebazer.service.BitbucketService     : Waiting for green builds on PR976 ( feature/generic-launcher -> develop )
Dec  1 17:11:59 rebazer rebazer[6507]: 2017-12-01 17:11:59.819  INFO 6509 --- [taskScheduler-1] o.r.rebazer.service.BitbucketService     : Processing PR977 ( feature/RET-1107-robust-rmi -> develop )
Dec  1 17:12:00 rebazer rebazer[6507]: 2017-12-01 17:12:00.500  INFO 6509 --- [taskScheduler-1] o.r.rebazer.service.BitbucketService     : Waiting for rebase on PR977 ( feature/RET-1107-robust-rmi -> develop )
Dec  1 17:12:00 rebazer rebazer[6507]: 2017-12-01 17:12:00.500  INFO 6509 --- [taskScheduler-1] o.retest.rebazer.service.RebaseService   : rebase PR977 ( feature/RET-1107-robust-rmi -> develop )
...

Fix Warning: IOException while Travis build

[WARNING] unable to get access token for Google Container Registry, configuration for building image will not contain RegistryAuth for GCR
java.io.IOException: Error code 404 trying to get security access token from Compute Engine metadata for the default service account. This may be because the virtual machine instance does not have permission scopes specified.

Cause is probably that on the travis build vm image contains some magic ENV variables or GCR build tools. This triggers the automatic support of the GCR in the docker plugin.

Support multiple repositories

ReBaZerConfig should be adapted such that multiple repositories can be defined. Therefore, we should also change how the external configuration takes place. For instance, Spring Boot also supports YAML:

rebazer:
   user: service_user
   pass: dont_use_this_pass_at_home
   team: your_company
   workspace: ./rebazer-workspace
   repos:
       - foo
       - bar
       - baz

Make rebazer work with no builds

When no builds have been configured (yet), let the rebazer still work just when someone approved it. There were some ideas flying around how to implement it (e.g. is there a special result when asking for build status, ... ).

However this may result in that there will be no changes on some hosts if there is no build, thus the logic for merging would need refactoring.

Merge after one approval or after approval of all reviewers?

As default I like one approval, but sometimes I want explicit that all approver must review the code.

I suggest implementing a support of '@ALL' in the title of a pull request. Benefits:

  • It's visible in the overview of pull requests
  • Simple to implement
  • Works with all type of git hosting platforms

Change merge message from "Branch merged by ReBaZer" to include more infos

Prviously, a merge message looked like

Merged in fix/not-selected-combo-box (pull request #723)

Fix combobox selection according to specification

Approved-by: Johannes Dillmann <[email protected]>

which contained information about the branch name and pull request number. That information is in the current version of the merge message missing. Can we readd it to something like (suggestions):

Merged in fix/not-selected-combo-box (pull request #723) by ReBaZer

Replace deprecated basic auth

During compile-time these warnings are shown:

[WARNING] GithubConnector.java:[25,35] basicAuthorization(java.lang.String,java.lang.String) in org.springframework.boot.web.client.RestTemplateBuilder has been deprecated
[WARNING] BitbucketConnector.java:[27,49] basicAuthorization(java.lang.String,java.lang.String) in org.springframework.boot.web.client.RestTemplateBuilder has been deprecated
[WARNING] BitbucketConnector.java:[29,43] basicAuthorization(java.lang.String,java.lang.String) in org.springframework.boot.web.client.RestTemplateBuilder has been deprecated

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.