Skip to content

Commit

Permalink
Merge pull request #42 from stuartmccoll/pypi-packaging-and-documenta…
Browse files Browse the repository at this point in the history
…tion

Updated to add correct PyPI packaging information and README.md
  • Loading branch information
stuartmccoll committed Aug 10, 2018
2 parents d3c5acc + 4317f56 commit bd76037
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 23 deletions.
52 changes: 52 additions & 0 deletions README.md
@@ -0,0 +1,52 @@
# GitLab Attendant

[![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)

## Description

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.

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.

**Python 3.6** or **Python 3.7** are required to run this utility.

## Installation

This utility can be installed through [pip](https://pypi.org/project/pip/) by running the following command:

```shell
pip install gitlab-attendant
```

## Usage

```shell
gitlab-attendant --ip localhost --interval 7 --token TOKEN

Options:
--ip The IP address of the GitLab installation.
--interval task scheduler interval in hours (ex. 1, 10) [default: 24]
--token GitLab personal access token.
```

This will run the GitLab Attendant process, which will begin attending to the specified GitLab installation at the first interval specified.

## Tests

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:

```shell
pytest
```

## Notes

All Python code has been formatted by [Black](https://github.com/ambv/black), 'the uncompromising Python code formatter'.

Type checking has been provided by [Pyre](https://pyre-check.org/).

Continuous integration is handled by [Travis CI](https://travis-ci.org/).

## License

See [LICENSE.md](LICENSE.md).
41 changes: 21 additions & 20 deletions gitlab_attendant/main.py
Expand Up @@ -4,8 +4,8 @@

from argparse import ArgumentParser

from log_handlers import logger
from tasks import (
from gitlab_attendant.log_handlers import logger
from gitlab_attendant.tasks import (
assign_project_members_to_issues,
assign_open_merge_requests,
notify_issue_assignees,
Expand Down Expand Up @@ -46,31 +46,32 @@ def process_arguments() -> dict:


def tasks(args):
"""
Function calls to the tasks that the GitLab Attendant
is capable of running.
"""
logger.info("GitLab Attendant has woken up...")
logger.info(f"GitLab Attendant will begin attending to GitLab instance at {args['ip_address']}...")

assign_project_members_to_issues(args)
assign_open_merge_requests(args)
notify_issue_assignees(args, 7)
notify_stale_merge_request_assignees(args, 7)
remove_merged_branches(args)
"""
Function calls to the tasks that the GitLab Attendant
is capable of running.
"""
logger.info("GitLab Attendant has woken up...")
logger.info(
f"GitLab Attendant will begin attending to GitLab instance at {args['ip_address']}..."
)

assign_project_members_to_issues(args)
assign_open_merge_requests(args)
notify_issue_assignees(args, 7)
notify_stale_merge_request_assignees(args, 7)
remove_merged_branches(args)


def main():
"""
"""
Entrypoint to the application.
"""
args = process_arguments()
schedule.every(int(args["interval"])).hours.do(tasks, args)
args = process_arguments()
schedule.every(int(args["interval"])).hours.do(tasks, args)

while True:
schedule.run_pending()
time.sleep(1)
while True:
schedule.run_pending()
time.sleep(1)


if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="gitlab-attendant",
version="1.0.0",
version="0.0.1",
author="Stuart McColl",
author_email="it@stuartmccoll.co.uk",
description="A GitLab bot that tidies and attends to repositories",
Expand All @@ -17,8 +17,8 @@
"console_scripts": ["gitlab-attendant=gitlab_attendant.main:main"]
},
packages=setuptools.find_packages(),
install_requires=["requests"],
tests_require=["unittest", "mock"],
install_requires=["requests", "pytz", "python-dateutil", "schedule==0.5.0"],
tests_require=["unittest", "mock", "pytz"],
classifiers=(
"Environment :: Console",
"Programming Language :: Python",
Expand Down

0 comments on commit bd76037

Please sign in to comment.