<commit_before>[![Build Status](https://travis-ci.org/bivas/rivi.svg?branch=development)](https://travis-ci.org/bivas/rivi)
[![Go Report Card](https://goreportcard.com/badge/github.com/bivas/rivi)](https://goreportcard.com/report/github.com/bivas/rivi)

# rivi
Automate your review process with Rivi the review bot

## Usage
```
Usage of rivi:
  -config string
    	Bot configuration file
  -port int
    	Bot listening port (default 8080)
  -uri string
    	Bot URI path (default "/")
```
### Example
```
$ rivi -port 9000 -config repo-x.yaml
```

## Requirements

- Create a token with `repo` persmissions
- Create a webhook and make sure the following are configured:


  - Select **content type** as `application/json`
  - Optionally, set a **secret** (this will be used by the bot to validate webhook content)
  - Register the following events
    - Pull request
    - Pull request review
    - Pull request review comment

# Configuration File Structure

## Config Section

Configure the Git client for repository access and webhook validation
```yaml
config:
  provider: github
  token: my-very-secret-token
  secret: my-hook-secret-shhhhh 
```

- `token` (required) - the client OAuth token the bot will connect with (and assign issues, add comments and lables)
- `provider` (optional) - which client to use for git connection - the bot tries to figure out which client to use automatically (currently only `github` is supported but others are on the way)
- `secret` (optional) - webhook secret to be used for content validation (recommended)

## Roles Section

List of roles for selecting (login) users for assignment. 
```yaml
roles:
  admins:
      - user1
      - user2
  reviewers:
      - user3
      - user4
  testers:
      - user2
      - user4
```

## Rules Section

Configure rules to be processed by the bot on each issue event
### Structure

```yaml
rules:
  rule-name1:
    <condition>
    <action-name>
  rule-name2:
    <condition>
    <action-name>
...
```

### Example
```yaml
rules:
  rule-name:
      condition:
        if-labeled:
          - label1
          - label2
        skip-if-labeled:
          - label3
        filter:
          pattern: "docs/.*"
          extension: ".go"
      commenter:
        comment: "We have a match!"
```
### Condition

The entire `condition` section is optional - you can run all rules all the time and see if it helps :smile:
- `if-labeled` - apply the rule if the issue has any of the provided labels
- `skip-if-labeled` - skip rule processing if issue has any of the provided labels
- `filter`
  - `pattern` - [pattern](https://golang.org/s/re2syntax) matching the pull request file list
  - `extension` - which file extension to match on pull request file list (must start with a dot [`.`])

### Available Actions
- [`autoassign`](bot/actions/autoassign/autoassign.md) - Automatic assignment of issue reviewers
- [`automerge`](bot/actions/automerge/automerge.md) - Automatic merge for approved pull requests
- [`commenter`](bot/actions/commenter/commenter.md) - Add comment to an issue
- [`labeler`](bot/actions/labeler/labeler.md) - Add label to an issue
- [`sizing`](bot/actions/sizing/sizing.md) - Size a pull request
- [`trigger`](bot/actions/trigger/trigger.md) - Send HTTP triggers<commit_msg>update rules for multiple actions support<commit_after>[![Build Status](https://travis-ci.org/bivas/rivi.svg?branch=development)](https://travis-ci.org/bivas/rivi)
[![Go Report Card](https://goreportcard.com/badge/github.com/bivas/rivi)](https://goreportcard.com/report/github.com/bivas/rivi)

# rivi
Automate your review process with Rivi the review bot

## Usage
```
Usage of rivi:
  -config string
    	Bot configuration file
  -port int
    	Bot listening port (default 8080)
  -uri string
    	Bot URI path (default "/")
```
### Example
```
$ rivi -port 9000 -config repo-x.yaml
```

## Requirements

- Create a token with `repo` persmissions
- Create a webhook and make sure the following are configured:


  - Select **content type** as `application/json`
  - Optionally, set a **secret** (this will be used by the bot to validate webhook content)
  - Register the following events
    - Pull request
    - Pull request review
    - Pull request review comment

# Configuration File Structure

## Config Section

Configure the Git client for repository access and webhook validation
```yaml
config:
  provider: github
  token: my-very-secret-token
  secret: my-hook-secret-shhhhh 
```

- `token` (required) - the client OAuth token the bot will connect with (and assign issues, add comments and lables)
- `provider` (optional) - which client to use for git connection - the bot tries to figure out which client to use automatically (currently only `github` is supported but others are on the way)
- `secret` (optional) - webhook secret to be used for content validation (recommended)

## Roles Section

List of roles for selecting (login) users for assignment. 
```yaml
roles:
  admins:
      - user1
      - user2
  reviewers:
      - user3
      - user4
  testers:
      - user2
      - user4
```

## Rules Section

Configure rules to be processed by the bot on each issue event. Each rule may have several actions.
### Structure

```yaml
rules:
  rule-name1:
    <condition>
    <action-name>
    <action-name>
    <action-name>
    ...
  rule-name2:
    <condition>
    <action-name>
...
```

### Example
```yaml
rules:
  rule-name:
      condition:
        if-labeled:
          - label1
          - label2
        skip-if-labeled:
          - label3
        filter:
          pattern: "docs/.*"
          extension: ".go"
      commenter:
        comment: "We have a match!"
      labeler:
        label: ready-for-review
```
### Condition

The entire `condition` section is optional - you can run all rules all the time and see if it helps :smile:
- `if-labeled` - apply the rule if the issue has any of the provided labels
- `skip-if-labeled` - skip rule processing if issue has any of the provided labels
- `filter`
  - `pattern` - [pattern](https://golang.org/s/re2syntax) matching the pull request file list
  - `extension` - which file extension to match on pull request file list (must start with a dot [`.`])

### Available Actions
- [`autoassign`](bot/actions/autoassign/autoassign.md) - Automatic assignment of issue reviewers
- [`automerge`](bot/actions/automerge/automerge.md) - Automatic merge for approved pull requests
- [`commenter`](bot/actions/commenter/commenter.md) - Add comment to an issue
- [`labeler`](bot/actions/labeler/labeler.md) - Add label to an issue
- [`sizing`](bot/actions/sizing/sizing.md) - Size a pull request
- [`trigger`](bot/actions/trigger/trigger.md) - Send HTTP triggers
{'fraction_non_alphanumeric': 0.11364994026284349, 'fraction_numerical': 0.005973715651135006, 'mean_word_length': 3.1365040148239656, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1387116', 'n_tokens_mistral': 2065, 'n_tokens_neox': 1976, 'n_words': 713}