-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
22 changed files
with
1,332 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
"""Create OSHScanModel | ||
Revision ID: 242a0cdb6d23 | ||
Revises: f376be1907e1 | ||
Create Date: 2024-10-18 08:10:35.335510 | ||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "242a0cdb6d23" | ||
down_revision = "f376be1907e1" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"scans", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("task_id", sa.Integer(), nullable=True), | ||
sa.Column( | ||
"status", | ||
sa.Enum( | ||
"pending", | ||
"running", | ||
"succeeded", | ||
"canceled", | ||
"failed", | ||
name="oshscanstatus", | ||
), | ||
nullable=True, | ||
), | ||
sa.Column("url", sa.String(), nullable=True), | ||
sa.Column("issues_added_url", sa.String(), nullable=True), | ||
sa.Column("issues_fixed_url", sa.String(), nullable=True), | ||
sa.Column("scan_results_url", sa.String(), nullable=True), | ||
sa.Column("copr_build_target_id", sa.Integer(), nullable=True), | ||
sa.ForeignKeyConstraint( | ||
["copr_build_target_id"], | ||
["copr_build_targets.id"], | ||
), | ||
sa.PrimaryKeyConstraint("id"), | ||
sa.UniqueConstraint("copr_build_target_id"), | ||
sa.UniqueConstraint("task_id"), | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table("scans") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright Contributors to the Packit project. | ||
# SPDX-License-Identifier: MIT | ||
|
||
import logging | ||
|
||
from packit.config import ( | ||
aliases, | ||
) | ||
from packit_service.worker.checker.abstract import Checker | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class RawhideX86Target( | ||
Checker, | ||
): | ||
def pre_check(self) -> bool: | ||
branches = aliases.get_build_targets( | ||
*self.job_config.targets, | ||
) | ||
if "fedora-rawhide-x86_64" not in branches: | ||
logger.debug( | ||
"Skipping job configuration with no fedora-rawhide-x86_64 target." | ||
) | ||
return False | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Copyright Contributors to the Packit project. | ||
# SPDX-License-Identifier: MIT | ||
|
||
import enum | ||
from typing import Optional | ||
from logging import getLogger | ||
|
||
from ogr.abstract import GitProject | ||
from packit_service.config import ServiceConfig | ||
from packit_service.worker.events.event import AbstractResultEvent | ||
from packit_service.models import ( | ||
AbstractProjectObjectDbType, | ||
ProjectEventModel, | ||
OSHScanModel, | ||
) | ||
|
||
logger = getLogger(__name__) | ||
|
||
|
||
class OpenScanHubTaskAbstractEvent(AbstractResultEvent): | ||
|
||
def __init__( | ||
self, | ||
task_id: int, | ||
**kwargs, | ||
): | ||
super().__init__(**kwargs) | ||
|
||
self.task_id = task_id | ||
|
||
self.scan = OSHScanModel.get_by_task_id(task_id) | ||
self.build = self.scan.copr_build_target | ||
|
||
def get_db_project_object(self) -> Optional[AbstractProjectObjectDbType]: | ||
return self.build.get_project_event_object() | ||
|
||
def get_db_project_event(self) -> Optional[ProjectEventModel]: | ||
return self.build.get_project_event_model() | ||
|
||
def get_project(self) -> GitProject: | ||
return ServiceConfig.get_service_config().get_project( | ||
self.db_project_object.project.project_url | ||
) | ||
|
||
def get_non_serializable_attributes(self): | ||
return super().get_non_serializable_attributes() + ["build", "scan"] | ||
|
||
|
||
class OpenScanHubTaskFinishedEvent(OpenScanHubTaskAbstractEvent): | ||
|
||
class Status(str, enum.Enum): | ||
success = "success" | ||
cancel = "cancel" | ||
interrupt = "interrupt" | ||
fail = "fail" | ||
|
||
def __init__( | ||
self, | ||
status: Status, | ||
issues_added_url: str, | ||
issues_fixed_url: str, | ||
scan_results_url: str, | ||
**kwargs, | ||
): | ||
super().__init__(**kwargs) | ||
|
||
self.status = status | ||
self.issues_added_url = issues_added_url | ||
self.issues_fixed_url = issues_fixed_url | ||
self.scan_results_url = scan_results_url | ||
|
||
|
||
class OpenScanHubTaskStartedEvent(OpenScanHubTaskAbstractEvent): ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.