From 5be5dd99c35b6007f971ca135fe0156704842cd8 Mon Sep 17 00:00:00 2001 From: Laura Barcziova Date: Wed, 17 Jan 2024 06:50:53 +0100 Subject: [PATCH] Add hint about config validation for invalid config error --- packit_service/config.py | 8 ++++++-- packit_service/constants.py | 2 ++ tests/integration/test_pr_comment.py | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packit_service/config.py b/packit_service/config.py index 06dfe7d01..b56a62903 100644 --- a/packit_service/config.py +++ b/packit_service/config.py @@ -6,9 +6,9 @@ from pathlib import Path from typing import List, NamedTuple, Optional, Set, Union -from ogr.abstract import GitProject, Issue from yaml import safe_load +from ogr.abstract import GitProject, Issue from packit.config import ( Config, PackageConfig, @@ -30,6 +30,8 @@ SANDCASTLE_PVC, SANDCASTLE_WORK_DIR, TESTING_FARM_API_URL, + DOCS_VALIDATE_CONFIG, + DOCS_VALIDATE_HOOKS, ) logger = logging.getLogger(__name__) @@ -349,7 +351,9 @@ def get_package_config_from_repo( "For more info, please check out " f"[the documentation]({DOCS_HOW_TO_CONFIGURE_URL}) " "or [contact the Packit team]" - f"({CONTACTS_URL})." + f"({CONTACTS_URL}). You can also use " + f"our CLI command [`validate-config`]({DOCS_VALIDATE_CONFIG}) or our " + f"[pre-commit hooks]({DOCS_VALIDATE_HOOKS}) for validation of the configuration." ) if pr_id: diff --git a/packit_service/constants.py b/packit_service/constants.py index 395bed11e..3fe634f9e 100644 --- a/packit_service/constants.py +++ b/packit_service/constants.py @@ -14,6 +14,8 @@ DOCS_APPROVAL_URL = f"{DOCS_URL}/guide/#2-approval" DOCS_VM_IMAGE_BUILD = f"{DOCS_URL}/cli/build/in-image-builder/" DOCS_TESTING_FARM = f"{DOCS_URL}/configuration/upstream/tests" +DOCS_VALIDATE_CONFIG = f"{DOCS_URL}/cli/validate-config" +DOCS_VALIDATE_HOOKS = "https://packit.dev/posts/pre-commit-hooks#validate-config" KOJI_PRODUCTION_BUILDS_ISSUE = "https://pagure.io/releng/issue/9801" diff --git a/tests/integration/test_pr_comment.py b/tests/integration/test_pr_comment.py index 491881d39..20496de5b 100644 --- a/tests/integration/test_pr_comment.py +++ b/tests/integration/test_pr_comment.py @@ -35,6 +35,8 @@ TASK_ACCEPTED, DEFAULT_RETRY_LIMIT, CHANGED_LOADING_BEHAVIOUR_IN_DISTGIT_MESSAGE, + DOCS_VALIDATE_HOOKS, + DOCS_VALIDATE_CONFIG, ) from packit_service.models import ( CoprBuildTargetModel, @@ -1714,7 +1716,9 @@ def test_trigger_packit_command_without_config( "For more info, please check out " f"[the documentation]({DOCS_HOW_TO_CONFIGURE_URL}) " "or [contact the Packit team]" - f"({CONTACTS_URL})." + f"({CONTACTS_URL}). You can also use " + f"our CLI command [`validate-config`]({DOCS_VALIDATE_CONFIG}) or our " + f"[pre-commit hooks]({DOCS_VALIDATE_HOOKS}) for validation of the configuration." ) flexmock(pr).should_receive("comment").with_args(err_msg)