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

Use the new handlers when evaluating repo webhooks #4565

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

jhrozek
Copy link
Contributor

@jhrozek jhrozek commented Sep 20, 2024

Summary

We added new watermill handlers that allow to refresh and evaluate a
generic entity with properties. This is the first patch in a series that
takes these handlers into account with the eventual goal of removing all
the bespoke code from the GitHub webhook handler and eventually remove
direct database access from the webhook handler.

I'll expand the same method for the other webhook events we issue, but
let's do small PRs so we can have some test runs in between them and
revert in case of issues.

Related: #4327

Change Type

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

I ran a subset of smoke tests that target repos and made the unit tests pass.

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • Checked that related changes are merged.

mockPropsBld: newPropSvcMock(
withSuccessRepoProto(),
),
mockRepoBld: newRepoSvcMock(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can remove these two because we no longer call the repo service to refresh the repository and no longer call the property service. That's all done by the new handler.

}),
),
topic: events.TopicQueueEntityEvaluate,
topic: events.TopicQueueRefreshEntityAndEvaluate,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we send a message to a new handler

@@ -1380,9 +1358,6 @@ func (s *UnitTestSuite) TestHandleGitHubWebHook() {
require.Equal(t, "12345", received.Metadata["id"])
require.Equal(t, event, received.Metadata["type"])
require.Equal(t, "https://api.github.com/", received.Metadata["source"])
require.Equal(t, providerID.String(), received.Metadata["provider_id"])
require.Equal(t, projectID.String(), received.Metadata[entities.ProjectIDEventKey])
require.Equal(t, repositoryID.String(), received.Metadata["repository_id"])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The message in the new handler doesn't have these metadata anymore, the job of the new handler is to figure these out

@coveralls
Copy link

coveralls commented Sep 20, 2024

Coverage Status

coverage: 52.978% (+0.02%) from 52.963%
when pulling 52e6c77 on jhrozek:webhook_repo_refresh_new_handler
into 9f9c6d3 on stacklok:main.

We added new watermill handlers that allow to refresh and evaluate a
generic entity with properties. This is the first patch in a series that
takes these handlers into account with the eventual goal of removing all
the bespoke code from the GitHub webhook handler and eventually remove
direct database access from the webhook handler.

I'll expand the same method for the other webhook events we issue, but
let's do small PRs so we can have some test runs in between them and
revert in case of issues.

Related: mindersec#4327
@jhrozek jhrozek force-pushed the webhook_repo_refresh_new_handler branch from d6b57a0 to 52e6c77 Compare September 22, 2024 09:01
@jhrozek jhrozek merged commit c1c0136 into mindersec:main Sep 30, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants