Skip to content

Commit

Permalink
Merge pull request #6 from mfocko/feat/vm-image-builds
Browse files Browse the repository at this point in the history
Add cron-job test for VM image builds
  • Loading branch information
mfocko authored Jan 29, 2024
2 parents 0417a18 + 3e13e11 commit 21203d8
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ unfixable = [
# Don't touch unused imports
"F401",
]
allowed-confusables = [
"«", "»",
"", "",
]

[tool.ruff.isort]
known-first-party = ["validation"]
Expand Down
3 changes: 3 additions & 0 deletions src/validation/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand All @@ -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"]',
Expand Down
9 changes: 6 additions & 3 deletions src/validation/testcase/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
15 changes: 14 additions & 1 deletion src/validation/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:")
]
Expand Down

0 comments on commit 21203d8

Please sign in to comment.