Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove PR if max attempt reached #430

Merged
merged 4 commits into from
Feb 15, 2024

Conversation

m-rudyk
Copy link
Collaborator

@m-rudyk m-rudyk commented Feb 13, 2024

Pull Request

Description

Add increment to Queue processing, when PR processing interrupted, it should be kept in queue until max scanning attempts reached.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code cleanup/refactoring
  • Documentation update
  • This change requires a documentation update
  • CI system update
  • Test Coverage update

Testing

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

Test Configuration:

  • Java: v17
  • LPVS Release: v1.x.x

Checklist:

  • My code follows the style guidelines of this project
  • My code meets the required code coverage for lines (90% and above)
  • My code meets the required code coverage for branches (80% and above)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@codecov-commenter
Copy link

codecov-commenter commented Feb 13, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (54e90ce) 90.93% compared to head (3da70e6) 90.81%.

Files Patch % Lines
...c/main/java/com/lpvs/service/LPVSQueueService.java 81.81% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #430      +/-   ##
============================================
- Coverage     90.93%   90.81%   -0.13%     
  Complexity      489      489              
============================================
  Files            47       47              
  Lines          1743     1731      -12     
  Branches        209      207       -2     
============================================
- Hits           1585     1572      -13     
- Misses           94       97       +3     
+ Partials         64       62       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@o-kopysov o-kopysov force-pushed the m.rudyk/fix_queue_max_attempts branch from f5e3ecd to a778ef6 Compare February 13, 2024 16:03
@o-kopysov o-kopysov added the fix label Feb 13, 2024
@o-kopysov o-kopysov added this to the v1.4.2 milestone Feb 13, 2024
@m-rudyk m-rudyk force-pushed the m.rudyk/fix_queue_max_attempts branch from a778ef6 to c9ce786 Compare February 14, 2024 07:54
@m-rudyk m-rudyk marked this pull request as ready for review February 14, 2024 08:03
@m-rudyk m-rudyk force-pushed the m.rudyk/fix_queue_max_attempts branch 2 times, most recently from 345fda7 to d755b30 Compare February 14, 2024 10:43
for (LPVSQueue webhook : webhookConfigList) {
log.info("PROCESSING WebHook id = " + webhook.getId());
if (webhook.getAttempts() > maxAttempts) {
if (webhook.getAttempts() < maxAttempts) {
Copy link
Collaborator

@o-kopysov o-kopysov Feb 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why "<"?
This is the processing of the case when webhook.getAttempts() > maxAttempts.
And I think we don't need this code here.

Comment on lines 152 to 159
LPVSPullRequest pullRequest = new LPVSPullRequest();
pullRequest.setPullRequestUrl(webhook.getPullRequestUrl());
pullRequest.setUser(webhook.getUserId());
Copy link
Collaborator

@o-kopysov o-kopysov Feb 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This webhook processing should be added to exception processing before delete().

@m-rudyk m-rudyk force-pushed the m.rudyk/fix_queue_max_attempts branch from d755b30 to c1b015d Compare February 15, 2024 07:32
delete(webhookConfig);
int currentAttempts = webhookConfig.getAttempts();
if (currentAttempts < maxAttempts) {
webhookConfig.setAttempts(currentAttempts++);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currentAttempts++ increases value after execution setAttempts.
Please use currentAttempts+1 instead.

@m-rudyk m-rudyk force-pushed the m.rudyk/fix_queue_max_attempts branch 3 times, most recently from 4887195 to bb9f086 Compare February 15, 2024 10:56
@@ -258,20 +225,36 @@ public void processWebHook(LPVSQueue webhookConfig) {
log.debug("Creating comment");
gitHubService.commentResults(webhookConfig, files, detectedConflicts, pullRequest);
log.debug("Results posted on GitHub");
delete(webhookConfig);
} else {
log.warn("Files are not found. Probably pull request is not exists.");
gitHubService.commentResults(webhookConfig, null, null, pullRequest);
delete(webhookConfig);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This delete is incorrect. Please remove it.

@m-rudyk m-rudyk force-pushed the m.rudyk/fix_queue_max_attempts branch 4 times, most recently from f283360 to bf7fd83 Compare February 15, 2024 11:15
@m-rudyk m-rudyk force-pushed the m.rudyk/fix_queue_max_attempts branch 2 times, most recently from 88ec88d to 3da70e6 Compare February 15, 2024 14:12
@o-kopysov o-kopysov self-requested a review February 15, 2024 14:23
Copy link
Collaborator

@t-naumenko t-naumenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@m-rudyk m-rudyk force-pushed the m.rudyk/fix_queue_max_attempts branch from 3da70e6 to 97d15c0 Compare February 15, 2024 16:30
@o-kopysov
Copy link
Collaborator

I've verified the code on local PC:
image

Copy link
Collaborator

@o-kopysov o-kopysov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified.

@o-kopysov o-kopysov merged commit c44618e into Samsung:main Feb 15, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants