Skip to content

Commit

Permalink
A skipped release is not a failure (#2250)
Browse files Browse the repository at this point in the history
When Packit skips a release do not mark it as a failure.

Merge after packit/packit#2156
Merge before packit/dashboard#356 and packit/packit.dev#772
  • Loading branch information
majamassarini authored Nov 16, 2023
2 parents 3084367 + b4fef7c commit 40b97a9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""add skipped status report to sync release jobs
Revision ID: 3de8647515ae
Revises: 99841c3f8ba8
Create Date: 2023-11-13 11:29:10.383794
"""
from alembic import op


# revision identifiers, used by Alembic.
revision = "3de8647515ae"
down_revision = "99841c3f8ba8"
branch_labels = None
depends_on = None


def upgrade():
op.execute("ALTER TYPE syncreleasetargetstatus ADD VALUE 'skipped'")


def downgrade():
op.execute(
"ALTER TYPE syncreleasetargetstatus RENAME TO syncreleasetargetstatus_old"
)
op.execute(
"CREATE TYPE syncreleasetargetstatus AS ENUM "
"('queued', 'running', 'error', 'retry', 'submitted')"
)
op.execute(
"ALTER TABLE sync_release_run_targets "
"ALTER COLUMN status TYPE syncreleasetargetstatus USING status::syncreleasetargetstatus"
)
op.execute("DROP TYPE syncreleasetargetstatus_old")
1 change: 1 addition & 0 deletions packit_service/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2442,6 +2442,7 @@ class SyncReleaseTargetStatus(str, enum.Enum):
error = "error"
retry = "retry"
submitted = "submitted"
skipped = "skipped"


class SyncReleaseTargetModel(ProjectAndEventsConnector, Base):
Expand Down
15 changes: 12 additions & 3 deletions packit_service/worker/handlers/distgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
from ogr.services.github import GithubService
from packit.config import JobConfig, JobType, Deployment
from packit.config.package_config import PackageConfig
from packit.exceptions import PackitException, PackitDownloadFailedException
from packit.exceptions import (
PackitException,
PackitDownloadFailedException,
ReleaseSkippedPackitException,
)
from packit_service import sentry_integration
from packit_service.config import PackageConfigGetter, ServiceConfig
from packit_service.constants import (
Expand Down Expand Up @@ -349,14 +353,19 @@ def run_for_target(
logger.debug(f"{self.sync_release_job_type} failed: {ex}")
# make sure exception message is propagated to the logs
logging.getLogger("packit").error(str(ex))
(state, status) = (
(BaseCommitStatus.neutral, SyncReleaseTargetStatus.skipped)
if isinstance(ex, ReleaseSkippedPackitException)
else (BaseCommitStatus.failure, SyncReleaseTargetStatus.error)
)
# eat the exception and continue with the execution
self.sync_release_helper.report_status_for_branch(
branch=branch,
description=f"{self.job_name_for_reporting.capitalize()} failed: {ex}",
state=BaseCommitStatus.failure,
state=state,
url=url,
)
model.set_status(status=SyncReleaseTargetStatus.error)
model.set_status(status=status)
sentry_integration.send_to_sentry(ex)

return str(ex)
Expand Down

0 comments on commit 40b97a9

Please sign in to comment.