Giter VIP home page Giter VIP logo

approveman's Introduction

logo

All Contributors

⚠️ Sunset Notice ⚠️

TODO(@tianhaoz95): add future plans and migration guide.

What are not going to change:

  • The project can still be self-hosted (Heroku or as a GitHub action, see https://probot.github.io/docs/deployment for details).
  • I will still maintain the project health including getting dependencies up-to-date and merging code contributions.

What are changing:

  • There will not be hosted services.
  • There won't be new features planned.

Repository status

Gitpod ready-to-code Codacy Badge Total alerts Run Tests codecov CodeQL Release Drafter

ApproveMan is a GitHub app that helps approve pull requests with safe changes.

Motivation

To maintain the health of repositories, it's important to set up review policies to make sure every pull request is good.

GitHub provides "protected branches" as a way to enforce code review policies on incoming pull requests.

However, not all pull requests require human attention.

For example, it's reasonable for a repository to set up a location with a user's GitHub ID like [project_root]/playground/${username} to allow developers add quick experiments that they want to keep a record and share with the team.

In this case, if I want to add some notes in [project_root]/playground/${username}/my-note.md, there is no reason to ask another developer to review the change.

Usage

For GitHub

The app can be installed from the GitHub Marketplace.

You can configure the behavior by adding rules into .github/approveman.yml.

Here is an example that, given that my GitHub ID is tianhaoz95, approves all my changes that go into playground/tianhaoz95 and docs/personal/tianhaoz95:

ownership_rules:
  directory_matching_rules:
    - name: personal projects in experimental
      path: playground/{{username}}/**/*
    - name: personal documentation
      path: docs/personal/{{username}}/**/*

Note:

  • The default config contains playground/{{username}}/**/* if no config file is provided in the repository.
  • All pull requests that modify files within .github the directory is denied regardless of the rules in the configuration for safety.
  • The globstar matches only the directories. More specifically, if you want all Markdown files in a directory, please use playground/{{username}}/**/*.md instead of playground/{{username}}/**.md which might work with some of the matching package variances.

Here is an example of how it works:

approval demo

check status demo

For GitHub Enterprise

Run with container

After setting GHE_HOST, APP_ID, WEBHOOK_PROXY_URL, WEBHOOK_SECRET, use the following command to start the server:

sudo docker run \
    --env GHE_HOST \
    --env APP_ID \
    --env WEBHOOK_PROXY_URL \
    --env WEBHOOK_SECRET \
    ghcr.io/tianhaoz95/approveman-server:v1.1.2 

For more details, see GitHub Container Registry.

Run locally

To run a server for GitHub Enterprise, please also set GHE_HOST and APP_ACTOR_NAME_OVERRIDE before running the server:

# This will be the custom domain for your GitHub Enterprise
export GHE_HOST="github.example.com"

# The following is just an example, you will need to set it to
# the app's actor name that you assign it with in GitHub Enterprise
# integration.
export APP_ACTOR_NAME_OVERRIDE="project-name__approveman[bot]"

npm run build # Build the TypeScript source
npm start # Start the server

After the server is up and running, the rest should be the same as the GitHub setup.

Available config

The following is a full configuration with default values:

ownership_rules:
  # If files inside .github directory should be allowed.
  # When it is set of true, rules like .github/workflows/playground__{{username}}-*.yml
  # can be enable with certain rules.
  # When it is set of false (default value), a pull request will not be approved
  # reguardless of rules if any files inside the .github folder is touched.
  allow_dot_github: false
  # A list of usernames that should not get their pull requests approved even
  # validated by rules. This can be used when some users are spotted to abuse
  # the auto approval and checks in unwanted content that violates the code of
  # conduct or other policies set by the owner.
  global_blacklisted_users: []
  # An optional list of usernames that should get their pull requests approved if
  # validated by rules. This can be used when only some users are trusted "commit
  # directly to the default branch", but you still want repository checks to be run for
  # their changes.  If not specified or empty, all users are considered to be "allowed".
  # This is also useful for automation usecases, automatically approving PRs created by
  # specific machine users.
  # N.B. Where a user is both "allowed" and "blacklisted", blacklisting takes precedence.
  global_allowed_users: []
  # The rules for matching directory ownership. A pull request is determined to be safe
  # when all the files modified satisfy at least one of the rules.
  directory_matching_rules:
      # The name of the rules that is used mainly for logging.
    - name: "Default playground rule for prototyping."
      # The directory that certain user with {{username}} owns.
      path: "playground/{{username}}/**/*"

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Tianhao Zhou

💻 📖

gnod

🐛

David Monks

💻 📖

This project follows the all-contributors specification. Contributions of any kind welcome!

approveman's People

Contributors

allcontributors[bot] avatar dependabot-preview[bot] avatar dependabot[bot] avatar scalen avatar tianhaoz95 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

approveman's Issues

Add optional config to customize approving messages

It would be a good indicator for the new contributors to see useful information about how ApproveMan is doing right from the pull request comments.

A quick draft design:

ownership_rules:
  message:
    success: |
      "Thanks {{username}} for opening the request!"
  directory_matching_rules:
    - name: personal projects in experimental
      path: playground/{{username}}/**/*
    - name: personal documentation
      path: docs/personal/{{username}}/**/*
      message:
      success: |
        "Thanks {{username}} for opening the request!"

The message can be global or fine grained to be project specific.

We can make it into 2 steps where the first one is global only and the second one is supporting project specific message.

Add contributor: <mohan>

@all-contributors please add <mohan> for <contributions>

Hi team, thanks for this information.
I do have a similar task in my repository we have (qa,uat, and staging). I'm trying to automate the code approval to automate to uat and staging.
Example: I have opened the feature branch pull request and got the reviews and merge code. So the same feature branch pull request is opened to merge code uat and stage, I need to add a status check to tell that the same feature branch has got approval in qa so no need for additional reviews in uat so automatically approves the review in uat and staging.

Can you please tell me how to do this we are not using "GitHub actions" but need to achieve without actions?

Pease can you give me a path forward.

[BUG] Whoops! An unknown error occured.

Describe the bug
We have approveman running on our repo. Sometimes it would report "Whoops! An unknown error occured." while checking a PR. We've been using it for the last 2 business days and it happened twice.

To Reproduce
The bug is not easily reproducible.

Expected behavior
Approveman should be able to check a PR and approve (or ignore) without failing and reporting an error.

Screenshots
Crash 1:
Screen Shot 2022-02-01 at 6 37 27 PM

Crash 2:
Screen Shot 2022-02-01 at 6 36 29 PM

Additional context
Add any other context about the problem here.

[FEAT] Add capabilities to blacklist or whitelist usernames

Is your feature request related to a problem? Please describe.
In case some users are checking in shady stuff, there should be a way to control who is allowed to check in stuff at all.

Describe alternatives you've considered
Can't think of any.

Explore if GHE app actor name can be supported with get app API

You may try to use the authenticated app endpoint. It returns the configured name, id, avatar, and even the html_url and external_url, which might be interesting for status posts.
I don't now much about probot app development, so it is just a guess. As we are building the app from source, a central modifiable variable would already do the trick. Also ENV during build-time or runtime would work. As you asked for examples for our naming schemes, we prefix the apps usually with an organization name separated with -. However, I do not recommend to stick to this in your app.

Referenced from the original issue #64

approveman does not support deviating appname

I built and installed this app on a GitHub enterprise server and prefixed the app name with our project name (as gh enterprise does not scope apps). So then the name of the app (and hence the reviewing "user") was not approveman[bot] as hard coded in the code. Thus, the app was not able to dismiss its own review.

[FEAT] initialize a CLI infra

Is your feature request related to a problem? Please describe.
There are things about the config that users want to check before submitting anything into the repository. For example, if the configuration file is valid at all or what will it do to a certain pull request.

Describe the solution you'd like
Initialize a CLI infra that shares code with the app.

Describe alternatives you've considered
Not much

Additional context
N/A

Add documentation for enterprise usage

It was recently brought to my attention that enterprise GitHub is drastically different from the GitHub in terms of apps, so a dedicated documentation for enterprise server usage can be helpful.

[FEAT] Good to accept comment commands

Is your feature request related to a problem? Please describe.
It would be good to give user a way to interact with the app instead always have it passively listening. For example, if it is for some reason not re-checking the status after an update (maybe the server load peaked), users can post a checking command to prompt it to do its job.

Describe the solution you'd like
Add an infra to listen to comments.

Describe alternatives you've considered
A site to add commands or a CLI. I would say CLI might be a good idea by itself, but site it too much work TBH.

Additional context
None

[BUG] HTTPError: Not Found

Describe the bug
When creating a PR, the Approveman check failed (not neutral, but failed) with the following error:

HttpError: Not Found
at /app/node_modules/@octokit/request/dist-node/index.js:86:21
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async sendRequestWithRetries (/app/node_modules/@octokit/auth-app/dist-node/index.js:454:12)
at async Job.doExecute (/app/node_modules/bottleneck/light.js:405:18)

To Reproduce
Steps to reproduce the behavior:

  1. Add Approveman to your repo.
  2. Configure it with limited scope for auto-approved changes (this happened with an allow-listed user, but it isn't clear if that is related).
  3. Create a PR (with an allowed user) containing changes outside of the defined scope.
  4. See error.

Expected behavior
The Approveman check should not succeed, but should complete with a neutral status.

Screenshots
image

[FEAT] maybe add a docker image to make GitHub Enterprise usage easier

Is your feature request related to a problem? Please describe.
Now users need to fork the repo and do a bunch of operations to get it running on GitHub Enterprise.

Describe the solution you'd like
Run a docker command and done.

Describe alternatives you've considered
There are many alternatives but none seems as effortless.

Additional context
Add any other context or screenshots about the feature request here.

Status not complete

Seems that the status only post a complete check mark if there is a rule match. Check if that is the case.

[BUG] ApproveMan not selectable as reviewer

Describe the bug
We've got a private repo (github.com/CamusEnergy/bando), for which we're trying to set up ApproveMan. I'm doing testing on my private fork with the same configuration (github.com/EnergySRE/bando), and seeing the same behavior in both places.

To Reproduce
Steps to reproduce the behavior:

  1. Install ApproveMan with org-level permissions from GitHub Marketplace
  2. Set "Repository access" to "All repositories"
  3. Create a branch with the config below*
  4. ApproveMan appears in the automated checks on the PR (screen shot below)
  5. ApproveMan does not appear as an option on the reviewer list

I also tried adding ApproveMan as an authorized user to our organization, and receive a "no such user" error.

Expected behavior
I expect to be able to select ApproveMan as a reviewer and have it approve my PR based on the content of my config.

Screenshots

Automated checks pass:

Screen Shot 2022-01-14 at 11 34 48 AM

ApproveMan not selectable as reviewer:

Screen Shot 2022-01-14 at 11 40 25 AM

Additional context

Here's the config we're using:

ownership_rules:
  directory_matching_rules:
    - name: Markdown-only changes
      path: **/*.md
    - name: Doc folder
      path: doc/*

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.