Skip to content

Commit 5bdc121

Browse files
authored
Merge pull request #5830 from opsmill/lgu-migrate-check-repo-check-def
Migrate run repository user checks tasks
2 parents bba5cd1 + 056ddad commit 5bdc121

File tree

18 files changed

+536
-814
lines changed

18 files changed

+536
-814
lines changed

backend/infrahub/git/models.py

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from typing import Optional
22

3-
from pydantic import BaseModel, Field
3+
from pydantic import BaseModel, ConfigDict, Field
4+
5+
from infrahub.message_bus.types import ProposedChangeBranchDiff
46

57

68
class RequestArtifactDefinitionGenerate(BaseModel):
@@ -110,3 +112,77 @@ class GitDiffNamesOnlyResponse(BaseModel):
110112
files_added: list[str] = Field(..., description="Files added")
111113
files_changed: list[str] = Field(..., description="Files changed")
112114
files_removed: list[str] = Field(..., description="Files removed")
115+
116+
117+
class UserCheckDefinitionData(BaseModel):
118+
"""Triggers user defined checks to run based on a Check Definition."""
119+
120+
model_config = ConfigDict(arbitrary_types_allowed=True)
121+
122+
check_definition_id: str = Field(..., description="The unique ID of the check definition")
123+
commit: str = Field(..., description="The commit to target")
124+
repository_id: str = Field(..., description="The unique ID of the Repository")
125+
repository_name: str = Field(..., description="The name of the Repository")
126+
branch_name: str = Field(..., description="The branch where the check is run")
127+
file_path: str = Field(..., description="The path and filename of the check")
128+
class_name: str = Field(..., description="The name of the class containing the check")
129+
proposed_change: str = Field(..., description="The unique ID of the Proposed Change")
130+
branch_diff: ProposedChangeBranchDiff = Field(..., description="The calculated diff between the two branches")
131+
132+
133+
class UserCheckData(BaseModel):
134+
"""Runs a check as defined within a CoreCheckDefinition within a repository."""
135+
136+
model_config = ConfigDict(arbitrary_types_allowed=True)
137+
138+
validator_id: str = Field(..., description="The id of the validator associated with this check")
139+
validator_execution_id: str = Field(..., description="The id of current execution of the associated validator")
140+
check_execution_id: str = Field(..., description="The unique ID for the current execution of this check")
141+
check_definition_id: str = Field(..., description="The unique ID of the check definition")
142+
commit: str = Field(..., description="The commit to target")
143+
repository_id: str = Field(..., description="The unique ID of the Repository")
144+
repository_name: str = Field(..., description="The name of the Repository")
145+
branch_name: str = Field(..., description="The branch where the check is run")
146+
file_path: str = Field(..., description="The path and filename of the check")
147+
class_name: str = Field(..., description="The name of the class containing the check")
148+
proposed_change: str = Field(..., description="The unique ID of the Proposed Change")
149+
variables: dict = Field(default_factory=dict, description="Input variables when running the check")
150+
name: str = Field(..., description="The name of the check")
151+
branch_diff: ProposedChangeBranchDiff = Field(..., description="The calculated diff between the two branches")
152+
timeout: int = Field(..., description="The timeout for the check")
153+
154+
155+
class TriggerRepositoryUserChecks(BaseModel):
156+
"""Sent to trigger the user defined checks on a repository."""
157+
158+
model_config = ConfigDict(arbitrary_types_allowed=True)
159+
160+
proposed_change: str = Field(..., description="The unique ID of the Proposed Change")
161+
repository_id: str = Field(..., description="The unique ID of the Repository")
162+
repository_name: str = Field(..., description="The name of the Repository")
163+
source_branch: str = Field(..., description="The source branch")
164+
source_branch_sync_with_git: bool = Field(..., description="Indicates if the source branch should sync with git")
165+
target_branch: str = Field(..., description="The target branch")
166+
branch_diff: ProposedChangeBranchDiff = Field(..., description="The calculated diff between the two branches")
167+
168+
169+
class TriggerRepositoryInternalChecks(BaseModel):
170+
"""Sent to trigger the checks for a repository to be executed."""
171+
172+
proposed_change: str = Field(..., description="The unique ID of the Proposed Change")
173+
repository: str = Field(..., description="The unique ID of the Repository")
174+
source_branch: str = Field(..., description="The source branch")
175+
target_branch: str = Field(..., description="The target branch")
176+
177+
178+
class CheckRepositoryMergeConflicts(BaseModel):
179+
"""Runs a check to validate if there are merge conflicts for a proposed change between two branches."""
180+
181+
validator_id: str = Field(..., description="The id of the validator associated with this check")
182+
validator_execution_id: str = Field(..., description="The id of current execution of the associated validator")
183+
check_execution_id: str = Field(..., description="The unique ID for the current execution of this check")
184+
proposed_change: str = Field(..., description="The unique ID of the Proposed Change")
185+
repository_id: str = Field(..., description="The unique ID of the Repository")
186+
repository_name: str = Field(..., description="The name of the Repository")
187+
source_branch: str = Field(..., description="The source branch")
188+
target_branch: str = Field(..., description="The target branch")

0 commit comments

Comments
 (0)