Skip to content

Commit bd76037

Browse files
authored
Merge pull request #42 from stuartmccoll/pypi-packaging-and-documentation
Updated to add correct PyPI packaging information and README.md
2 parents d3c5acc + 4317f56 commit bd76037

3 files changed

Lines changed: 76 additions & 23 deletions

File tree

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# GitLab Attendant
2+
3+
[![Build Status](https://travis-ci.org/stuartmccoll/gitlab-attendant.svg?branch=master)](https://travis-ci.org/stuartmccoll/gitlab-attendant) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4+
5+
## Description
6+
7+
The GitLab Attendant is a bot that will tidy and attend to repositories on a specified GitLab installation at a scheduled basis. Currently the bot is capable of removing merged branches, assigning project members to open issues, assigning project members to open merge requests, notifying issue assignees of due or overdue issues, and notifying assignees of stale merge requests.
8+
9+
In order to use the GitLab Attendant fully, you should create a new account within the specified GitLab installation with privileges that will allow the bot to read and write any changes necessary to branches, merge requests, issues, etc. The personal access token for this account should then be entered in the `token` paramter when calling the bot from the command line.
10+
11+
**Python 3.6** or **Python 3.7** are required to run this utility.
12+
13+
## Installation
14+
15+
This utility can be installed through [pip](https://pypi.org/project/pip/) by running the following command:
16+
17+
```shell
18+
pip install gitlab-attendant
19+
```
20+
21+
## Usage
22+
23+
```shell
24+
gitlab-attendant --ip localhost --interval 7 --token TOKEN
25+
26+
Options:
27+
--ip The IP address of the GitLab installation.
28+
--interval task scheduler interval in hours (ex. 1, 10) [default: 24]
29+
--token GitLab personal access token.
30+
```
31+
32+
This will run the GitLab Attendant process, which will begin attending to the specified GitLab installation at the first interval specified.
33+
34+
## Tests
35+
36+
Tests for this project utilise the [Pytest](https://pypi.org/project/pytest/) framework. To run the existing suite of unit tests run the following command within the root directory:
37+
38+
```shell
39+
pytest
40+
```
41+
42+
## Notes
43+
44+
All Python code has been formatted by [Black](https://github.com/ambv/black), 'the uncompromising Python code formatter'.
45+
46+
Type checking has been provided by [Pyre](https://pyre-check.org/).
47+
48+
Continuous integration is handled by [Travis CI](https://travis-ci.org/).
49+
50+
## License
51+
52+
See [LICENSE.md](LICENSE.md).

gitlab_attendant/main.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
from argparse import ArgumentParser
66

7-
from log_handlers import logger
8-
from tasks import (
7+
from gitlab_attendant.log_handlers import logger
8+
from gitlab_attendant.tasks import (
99
assign_project_members_to_issues,
1010
assign_open_merge_requests,
1111
notify_issue_assignees,
@@ -46,31 +46,32 @@ def process_arguments() -> dict:
4646

4747

4848
def tasks(args):
49-
"""
50-
Function calls to the tasks that the GitLab Attendant
51-
is capable of running.
52-
"""
53-
logger.info("GitLab Attendant has woken up...")
54-
logger.info(f"GitLab Attendant will begin attending to GitLab instance at {args['ip_address']}...")
55-
56-
assign_project_members_to_issues(args)
57-
assign_open_merge_requests(args)
58-
notify_issue_assignees(args, 7)
59-
notify_stale_merge_request_assignees(args, 7)
60-
remove_merged_branches(args)
49+
"""
50+
Function calls to the tasks that the GitLab Attendant
51+
is capable of running.
52+
"""
53+
logger.info("GitLab Attendant has woken up...")
54+
logger.info(
55+
f"GitLab Attendant will begin attending to GitLab instance at {args['ip_address']}..."
56+
)
6157

58+
assign_project_members_to_issues(args)
59+
assign_open_merge_requests(args)
60+
notify_issue_assignees(args, 7)
61+
notify_stale_merge_request_assignees(args, 7)
62+
remove_merged_branches(args)
6263

6364

6465
def main():
65-
"""
66+
"""
6667
Entrypoint to the application.
6768
"""
68-
args = process_arguments()
69-
schedule.every(int(args["interval"])).hours.do(tasks, args)
69+
args = process_arguments()
70+
schedule.every(int(args["interval"])).hours.do(tasks, args)
7071

71-
while True:
72-
schedule.run_pending()
73-
time.sleep(1)
72+
while True:
73+
schedule.run_pending()
74+
time.sleep(1)
7475

7576

7677
if __name__ == "__main__":

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="gitlab-attendant",
8-
version="1.0.0",
8+
version="0.0.1",
99
author="Stuart McColl",
1010
author_email="it@stuartmccoll.co.uk",
1111
description="A GitLab bot that tidies and attends to repositories",
@@ -17,8 +17,8 @@
1717
"console_scripts": ["gitlab-attendant=gitlab_attendant.main:main"]
1818
},
1919
packages=setuptools.find_packages(),
20-
install_requires=["requests"],
21-
tests_require=["unittest", "mock"],
20+
install_requires=["requests", "pytz", "python-dateutil", "schedule==0.5.0"],
21+
tests_require=["unittest", "mock", "pytz"],
2222
classifiers=(
2323
"Environment :: Console",
2424
"Programming Language :: Python",

0 commit comments

Comments
 (0)