Code Monkey home page Code Monkey logo

prlint-reloaded's Introduction

Uptime Robot status

Logo PRLint Reloaded

PRLint Reloaded lets you validate PR metadata using regular expressions, and then fail or pass the PR based on the validation results.

There are two installation types, GitHub App and GitHub Action. The GitHub App is faster and provides more capabilities, while the GitHub Action is more isolated and independent.

GitHub App

The GitHub App can validate various PR metadata, such as title, description, and labels. It is a copy of ewolfe/prlint wrapped in a serverless deployment.

Simple add a .github/prlint.json file to your repository and install the app from the marketplace.

Example rules:

{
  "title": [
    {
      "pattern": "^(build|ci|docs|feat|fix|perf|refactor|style|test):\\s",
      "message": "Your title needs to be prefixed with a topic"
    }
  ],
  "body": [
    {
      "pattern": "JIRA-\\d{1,4}",
      "flags": ["i"],
      "message": "You need a JIRA ticket in your description"
    },
    {
      "pattern": ".{1,}",
      "message": "You need literally anything in your description"
    }
  ],
  "head.ref": [
    {
      "pattern": "^(build|ci|docs|feat|fix|perf|refactor|style|test)/",
      "message": "Your branch name is invalid"
    }
  ],
  "assignee.login": [
    {
      "pattern": ".+",
      "message": "You need to assign someone"
    }
  ],
  "requested_teams.0.id": [
    {
      "pattern": "2691982",
      "message": "The product team needs to be added as a reviewer"
    }
  ],
  "additions": [
    {
      "pattern": "0|^[1-9]$|^[1-9]\\d$",
      "message": "Your PR is too big (over 99 additions)"
    }
  ],
  "labels.0.name": [
    {
      "pattern": "bug|enhancement|question",
      "message": "Please add a label"
    }
  ]
}

GitHub Action

The GitHub Action only validates PR titles.

Create a .github/workflows/prlint.yml file in your repository with the following content:

name: PR Lint
on:
  pull_request:
    types: ['opened', 'edited', 'reopened', 'synchronize']
jobs:
  prlint-reloaded:
    runs-on: ubuntu-latest
    steps:
      - uses: maor-rozenfeld/prlint-reloaded@v1
        with:
          title-regex: ^[A-Z][a-z]+?\s
          error-message: Your title must start with a capital letter, and a real word, e.g. 'Add GO support'
      - uses: maor-rozenfeld/prlint-reloaded@v1
        with:
          title-regex: ^\S+\s+\S+\s+\S+
          error-message: Your title must have at least three words
      - uses: maor-rozenfeld/prlint-reloaded@v1
        with:
          title-regex: ^(?!\S+ing\s)(?!\S+ed\s)
          error-message: Use imperative mood (i.e write "Fix", not "Fixed" or "Fixing")

Edit the title-regex and error-message fields to match your requirements.

prlint-reloaded's People

Contributors

maor-rozenfeld avatar yellowblood avatar

Stargazers

Konstantinos Nikoloutsos avatar Suguru Ohki avatar  avatar Ori Erel avatar Doğukan Aydoğdu avatar

Watchers

 avatar

prlint-reloaded's Issues

Conditional rules

Hi there

I am curious whether it would be possible to implement conditional linting. On PRs created by human, I would like to have strict rules which guide the developer through creating a good PR. However when PR is created via automation (f.e. Dependabot) I am in no control of the PR template, I would like to relax the rules (so I can automate the merge of the PR, which impossible if it fails :()

Cheers

bug: Additions Rules work erratically

The rules for additions seems not to work correctly, sometimes it works as expected and sometimes not.

I've tried and verified this regular expression and can't find any problems with it.

{
  "additions": [
    {
      "pattern": "^([0-9]|[1-9][0-9]|[1-4][0-9][0-9]|[5][0][0])$",
      "message": "Your PR is too big (over 500 additions)"
    }
  ]
}

Also tried this and didn't work:

{
  "additions": [
    {
      "pattern": /^([0-9]|[1-9][0-9]|[1-4][0-9][0-9]|[5][0][0])$/,
      "message": "Your PR is too big (over 500 additions)"
    }
  ]
}

Reviewers check issue

Hello;
We want to check reviewers of Pull request
We are using requested_reviewers.0.id for this but when everybody approved or commented our pull request this field is throwing error. I think this is just checking reviewers who does not answer. How can we solve this issue ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.