Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
hexylena committed Sep 15, 2015
0 parents commit e87ab6e
Show file tree
Hide file tree
Showing 6 changed files with 691 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Created by https://www.gitignore.io/api/python

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

cache.sqlite
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Proper Prior PR Planning

Simple bot to comment on GitHub repositories to help guide repository
maintenance. This includes things like ensuring enough members of the core team
+1 a pull request, and otherwise help ensure that procedures are consistently
followed for merging of PRs.

## How it works

- run the script as regularly as seems reasonable (and stays within your GH API
limits)
- the script fetches all pull requests for a repository
- this data is compared against a list
- those that have changed since last time are investigated individually
- various filters are applied to the PR, with user-defined behaviour resulting
if the PR matches a filter
- the database is updated


## Example Run

Our first run we watch the bot find a PR (#1), and evaluate a number of states.
It finds that the PR is open, it doesn't contain `[PROCEDURES]`, and that it
has one or more `:+1:` votes (emoji required)

```log
(env)hxr@leda:~/work/p4$ python process.py
INFO:root:Registered PullRequestFilter Check PRs to dev for mergability
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.github.com
DEBUG:requests.packages.urllib3.connectionpool:"GET /repos/erasche/gx-package-caching/pulls?per_page=100&state=open&page=1 HTTP/1.1" 200 None
INFO:root:Built PullRequest #1 Testing change for p4
DEBUG:root:Found 1 PRs to examine
DEBUG:root:[Check PRs to dev for mergability] Evaluating state open for <#1 "Testing change for p4" by @erasche>
DEBUG:root:[Check PRs to dev for mergability] Evaluating title_contains__not [PROCEDURES] for <#1 "Testing change for p4" by @erasche>
DEBUG:root:[Check PRs to dev for mergability] Evaluating plus__ge 1 for <#1 "Testing change for p4" by @erasche>
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.github.com
DEBUG:requests.packages.urllib3.connectionpool:"GET /repos/erasche/gx-package-caching/issues/1/comments?per_page=100&page=1 HTTP/1.1" 200 None
DEBUG:root:[Check PRs to dev for mergability] Evaluating to_branch master for <#1 "Testing change for p4" by @erasche>
INFO:root:Matched Check PRs to dev for mergability
INFO:root:Executing action
```

The second time around our state is stored in the database, so we fail to find
any PRs that need comments.

```
(env)hxr@leda:~/work/p4$ python process.py
INFO:root:Registered PullRequestFilter Check PRs to dev for mergability
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.github.com
DEBUG:requests.packages.urllib3.connectionpool:"GET /repos/erasche/gx-package-caching/pulls?per_page=100&state=open&page=1 HTTP/1.1" 200 None
2015-09-15 02:07:00 2015-09-15 02:07:00
DEBUG:root:Found 0 PRs to examine
```
64 changes: 64 additions & 0 deletions conf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
meta:
database_path: ./cache.sqlite
bot_user: erasche

repository:
owner: galaxyproject
name: galaxy
pr_approvers:
- martenson
- afgane
- bgruening
- blankenberg
- carlfeberhard
- dannon
- davebx
- erasche
- guerler
- jennaj
- jgoecks
- jmchilton
- jxtx
- natefoo
- nekrut
- nitesh1989
- nsoranzo
- tnabtaf
filters:
-
name: Check Procedures PRs for mergability
conditions:
- state: 'open'
- title_contains: '[PROCEDURES]'
- older_than: 168 hours ago
- plus__gt: 5
- minus__eq: 0
actions:
-
action: comment
comment: "{author}'s PR has reached the threshold of 168 hours and quorum of at least 5 binding +1 votes. One of the maintainers is now bound to merge this PR."
#-
#action: merge
#comment: "Automatically merged by Galaxy Jenkins Github Bot"
-
name: Check PRs to dev for mergability
conditions:
- state: 'open'
- title_contains__not: '[PROCEDURES]'
- plus__ge: 1
- to_branch: dev
actions:
-
action: comment
comment: "{author}'s PR has reached the required number of votes for merging. Does anyone wish to do this?"
-
name: Check bugfix PRs for mergability
conditions:
- state: 'open'
- title_contains__not: '[PROCEDURES]'
- plus__ge: 2
- to_branch__not: dev
actions:
-
action: comment
comment: "{author}'s PR has reached the required number of votes for merging. Does anyone wish to do this?"
Loading

0 comments on commit e87ab6e

Please sign in to comment.