Skip to content

Commit

Permalink
Do not show build status in manual test checks (#2375)
Browse files Browse the repository at this point in the history
Do not show build status in manual test checks

Unless there are failures or errors.
This can be improved having a real dependency
between tests and builds.
Showing a neutral state for a successful build
message is not working on gitlab and either on
github is not working always
(my test falls back on commit statuses and
they don't have a neutral state).
Fixes #2147
RELEASE NOTES BEGIN
Packit no longer shows status checks for not yet triggered manual tests.
RELEASE NOTES END

Reviewed-by: Maja Massarini
Reviewed-by: Laura Barcziová
  • Loading branch information
softwarefactory-project-zuul[bot] authored Mar 21, 2024
2 parents 623c117 + ce2a788 commit 0a85e3c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 19 deletions.
8 changes: 5 additions & 3 deletions packit_service/worker/helpers/build/build_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ def report_status_to_all_test_jobs(
update_feedback_time: Callable = None,
) -> None:
for test_job in self.job_tests_all:
if test_job.skip_build:
if test_job.skip_build or test_job.manual_trigger:
continue
check_names = self.test_check_names_for_test_job(test_job)
self._report(
Expand Down Expand Up @@ -696,8 +696,10 @@ def report_status_to_all_test_jobs_for_chroot(
update_feedback_time: Callable = None,
) -> None:
for test_job in self.job_tests_all:
if not test_job.skip_build and chroot in self.build_targets_for_test_job(
test_job
if (
not test_job.skip_build
and not test_job.manual_trigger
and chroot in self.build_targets_for_test_job(test_job)
):
test_targets = self.build_target2test_targets_for_test_job(
chroot, test_job
Expand Down
54 changes: 38 additions & 16 deletions tests/integration/test_listen_to_fedmsg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: MIT

import json
import copy
from datetime import datetime

import pytest
Expand Down Expand Up @@ -1018,7 +1019,16 @@ def test_copr_build_end_testing_farm_different_pr_branch(copr_build_end, copr_bu
)


def test_copr_build_end_testing_farm_manual_trigger(copr_build_end, copr_build_pr):
@pytest.mark.parametrize(
"build_status,report_manual_triggered_times",
(
(BuildStatus.success, 0),
(BuildStatus.failure, 0),
),
)
def test_copr_build_end_testing_farm_manual_trigger(
copr_build_end, copr_build_pr, build_status, report_manual_triggered_times
):
ServiceConfig.get_service_config().testing_farm_api_url = (
"https://api.dev.testing-farm.io/v0.1/"
)
Expand Down Expand Up @@ -1090,32 +1100,43 @@ def test_copr_build_end_testing_farm_manual_trigger(copr_build_end, copr_build_p
copr_build_pr
)
flexmock(CoprBuildTargetModel).should_receive("get_by_id").and_return(copr_build_pr)
copr_build_pr.should_call("set_status").with_args(BuildStatus.success).once()
copr_build_pr.should_call("set_status").with_args(build_status).once()
copr_build_pr.should_receive("set_end_time").once()
copr_build_pr.should_receive("get_package_name").and_return(None)
flexmock(requests).should_receive("get").and_return(requests.Response())
flexmock(requests.Response).should_receive("raise_for_status").and_return(None)
# check if packit-service set correct PR status
url = get_copr_build_info_url(1)
flexmock(StatusReporter).should_receive("report").with_args(
state=BaseCommitStatus.success,
description="RPMs were built successfully.",
url=url,
check_names=EXPECTED_BUILD_CHECK_NAME,
markdown_content=None,
links_to_external_services=None,
update_feedback_time=object,
).once()
if build_status == BuildStatus.success:
flexmock(StatusReporter).should_receive("report").with_args(
state=BaseCommitStatus.success,
description="RPMs were built successfully.",
url=url,
check_names=EXPECTED_BUILD_CHECK_NAME,
markdown_content=None,
links_to_external_services=None,
update_feedback_time=object,
).once()
else:
flexmock(StatusReporter).should_receive("report").with_args(
description="RPMs failed to be built.",
state=BaseCommitStatus.failure,
url=url,
check_names=EXPECTED_BUILD_CHECK_NAME,
markdown_content=None,
links_to_external_services=None,
update_feedback_time=object,
).once()

flexmock(StatusReporter).should_receive("report").with_args(
state=BaseCommitStatus.pending,
description="RPMs were built successfully.",
state=BaseCommitStatus.failure,
description="RPMs failed to be built.",
url=url,
check_names=EXPECTED_TESTING_FARM_CHECK_NAME,
markdown_content=None,
links_to_external_services=None,
update_feedback_time=object,
).once()
).times(report_manual_triggered_times)

flexmock(GithubProject).should_receive("get_web_url").and_return(
"https://github.com/foo/bar"
Expand All @@ -1136,8 +1157,9 @@ def test_copr_build_end_testing_farm_manual_trigger(copr_build_end, copr_build_p
)

flexmock(Pushgateway).should_receive("push").times(2).and_return()

processing_results = SteveJobs().process_message(copr_build_end)
copr_event = copy.deepcopy(copr_build_end)
copr_event["status"] = 1 if build_status == BuildStatus.success else 0
processing_results = SteveJobs().process_message(copr_event)
event_dict, job, job_config, package_config = get_parameters_from_results(
processing_results
)
Expand Down

0 comments on commit 0a85e3c

Please sign in to comment.