All Projects β†’ crawford β†’ tailor

crawford / tailor

Licence: Apache-2.0 license
GitHub bot that validates patches before they can be merged

Programming Languages

rust
11053 projects
HTML
75241 projects

Projects that are alternatives of or similar to tailor

aloba
πŸ€– [Myrmica Aloba 🐜] Bot: Add labels and milestone on pull requests and issues.
Stars: ✭ 18 (+0%)
Mutual labels:  github-bot, pull-requests
scalafmt-probot
πŸ€–Github bot for checking code formatting with scalafmt
Stars: ✭ 15 (-16.67%)
Mutual labels:  github-bot, pull-requests
github-rebase-bot
A github bot that monitors repository PRs, rebases them and merges them as they pass tests
Stars: ✭ 29 (+61.11%)
Mutual labels:  github-bot, pull-requests
lobicornis
πŸ€– [Myrmica Lobicornis 🐜] Bot: Update and Merge Pull Request
Stars: ✭ 27 (+50%)
Mutual labels:  github-bot, pull-requests
chewbacca
Chewbacca GitHub Bot
Stars: ✭ 16 (-11.11%)
Mutual labels:  github-bot
container-builder-github-ci-status
Google Cloud Function responds to PubSub events on the cloud-builds topic to update GitHub CI status.
Stars: ✭ 23 (+27.78%)
Mutual labels:  github-bot
check-in
Checks your test results metadata into github, commit-bound. Acts as a bot. You'll need a GitHub App to use it.
Stars: ✭ 18 (+0%)
Mutual labels:  github-bot
term-check
A GitHub app which runs checks for flagged terminology in GitHub repos
Stars: ✭ 19 (+5.56%)
Mutual labels:  github-bot
redmine merge request links
Display links to associated Gitlab merge requests and GitHub pull requests on Redmine's issue page.
Stars: ✭ 32 (+77.78%)
Mutual labels:  pull-requests
performabot
Continuous performance analysis reports for software projects πŸ€–
Stars: ✭ 40 (+122.22%)
Mutual labels:  github-bot
github-clear-merged-pull-requests
Clear merged pull requests ref (branch) on GitHub
Stars: ✭ 12 (-33.33%)
Mutual labels:  github-bot
Open-Source-Enthusiast
Showcase Your Programming Skills here without hesitation
Stars: ✭ 102 (+466.67%)
Mutual labels:  pull-requests
release-changelog-builder-action
A GitHub action that builds your release notes / changelog fast, easy and exactly the way you want.
Stars: ✭ 515 (+2761.11%)
Mutual labels:  pull-requests
BastionGitHubBot
πŸš€ A GitHub bot to automate common tasks in GitHub.
Stars: ✭ 15 (-16.67%)
Mutual labels:  github-bot
gitbot
The most popular Discord dev toolkit with 400k+ users πŸš€βœ¨
Stars: ✭ 59 (+227.78%)
Mutual labels:  github-bot
zorechka-bot
Github bot for keeping your Bazel dependencies up-to-date and clean
Stars: ✭ 25 (+38.89%)
Mutual labels:  github-bot
prlint
GitHub App for linting pull request meta data
Stars: ✭ 122 (+577.78%)
Mutual labels:  pull-requests
showmyprs.com
See all your Open Source contributions in one place
Stars: ✭ 30 (+66.67%)
Mutual labels:  pull-requests
Hamster
πŸ€ A Bot toolkit for github that supports OAuth, Events, API, Custom Commands and Check Runs.
Stars: ✭ 40 (+122.22%)
Mutual labels:  github-bot
GitInfo-Git-for-Google-Assistant
GitInfo is a conversational data retrieval bot for Github repositories. It provides a conversational experience to access information. Information that can be retrieved using GitInfo include: stars, latest commit details , no of forks , no of issues etc.
Stars: ✭ 18 (+0%)
Mutual labels:  github-bot

Tailor

Tailor pull requests to your liking.

Tailor is a GitHub bot which can be used to validate that pull requests comply with a set of rules. It can be used for example to ensure that commit messages are properly formatted, that commits are properly structured, or that pull requests have particular labels.

Usage

Repository Configuration

Each repository contains its own rules and configuration. This makes it easy to version the configuration alongside the code. The configuration is stored in /.github/tailor.yaml and has the following structure:

# This is the list of rules that are applied to each of the pull requests to
# the repository.
rules:

    # The name is used as an identifier and can be used in the admin commands.
  - name:        commit title

    # The description is printed in the status messages to inform the submitter
    # of what is wrong with their pull request.
    description: all commit titles are less than or equal to 50 characters

    # The expression describes the rule itself. Refer to the language
    # documentation for an overview of the available functionality.
    expression:  .commits all(.title length < 51)

Each of the rules are run on the entire pull request (the root context). They are run independently and cannot influence one another. Often times, it is useful to use .commits all to run an expression on each of the commits in the pull request, requiring all of them to comply. This is detailed further in the Expressions section. The rule expression must result in a boolean value, true indicating a success and false a failure.

Expressions

Expressions are made up of a series of infix operators detailed below. Almost all operators have an input value (on the left) and most have an argument value (on the right). Expressions are evaluated from left to right, which the result of the previous operator feeding into the next. Parenthesis can be used to evaluate a contained expression before its surroundings.

The only operator which doesn't take an input is the context operator (.). The result of this operation is the current context. It can be further limited by using a specifier (e.g. .commits) if the context is a dictionary. Since the context operator is the only operator which doesn't take an input, all expressions must begin with it.

It might be helpful to break down a few examples.

This expression returns true if there are exactly ten commits in the pull request: .commits length = 10. Parenthesis around every operation could be added for clarity: (((.commits) length) = 10)

This expression returns true if every commit title is no more than fifty characters: .commits all(.title length < 51). This expression makes use of the all operator, which is used for manipulating lists. For every commit, the expression .title length < 51 is evaluated with the context set to the commit in question. This inner expression then uses a context specifier (.title) to get the commit title and uses length to get the length of the title and compares to see if there are more than fifty characters. If every one of the inner expressions evaluates to true, all also results in true.

There are a handful of other operators, detailed below.

Operators
Comparison
Operator Input Argument Result Description
= Any value Any value Boolean true if the values are equal
< Numeral Numeral Boolean true if the input is less than the argument
> Numeral Numeral Boolean true if the input is greater than the argument
Logical
Operator Input Argument Result Description
and Boolean Boolean Boolean true if both the input and argument are true
or Boolean Boolean Boolean true if either the input or argument are true
xor Boolean Boolean Boolean true if one of the input or argument are true
not Boolean Boolean true if the input is false
List Manipulation

Each of the list manipulation operators (except length), accepts an expression as an argument and this expression is evaluated for each of the elements in the list. The context for each expression is set to the corresponding element from the input list. As mentioned above, every expression must begin with a context operator.

Operator Input Argument Result Description
all List Expression Boolean true if all of the expression results are true
any List Expression Boolean true if any of the expression results are true
filter List Expression List List of each of the elements who's expression results in true
map List Expression List List the result of each elements expression
length List Numeral The number of elements in the list
String Manipulation
Operator Input Argument Result Description
test String String Boolean true if the argument (a regular expression) matches the input
lines String List Splits a string by newlines into a list of strings
Miscellaneous
Operator Input Argument Result Description
. Value The current context
Values

There are a few different types of values that can be used in Tailor:

  • numeral - Any positive number (e.g. 25)
  • boolean - true or false
  • string - A sequence of characters delimited by double-quotes (e.g. "this is a string"). Double-quotes and backslashes can be escaped with a backslash so they can be included in the string (e.g. "Escaped \"quotes\"")
  • list - A sequence of values delimited by brackets (e.g. [1 2 3])
  • dictionary - A mapping between strings (the key) and values (the value). These cannot be created in expressions so they are only useful for context specifiers.

Root Context

The root context is the initial input (a dictionary) into the rule expression. It is always a dictionary of values, derived from the pull request, and is of the following structure. Dictionaries are denoted by indentation, lists are denoted with brackets, and all leaf members are strings.

.
  .user
    .login
  .title
  .body
  .commits[]
    .sha
    .author
      .name
      .email
      .date
      .github_login
    .committer
      .name
      .email
      .date
      .github_login
    .title
    .description
  .comments[]
    .user
      .login
    .body
    .created_at
  .base
    .sha
    .label
    .user
      .login
  .head
    .sha
    .label
    .user
      .login

Admin Commands

In some cases, it may be necessary to grant an exemption to the rules. Repository admins can specify exemptions by commenting on the pull request with tailor disable <rule name> to disable a particular rule or tailor disable all to disable all rules. Exemptions can be removed by deleting the comment.

Setup

Building

After cloning the repository, Tailor can be built and run with cargo run. The logging verbosity can be increased by adding up to three -v flags to the invocation (cargo run -- -vvv).

Configuring GitHub

Tailor is designed to be used as a webhook. Each GitHub repository will need to be configured with a new webhook with the payload URL http://url-of-tailor-instance/hook, the content type set to application/json, and just the "Pull request" event. The token that is given to Tailor will only need to have the repo scope so that it may set statuses and access collaborators.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].