-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Petr "Stone" Hracek <[email protected]>
- Loading branch information
Showing
10 changed files
with
257 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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Red Hat, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Empty file.
Empty file.
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,60 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# MIT License | ||
# | ||
# Copyright (c) 2024 Red Hat, Inc. | ||
|
||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
|
||
import json | ||
import sys | ||
|
||
from typing import List | ||
|
||
|
||
from auto_merger import utils | ||
|
||
|
||
class AutoMerger: | ||
repo_data: List = [] | ||
|
||
def __init__(self, container_name: str): | ||
self.container_name = container_name | ||
|
||
def get_gh_pr_list(self): | ||
cmd = ["gh pr list -s open --json number,title,labels"] | ||
gh_repo_list = utils.run_command(cmd=cmd, return_output=True) | ||
self.repo_data = json.loads(gh_repo_list) | ||
|
||
def clone_repo(self): | ||
pass | ||
|
||
def merge_pull_request(self): | ||
pass | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) != 2: | ||
print("usage: merger.py [container-name]") | ||
print('OUTPUT DIR is ".", if not specified otherwise') | ||
sys.exit(5) | ||
auto_merger = AutoMerger(container_name=sys.argv[1]) | ||
auto_merger.get_gh_pr_list() | ||
auto_merger.merge_pull_request() |
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,68 @@ | ||
# MIT License | ||
# | ||
# Copyright (c) 2024 Red Hat, Inc. | ||
|
||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
import subprocess | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def run_command( | ||
cmd, | ||
return_output: bool = True, | ||
ignore_error: bool = False, | ||
shell: bool = True, | ||
debug: bool = False, | ||
**kwargs, | ||
): | ||
""" | ||
Run provided command on host system using the same user as invoked this code. | ||
Raises subprocess.CalledProcessError if it fails. | ||
:param cmd: list or str | ||
:param return_output: bool, return output of the command | ||
:param ignore_error: bool, do not fail in case nonzero return code | ||
:param shell: bool, run command in shell | ||
:param debug: bool, print command in shell, default is suppressed | ||
:return: None or str | ||
""" | ||
if debug: | ||
logger.debug(f"command: {cmd}") | ||
try: | ||
if return_output: | ||
return subprocess.check_output( | ||
cmd, | ||
stderr=subprocess.STDOUT, | ||
universal_newlines=True, | ||
shell=shell, | ||
**kwargs, | ||
) | ||
else: | ||
return subprocess.check_call(cmd, shell=shell, **kwargs) | ||
except subprocess.CalledProcessError as cpe: | ||
if ignore_error: | ||
if return_output: | ||
return cpe.output | ||
else: | ||
return cpe.returncode | ||
else: | ||
logger.error(f"failed with code {cpe.returncode} and output:\n{cpe.output}") | ||
raise cpe |
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,3 @@ | ||
[pytest] | ||
pythonpath = auto_merger | ||
testpaths = tests |
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,44 @@ | ||
[ | ||
{ | ||
"labels": [ | ||
{ | ||
"id": "MDU6TGFiZWwxNzM3MjEwMTc=", | ||
"name": "enhancement", | ||
"description": "", | ||
"color": "84b6eb" | ||
}, | ||
{ | ||
"id": "MDU6TGFiZWwzNTI2MjY1NDA=", | ||
"name": "P1", | ||
"description": "", | ||
"color": "d93f0b" | ||
}, | ||
{ | ||
"id": "LA_kwDOAc6Y3c7cwogD", | ||
"name": "ready for review", | ||
"description": "The pull request is ready to review", | ||
"color": "0052CC" | ||
}, | ||
{ | ||
"id": "LA_kwDOAc6Y3c8AAAABpEG3Zg", | ||
"name": "easyfix", | ||
"description": "", | ||
"color": "0E8A16" | ||
}, | ||
{ | ||
"id": "LA_kwDOAc6Y3c8AAAABrYkcpw", | ||
"name": "pr/missing-review", | ||
"description": "", | ||
"color": "ededed" | ||
}, | ||
{ | ||
"id": "LA_kwDOAc6Y3c8AAAABrdCuRQ", | ||
"name": "pr/failing-ci", | ||
"description": "", | ||
"color": "ededed" | ||
} | ||
], | ||
"number": 314, | ||
"title": "Support s2i-core building and testing on Fedora 41" | ||
} | ||
] |
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,12 @@ | ||
{ | ||
"labels": [ | ||
{ | ||
"id": "LA_kwDOA3sMzs8AAAABqTWftQ", | ||
"name": "pr/missing-review", | ||
"description": "", | ||
"color": "ededed" | ||
} | ||
], | ||
"number": 192, | ||
"title": "[WIP] Make tests work also for rootless containers" | ||
} |
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,44 @@ | ||
[ | ||
{ | ||
"labels": [ | ||
{ | ||
"id": "MDU6TGFiZWwxNzM3MjEwMTc=", | ||
"name": "enhancement", | ||
"description": "", | ||
"color": "84b6eb" | ||
}, | ||
{ | ||
"id": "MDU6TGFiZWwzNTI2MjY1NDA=", | ||
"name": "P1", | ||
"description": "", | ||
"color": "d93f0b" | ||
}, | ||
{ | ||
"id": "LA_kwDOAc6Y3c7cwogD", | ||
"name": "ready for review", | ||
"description": "The pull request is ready to review", | ||
"color": "0052CC" | ||
}, | ||
{ | ||
"id": "LA_kwDOAc6Y3c8AAAABpEG3Zg", | ||
"name": "easyfix", | ||
"description": "", | ||
"color": "0E8A16" | ||
}, | ||
{ | ||
"id": "LA_kwDOAc6Y3c8AAAABrYkcpw", | ||
"name": "pr/missing-review", | ||
"description": "", | ||
"color": "ededed" | ||
}, | ||
{ | ||
"id": "LA_kwDOAc6Y3c8AAAABrdCuRQ", | ||
"name": "pr/failing-ci", | ||
"description": "", | ||
"color": "ededed" | ||
} | ||
], | ||
"number": 314, | ||
"title": "Support s2i-core building and testing on Fedora 41" | ||
} | ||
] |
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 @@ | ||
[testenv] | ||
commands = python3 -m pytest --color=yes -v | ||
deps = | ||
pytest | ||
PyYAML |