Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packit_service/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
DOCS_VALIDATE_CONFIG = f"{DOCS_URL}/cli/config/validate"
DOCS_VALIDATE_HOOKS = "https://packit.dev/posts/pre-commit-hooks#validate-config"

HELP_COMMENT_PROG = "/packit | /packit-stg"
HELP_COMMENT_PROG_FEDORA_CI = "/packit-ci | /packit-ci-stg"
HELP_COMMENT_DESCRIPTION = ""
HELP_COMMENT_EPILOG = (
f"Documentation: {DOCS_URL}\n"
"Contact:\n"
" Email: [email protected]\n"
" Matrix: #packit:fedora.im\n"
" Mastodon: @[email protected]"
)

KOJI_PRODUCTION_BUILDS_ISSUE = "https://pagure.io/releng/issue/9801"

SANDCASTLE_WORK_DIR = "/tmp/sandcastle"
Expand Down
92 changes: 92 additions & 0 deletions packit_service/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT

import argparse
import logging
import os
from argparse import RawTextHelpFormatter
from datetime import datetime, timezone
from io import StringIO
from logging import StreamHandler
Expand Down Expand Up @@ -217,6 +219,96 @@ def get_packit_commands_from_comment(
return []


def _create_base_parser(prog: str, description: str, epilog: str) -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
prog=prog,
description=description,
epilog=epilog,
formatter_class=RawTextHelpFormatter,
)
parser.add_argument("--package", help="Specific package from monorepo to run job for")
return parser


def get_pr_comment_parser(prog: str, description: str, epilog: str) -> argparse.ArgumentParser:
parser = _create_base_parser(prog, description, epilog)

subparsers = parser.add_subparsers(
dest="command",
help="Jobs available",
)

build_parser = subparsers.add_parser(
"copr-build",
aliases=["build"],
help="Build package(s) in Copr",
)
build_parser.add_argument(
"--commit", help="Run Copr build jobs configured with the commit trigger"
)
build_parser.add_argument(
"--release", help="Run Copr build jobs configured with the release trigger"
)
subparsers.add_parser("rebuild-failed", help="Re-build failed builds in Copr")
subparsers.add_parser(
"upstream-koji-build",
help="Build package(s) in Koji (the latest commit of this PR will be targeted, not HEAD)",
)

test_parser = subparsers.add_parser("test", help="Run tests in Testing Farm")
test_parser.add_argument("--commit", help="Run tests configured with the commit trigger")
test_parser.add_argument("--release", help="Run tests configured with the release trigger")
test_parser.add_argument("target", nargs="*", help="Test target(s)")
test_parser.add_argument("env", nargs="*", help="Environment variables")

subparsers.add_parser("retest-failed", help="Re-run failed tests in Testing Farm")
subparsers.add_parser("vm-image-build", help="Trigger VM image build")
subparsers.add_parser("propose-downstream", help="Trigger propose-downstream job")

pull_from_upstream_parser = subparsers.add_parser(
"pull-from-upstream", help="Trigger pull-from-upstream job"
)
pull_from_upstream_parser.add_argument(
"--resolve-bug",
help="Override the referenced resolved bug set by Packit",
)
pull_from_upstream_parser.add_argument(
"--with-pr-config",
action="store_true",
help="Use the configuration file from this dist-git pull request",
)

subparsers.add_parser(
"koji-build",
help="Build package(s) in Koji (the latest commit of this PR will be targeted, not HEAD)",
)

koji_tag_parser = subparsers.add_parser("koji-tag", help="Tag Koji build to the common sidetag")
koji_tag_parser.add_argument("--all-branches", action="store_true", help="Target all branches")

subparsers.add_parser("create-update", help="Trigger Bodhi update job")

return parser


def get_pr_comment_parser_fedora_ci(
prog: str, description: str, epilog: str
) -> argparse.ArgumentParser:
parser = _create_base_parser(prog, description, epilog)

subparsers = parser.add_subparsers(
dest="command",
help="Jobs available",
)
test_parser = subparsers.add_parser("test", help="Run tests in Testing Farm")
test_parser.add_argument("target", nargs="*", help="Test target(s)")
test_parser.add_argument("env", nargs="*", help="Environment variables")
subparsers.add_parser("retest-failed", help="Re-run failed tests in Testing Farm")
subparsers.add_parser("scratch-build", help="Build package in Scratch")

return parser


def get_koji_task_id_and_url_from_stdout(stdout: str) -> tuple[Optional[int], Optional[str]]:
task_id, task_url = None, None

Expand Down
Loading
Loading