Skip to content

Commit

Permalink
fix: do the check in trigger_process_flakes
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-sentry committed Dec 12, 2024
1 parent 33b58c4 commit bf1e405
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
24 changes: 15 additions & 9 deletions tasks/sync_pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,12 @@ def update_pull_commits(
)
)

if (
should_do_flaky_detection(repository, current_yaml)
and db_session.query(Test).filter(Test.repoid == repoid).count() > 0
):
self.trigger_process_flakes(
repository, pull.head, pull_dict["head"]["branch"], current_yaml
db_session,
repository,
pull.head,
pull_dict["head"]["branch"],
current_yaml,
)

# set the rest of the commits to deleted (do not show in the UI)
Expand Down Expand Up @@ -531,16 +531,22 @@ def was_pr_merged_with_squash(

def trigger_process_flakes(
self,
db_session: sqlalchemy.orm.Session,
repository: Repository,
pull_head: str,
branch: str,
current_yaml: UserYaml,
):
self.app.tasks[process_flakes_task_name].apply_async(
kwargs=dict(
repo_id=repository.repoid, commit_id_list=[pull_head], branch=branch
if (
should_do_flaky_detection(repository, current_yaml)
and db_session.query(Test).filter(Test.repoid == repository.repoid).count()
> 0
):
self.app.tasks[process_flakes_task_name].apply_async(
kwargs=dict(
repo_id=repository.repoid, commit_id_list=[pull_head], branch=branch
)
)
)

def trigger_ai_pr_review(self, enriched_pull: EnrichedPull, current_yaml: UserYaml):
pull = enriched_pull.database_pull
Expand Down
5 changes: 5 additions & 0 deletions tasks/tests/unit/test_sync_pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,12 @@ def test_trigger_process_flakes(dbsession, mocker, flake_detection, repository):
task.app.tasks["app.tasks.flakes.ProcessFlakesTask"], "apply_async"
)

if flake_detection:
TestFactory.create(repository=repository)
dbsession.flush()

task.trigger_process_flakes(
dbsession,
repository,
commit.commitid,
"main",
Expand Down

0 comments on commit bf1e405

Please sign in to comment.