Coffee Reviews in 🦀
Get a notification about pending Merge Requests for your (team's) projects.
Got time for a coffee? Why not reviewing some code while enjoying it?
- Rust >= 1.40
- Clone this project
- Build the application by executing
cargo build
The presence of a configuration file is required. JSON and TOML formats are supported. This file contains all possible configuration options needed to run the project. Refer to the sample files to get an overview of these options.
Before starting be sure to have obtained a Gitlab API Token to authenticate the requests.
Once you have the authentication token include it in the configuration file in the gitlab
section. Example in JSON:
{
"gitlab": {
"base_url": "https://gitlab.com/api/v4",
"token": "here-goes-your-token"
},
[...]
}
gitlab.base_url = "https://gitlab.com/api/v4"
gitlab.token = "your-token"
Other configuration options are available, please check the JSON and TOML attached to this project.
An application webhook is required to receive messages in Slack. You can create one by registering an application. Please proceed as specified in the official Slack documentation.
Once you have your webhook URL include it in the configuration file. Example:
{
[...]
"publish": {
"slack": {
"webhook_url": "https://hooks.slack.com/services/yourappwebhook-url"
}
}
}
publish.slack.webhook_url = "https://hooks.slack.com/yourappwebhook-url"
To receive the messages a connector for incoming webhook needs to be created in your channel. Proceed as specified in the Teams documentation.
Once you have registered the connector in your channel you can specify the url in the configuration settings.
{
[...]
"publish": {
"teams": {
"webhook_url": "https://url.outlook.com/webhooks/your-webhook-url"
}
}
}
publish.teams.webhook_url = "https://domain.webhook.office.com/yourwebhookconnector-url"
Create a config.json
or config.toml
file that would include all your configuration settings.
Then execute:
cargo run -- -c /path/to/configfile
This command will print a message indicating the Merge Requests posted and a confirmation on the number of messages posted (all merge requests go in one message).
If all is configured correctly you should be able to see something like
Posted 4 Merge Requests. Successful posts: 1
And the corresponding message in your channel.
If you don't specify a path to your config file using -c /path/to/configfile
the program will assume that a config.json
resides in the current path.
Currently the messages are preceeded by:
Hi! There are some Merge Requests to review :)
The best use case scenario is when this script is executed by a Cron job.
Can be quickly resumed as follows.
- Build the release binary
$ cargo build --release
This creates a target/release folder inside the project's folder that includes the executable file coffee-rustviews
.
- Edit your cron jobs to execute the program.
For example
0 9 * * * /path/to/target/release/coffee-rustviews -c /path/to/configfile
Will execute the script everyday at 09:00 hrs.