Set up the bot as developer - Refactoring-Bot/Refactoring-Bot GitHub Wiki
Prerequisites...
...to run the bot
- 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
ordocker-compose
. In this MySQL instance, you need to create a schema with the namerefactoringbot_db
and make sure the user for the bot has access rights to this schema. - Git must be installed.
- 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
- Results of the static code analysis is available (e.g. via sonarcloud or a local SonarQube instance).
- 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
- Repository needs to be publicly hosted on a file hosting service (GitHub/GitLab).
Project setup
- Import the project as maven project to your IDE.
- In your IDE, copy the configuration file
src/main/resources/application_example.yml
and rename it tosrc/main/resources/application.yml
. - 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 commandmvn install
to create the executable JAR file for the bot and run the created JAR file viajava -jar ./target/RefactoringBot-0.0.1-SNAPSHOT.jar
. - The API should now be available at
http://localhost:8808
and the SwaggerUI will open in the browser. - Go to the Configuration-Controller and create a configuration*. Here we basically define which account should be used on which repository.
- 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"
}