ruleset:
  label_bugs:
    name: "Label issues as bug"
    events: [ issues ]
    label: bug
    when:
      - body contains "[x] Bug"
      - action = "opened" or action = "reopened"

  short_description:
    name: "Close issues with short descriptions"
    events: [ issues, pull_request ]
    close: true
    label: invalid
    when: length(body) < 50
    message: >
      "Please add a longer description of your issue. Body needs to be 50 characters."

  remove_invalid:
    name: "Remove invalid tag when issue re-opened"
    events: [ issues, pull_request ]
    label: -invalid
    when:
      - action = "reopened"
      - filter(labels, "name") has "invalid"

  require_tests:
    name: Require unit tests for pull requests
    events: pull_request
    when:
    - action = "opened"
    - count(filter(files, "[name=/^src\/]")) > 1
    - count(filter(files, "[name=/^tests\/]")) = 0
    message: >
      "@{{ user.login }}, remember that all pull requests should be accompanied
      with unit tests per our contributing guidelines. Please `/cc` one of our maintainers
      if you need help with this!"
