From f4fff6dcec00f06b7bae8aee2966b061d3bbfa67 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 20:23:46 +0000 Subject: [PATCH 1/4] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-prettier: v3.0.3 → v4.0.0-alpha.8](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.3...v4.0.0-alpha.8) - [github.com/psf/black: 23.10.1 → 23.12.1](https://github.com/psf/black/compare/23.10.1...23.12.1) - [github.com/astral-sh/ruff-pre-commit: v0.1.3 → v0.1.14](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.3...v0.1.14) - [github.com/pre-commit/mirrors-mypy: v1.6.1 → v1.8.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.6.1...v1.8.0) - [github.com/gitleaks/gitleaks: v8.18.0 → v8.18.1](https://github.com/gitleaks/gitleaks/compare/v8.18.0...v8.18.1) --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4eb16b8..f433175 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ repos: - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.3 + rev: v4.0.0-alpha.8 hooks: - id: prettier - repo: https://github.com/pre-commit/pre-commit-hooks @@ -20,16 +20,16 @@ repos: args: - --allow-missing-credentials - repo: https://github.com/psf/black - rev: 23.10.1 + rev: 23.12.1 hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.3 + rev: v0.1.14 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.6.1 + rev: v1.8.0 hooks: - id: mypy args: [--no-strict-optional, --ignore-missing-imports] @@ -47,7 +47,7 @@ repos: hooks: - id: shellcheck - repo: https://github.com/gitleaks/gitleaks - rev: v8.18.0 + rev: v8.18.1 hooks: - id: gitleaks # The hook runs 'gitleaks protect --staged' which parses output of From 1049405963554b142224fefcff025d9c5e10fd23 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Fri, 26 Jan 2024 17:59:34 +0100 Subject: [PATCH 2/4] ci: allow guillemets in comments, strings, docstrings Signed-off-by: Matej Focko --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index ba22112..d2d0aff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -126,6 +126,10 @@ unfixable = [ # Don't touch unused imports "F401", ] +allowed-confusables = [ + "«", "»", + "‹", "›", +] [tool.ruff.isort] known-first-party = ["validation"] From 6614e1db752d64bfa3df7d54314c991d4d1d9396 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Fri, 26 Jan 2024 18:00:00 +0100 Subject: [PATCH 3/4] feat: add test for VM image builds Co-Authored-by: Maja Massarini Signed-off-by: Matej Focko --- src/validation/deployment.py | 3 +++ src/validation/testcase/base.py | 9 ++++++--- src/validation/tests/base.py | 15 ++++++++++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/validation/deployment.py b/src/validation/deployment.py index 1d885c0..80c36ec 100644 --- a/src/validation/deployment.py +++ b/src/validation/deployment.py @@ -26,6 +26,7 @@ class DeploymentInfo: name: str app_name: str pr_comment: str + pr_comment_vm_image_build: str opened_pr_trigger__packit_yaml_fix: Optional[YamlFix] copr_user: str push_trigger_tests_prefix: str @@ -37,6 +38,7 @@ class DeploymentInfo: name="prod", app_name="Packit-as-a-Service", pr_comment="/packit build", + pr_comment_vm_image_build="/packit vm-image-build", opened_pr_trigger__packit_yaml_fix=None, copr_user="packit", push_trigger_tests_prefix="Basic test case (prod): push trigger", @@ -47,6 +49,7 @@ class DeploymentInfo: name="stg", app_name="Packit-as-a-Service-stg", pr_comment="/packit-stg build", + pr_comment_vm_image_build="/packit-stg vm-image-build", opened_pr_trigger__packit_yaml_fix=YamlFix( from_str="---", to_str='---\npackit_instances: ["stg"]', diff --git a/src/validation/testcase/base.py b/src/validation/testcase/base.py index ab49345..e23e2c5 100644 --- a/src/validation/testcase/base.py +++ b/src/validation/testcase/base.py @@ -21,9 +21,10 @@ class Testcase: def __init__( self, project: GitProject, - pr: PullRequest = None, + pr: PullRequest | None = None, trigger: Trigger = Trigger.pr_opened, - deployment: DeploymentInfo = None, + deployment: DeploymentInfo | None = None, + comment: str | None = None, ): self.project = project self.pr = pr @@ -33,6 +34,7 @@ def __init__( self.head_commit = pr.head_commit if pr else None self._copr_project_name = None self.deployment = deployment or PRODUCTION_INFO + self.comment = comment @property def copr_project_name(self): @@ -70,7 +72,8 @@ def trigger_build(self): self.pr if self.pr else "new PR", ) if self.trigger == Trigger.comment: - self.pr.comment(self.deployment.pr_comment) + comment = self.comment or self.deployment.pr_comment + self.pr.comment(comment) elif self.trigger == Trigger.push: self.push_to_pr() else: diff --git a/src/validation/tests/base.py b/src/validation/tests/base.py index b4b75f0..5c0f4ea 100644 --- a/src/validation/tests/base.py +++ b/src/validation/tests/base.py @@ -15,7 +15,20 @@ class Tests: test_case_kls: type def run(self): - logging.info("Run testcases where the build is triggered by a '/packit build' comment") + logging.info("Run testcases where the build is triggered by a ‹vm-image-build› comment") + prs_for_comment = [ + pr for pr in self.project.get_pr_list() if pr.title.startswith("Test VM Image builds") + ] + for pr in prs_for_comment: + self.test_case_kls( + project=self.project, + pr=pr, + trigger=Trigger.comment, + deployment=DEPLOYMENT, + comment=DEPLOYMENT.pr_comment_vm_image_build, + ).run_test() + + logging.info("Run testcases where the build is triggered by a ‹build› comment") prs_for_comment = [ pr for pr in self.project.get_pr_list() if pr.title.startswith("Basic test case:") ] From 3e13e11ec1aa476767aa3a3580399d951c353eb3 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Fri, 26 Jan 2024 18:08:14 +0100 Subject: [PATCH 4/4] chore: gitignore the potential secrets Signed-off-by: Matej Focko --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 68bc17f..d83af75 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,6 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + +# Do not commit the secrets +secrets