-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reimplementation of bash functions in python
This is the first step to move from the spaghetti bash code to a more testable, maintainable and extensible python re-implementation. TODO(kwk): Some bits from the functions.sh have been migrated but are probable not used anywhere yet. TODO(kwk): Remove functions.sh once the migration is complete and all workflows use the new setup.
- Loading branch information
Showing
32 changed files
with
2,102 additions
and
118 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
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
buildroot/ | ||
llvm-snapshot-builder*.tar.bz2 | ||
*.rpm | ||
.coverage |
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
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
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,2 @@ | ||
__pycache__ | ||
*.py,cover |
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,158 @@ | ||
import argparse | ||
import logging | ||
import sys | ||
|
||
import snapshot_manager.config as config | ||
import snapshot_manager.snapshot_manager as snapshot_manager | ||
|
||
|
||
def main(): | ||
cfg = config.Config() | ||
|
||
logging.basicConfig( | ||
level=logging.INFO, | ||
format="[%(asctime)s] %(levelname)s [%(pathname)s:%(lineno)d %(funcName)s] %(message)s", | ||
datefmt="%d/%b/%Y %H:%M:%S", | ||
stream=sys.stderr, | ||
) | ||
|
||
# This shows the default value of arguments in the help text. | ||
# See https://docs.python.org/3/library/argparse.html#argparse.ArgumentDefaultsHelpFormatter | ||
parser_args = {"formatter_class": argparse.ArgumentDefaultsHelpFormatter} | ||
|
||
mainparser = argparse.ArgumentParser( | ||
description="Program for managing LLVM snapshots", | ||
**parser_args, | ||
) | ||
|
||
# For config file support see: | ||
# https://newini.wordpress.com/2021/06/11/how-to-import-config-file-to-argparse-using-configparser/ | ||
# subparser_check.add_argument( | ||
# "--config-file", | ||
# type=str, | ||
# nargs="+", | ||
# dest="config_file", | ||
# help="Path to config file?", | ||
# required=False | ||
# ) | ||
|
||
subparsers = mainparser.add_subparsers(help="Command to run", dest="command") | ||
|
||
subparser_check = subparsers.add_parser( | ||
"check", | ||
description="Check Copr status and update today's github issue", | ||
**parser_args, | ||
) | ||
|
||
subparser_check.add_argument( | ||
"--packages", | ||
metavar="PKG", | ||
type=str, | ||
nargs="+", | ||
dest="packages", | ||
default=cfg.packages, | ||
help="Which packages are required to build?", | ||
) | ||
|
||
subparser_check.add_argument( | ||
"--chroot-pattern", | ||
metavar="REGULAR_EXPRESSION", | ||
type=str, | ||
dest="chroot_pattern", | ||
default=cfg.chroot_pattern, | ||
help="Chroots regex pattern for required chroots.", | ||
) | ||
|
||
subparser_check.add_argument( | ||
"--build-strategy", | ||
type=str, | ||
dest="build_strategy", | ||
default=cfg.build_strategy, | ||
help="Build strategy to look for (e.g. 'standalone', 'big-merge', 'bootstrap').", | ||
) | ||
|
||
subparser_check.add_argument( | ||
"--maintainer-handle", | ||
metavar="GITHUB_HANDLE_WITHOUT_AT_SIGN", | ||
type=str, | ||
dest="maintainer_handle", | ||
default=cfg.maintainer_handle, | ||
help="Maintainer handle to use for assigning issues.", | ||
) | ||
|
||
subparser_check.add_argument( | ||
"--github-repo", | ||
metavar="OWNER/REPO", | ||
type=str, | ||
dest="github_repo", | ||
default=cfg.github_repo, | ||
help="Repo where to open or update issues.", | ||
) | ||
|
||
subparser_check.add_argument( | ||
"--copr-ownername", | ||
metavar="COPR-OWNWERNAME", | ||
type=str, | ||
dest="copr_ownername", | ||
default=cfg.copr_ownername, | ||
help="Copr ownername to check.", | ||
) | ||
|
||
subparser_check.add_argument( | ||
"--copr-project-tpl", | ||
metavar="COPR-PROJECT-TPL", | ||
type=str, | ||
dest="copr_project_tpl", | ||
default=cfg.copr_project_tpl, | ||
help="Copr project name to check. 'YYYYMMDD' will be replaced, so make sure you have it in there.", | ||
) | ||
|
||
subparser_check.add_argument( | ||
"--github-token-env", | ||
metavar="ENV_NAME", | ||
type=str, | ||
dest="github_token_env", | ||
default=cfg.github_token_env, | ||
help="Default name of the environment variable which holds the github token", | ||
) | ||
|
||
subparser_check.add_argument( | ||
"--copr-monitor-tpl", | ||
metavar="COPR-MONITOR-TPL", | ||
type=str, | ||
dest="copr_monitor_tpl", | ||
default=cfg.copr_monitor_tpl, | ||
help="URL to the Copr monitor page. We'll use this in the issue comment's body, not for querying Copr.", | ||
# See https://github.com/python/cpython/issues/113878 for when we can | ||
# use the __doc__ of a dataclass field. | ||
# help=config.Config.copr_monitor_tpl.__doc__ | ||
) | ||
|
||
# if args.config_file: | ||
# config = configparser.ConfigParser() | ||
# config.read(args.config_file) | ||
# defaults = {} | ||
# defaults.update(dict(config.items("Defaults"))) | ||
# mainparser.set_defaults(**defaults) | ||
# args = mainparser.parse_args() # Overwrite arguments | ||
|
||
args = mainparser.parse_args() | ||
|
||
cfg.packages = args.packages | ||
cfg.chroot_pattern = args.chroot_pattern | ||
cfg.build_strategy = args.build_strategy | ||
cfg.maintainer_handle = args.maintainer_handle | ||
cfg.copr_ownername = args.copr_ownername | ||
cfg.copr_project_tpl = args.copr_project_tpl | ||
cfg.copr_monitor_tpl = args.copr_monitor_tpl | ||
cfg.github_repo = args.github_repo | ||
cfg.github_token_env = args.github_token_env | ||
|
||
if args.command == "check": | ||
snapshot_manager.SnapshotManager(config=cfg).check_todays_builds() | ||
else: | ||
logging.error(f"Unsupported argument: {args.command}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,2 @@ | ||
__pycache__ | ||
*.py,cover |
Empty file.
Oops, something went wrong.