-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b2f2a9
commit aaad2a6
Showing
7 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements-test.txt | ||
- name: flake8 | ||
run: | | ||
make flake8 | ||
continue-on-error: true | ||
- name: black | ||
run: | | ||
make black | ||
continue-on-error: true | ||
- name: mypy | ||
run: | | ||
make mypy | ||
continue-on-error: true | ||
- name: pylint | ||
run: | | ||
make pylint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FILES=*.py | ||
|
||
.PHONY: all | ||
all: flake8 pylint mypy black | ||
|
||
.PHONY: flake8 | ||
flake8: | ||
@flake8 --ignore=E501 $(FILES) | ||
|
||
.PHONY: pylint | ||
pylint: | ||
@pylint $(FILES) | ||
|
||
.PHONY: mypy | ||
mypy: | ||
@mypy $(FILES) | ||
|
||
.PHONY: black | ||
black: | ||
@black $(FILES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
![Build Status](https://github.com/ricardobranco777/bugme/actions/workflows/ci.yml/badge.svg) | ||
|
||
# bugme | ||
|
||
Show bug and issue statuses | ||
|
||
## Example usage | ||
|
||
``` | ||
$ bugme.py bsc#1213811 gh#containers/podman#19529 | ||
bsc#1213811 NEW Tue Sep 05 16:21:37 CEST 2023 podman network unreachable after starting docker | ||
gh#19529 closed Tue Aug 08 10:56:56 CEST 2023 Unexpected error with --volumes-from | ||
``` | ||
|
||
## Requirements | ||
|
||
- Tested on Python 3.8+ | ||
- [requirements](requirements-dev.txt) | ||
|
||
## TODO | ||
|
||
- Redmine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/env python3 | ||
""" | ||
Bugme | ||
""" | ||
|
||
import os | ||
import json | ||
import sys | ||
|
||
from dateutil import parser | ||
from pytz import utc | ||
|
||
from github import Github, Auth | ||
from bugzilla import Bugzilla # type: ignore | ||
|
||
CREDENTIALS_FILE = os.path.expanduser("./creds.json") | ||
|
||
|
||
def dateit(date: str | None, time_format: str = "%a %b %d %H:%M:%S %Z %Y") -> str: | ||
""" | ||
Return date in desired format | ||
""" | ||
if date is None: | ||
return "" | ||
return utc.normalize(parser.parse(date)).astimezone().strftime(time_format) | ||
|
||
|
||
class GithubIssue: # pylint: disable=too-few-public-methods | ||
""" | ||
Simple class to hold GitHub issue | ||
""" | ||
|
||
def __init__(self, repo: str, issue: str): | ||
self.repo = repo | ||
self.number = int(issue) | ||
|
||
|
||
def main() -> None: | ||
""" | ||
Main function | ||
""" | ||
bsc_list: list[int] = [] | ||
gh_list: list[GithubIssue] = [] | ||
|
||
for arg in sys.argv[1:]: | ||
if arg.startswith(("bnc#", "boo#", "bsc#")): | ||
bsc_list.append(int(arg.split("#", 1)[1])) | ||
elif arg.startswith("gh#"): | ||
gh_list.append(GithubIssue(*arg.split("#", 2)[1:])) | ||
else: | ||
print(f"Unsupported {arg}", file=sys.stderr) | ||
|
||
with open(CREDENTIALS_FILE, encoding="utf-8") as file: | ||
if os.fstat(file.fileno()).st_mode & 0o77: | ||
sys.exit(f"ERROR: {CREDENTIALS_FILE} has insecure permissions") | ||
creds = json.load(file) | ||
|
||
# Bugzilla | ||
mybsc = Bugzilla( | ||
"https://bugzilla.suse.com", force_rest=True, **creds["bugzilla.suse.com"] | ||
) | ||
for bsc in mybsc.getbugs(bsc_list): | ||
print( | ||
f"bsc#{bsc.id}\t{bsc.status}\t{dateit(bsc.last_change_time)}\t{bsc.summary}" | ||
) | ||
mybsc.disconnect() | ||
|
||
# Github | ||
auth = Auth.Token(**creds["github.com"]) | ||
mygh = Github(auth=auth) | ||
for issue in gh_list: | ||
info = mygh.get_repo(issue.repo).get_issue(issue.number) | ||
print( | ||
f"gh#{info.number}\t{info.state}\t{dateit(info.last_modified)}\t{info.title}" | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
try: | ||
main() | ||
except KeyboardInterrupt: | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
PyGithub | ||
python-bugzilla | ||
python-redmine | ||
python-dateutil | ||
pytz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-r requirements.txt | ||
|
||
black | ||
flake8 | ||
pylint | ||
mypy | ||
types-python-dateutil | ||
types-pytz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
certifi==2023.7.22 | ||
cffi==1.15.1 | ||
charset-normalizer==3.2.0 | ||
cryptography==41.0.3 | ||
Deprecated==1.2.14 | ||
idna==3.4 | ||
pycparser==2.21 | ||
PyGithub==1.59.1 | ||
PyJWT==2.8.0 | ||
PyNaCl==1.5.0 | ||
python-bugzilla==3.2.0 | ||
python-dateutil==2.8.2 | ||
python-redmine==2.4.0 | ||
pytz==2023.3.post1 | ||
requests==2.31.0 | ||
six==1.16.0 | ||
urllib3==2.0.4 | ||
wrapt==1.15.0 |