Set up the bot as developer - Refactoring-Bot/Refactoring-Bot GitHub Wiki

Prerequisites...

...to run the bot

  1. The bot needs access to a MySQL DB instance to save its data. Use an existing one, download MySQL for your OS, or refer to our Docker Repository for detailed usage instructions with docker or docker-compose. In this MySQL instance, you need to create a schema with the name refactoringbot_db and make sure the user for the bot has access rights to this schema.
  2. Git must be installed.
  3. The commits and pull requests are created under a specific account. You can either use your existing GitHub/GitLab account or create a new one. In any case you need to generate and provide an API token.

...to perform refactorings based on static code analysis

  1. Results of the static code analysis is available (e.g. via sonarcloud or a local SonarQube instance).
  2. A unique Project Key of the hosted project must be available for the API access of the analysis service.

...for the project you would like to refactor with comments from pull-requests

  1. Repository needs to be publicly hosted on a file hosting service (GitHub/GitLab).

Project setup

  1. Import the project as maven project to your IDE.
  2. In your IDE, copy the configuration file src/main/resources/application_example.yml and rename it to src/main/resources/application.yml.
  3. Run the project as Spring-Project. If you use Eclipse, run as maven build... and add spring-boot:run to the goals.
    OR Execute the command mvn install to create the executable JAR file for the bot and run the created JAR file via java -jar ./target/RefactoringBot-0.0.1-SNAPSHOT.jar.
  4. The API should now be available at http://localhost:8808 and the SwaggerUI will open in the browser.
  5. Go to the Configuration-Controller and create a configuration*. Here we basically define which account should be used on which repository.
  6. If successful, go to the Refactoring-Controller and perform refactorings with comments from pull-requests or from a static code analysis. You will have to chose the configuration you want to use with the configuration ID.

*example configuration:

{  
  "analysisService": "sonarqube",  
  "analysisServiceApiLink": "https://sonarcloud.io/api",
  "analysisServiceProjectKey": "Bot-Playground:Bot-Playground",
  "botEmail": "[email protected]",
  "botName": "Samantha-Bo",
  "botToken": "12345abc678d9efg",
  "maxAmountRequests": 2,
  "repoName": "Bot-Playground",
  "repoOwner": "Refactoring-Bot",
  "repoService": "github"
}

See also