societe-generale / ci-droid-tasks-consumer Goto Github PK
View Code? Open in Web Editor NEWCI-droid consumer, receiving tasks to perform
License: Apache License 2.0
CI-droid consumer, receiving tasks to perform
License: Apache License 2.0
In Event
the copyOfMdc we do the first time is null, so MDC doesn't get cleaned, while it has been modified
It is a :
MDC content is not cleaned properly the first time it's used, so its content "leaks" to subsequent calls
MDC should be cleaned properly, so that each call is actually independent and we don't end up logging MDC attribute of previous event(s)
When PR already exists but we still try to create one, an exception is thrown. commit has happen, but we don't receive any notification
Ideally, we should use a DirectPush instead of PullRequestGitHubInteraction, but in case we didn't we should still receive a notification
It is a :
2018-08-14 15:02:25.761 [] WARN 22828 --- [github-events-1] c.s.c.t.c.i.ActionToPerformListener : some unexpected error happened
feign.FeignException: status 422 reading FeignRemoteGitHub#createPullRequest(String,PullRequestToCreate); content:
{"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"A pull request already exists for ItecFccOsd:sonarMigrationAugust."}],"documentation_url":"https://developer.github.com/enterprise/2.13/v3/pulls/#create-a-pull-request"}
at feign.FeignException.errorStatus(FeignException.java:62)
at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:91)
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:138)
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76)
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103)
at com.sun.proxy.$Proxy104.createPullRequest(Unknown Source)
at com.societegenerale.cidroid.tasks.consumer.services.ActionToPerformService.createPrOnBranch(ActionToPerformService.java:207)
at com.societegenerale.cidroid.tasks.consumer.services.ActionToPerformService.createPullRequest(ActionToPerformService.java:90)
at com.societegenerale.cidroid.tasks.consumer.services.ActionToPerformService.perform(ActionToPerformService.java:74)
at com.societegenerale.cidroid.tasks.consumer.infrastructure.ActionToPerformListener.onActionToPerform(ActionToPerformListener.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:180)
Exception should be caught (logged as warn), and flow should continue normally so that notification is sent.
Following Spring Boot 2.2 upgrade, we're supposed to use Spring Cloud Hoxton M3. However, when upgrading Spring Cloud, build fails
we should keep dependencies up to date, according to Spring recommendations
Build fails because of test failure in PRtitleShouldBeReceivedAsSent
:
09:25:52.857 [main] DEBUG org.springframework.context.annotation.AnnotationConfigApplicationContext - Closing FeignContext-github, started on Sat Oct 19 09:25:48 CEST 2019, parent: org.springframework.context.s
upport.GenericApplicationContext@7158a28c
09:25:52.860 [main] ERROR org.springframework.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionLi
stener@24b9c037] to prepare test instance [com.societegenerale.cidroid.tasks.consumer.infrastructure.FeignRemoteGitHubTest@570f2cf7]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:123)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:244)
...
...
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'actions-to-perform' available
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:805)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1278)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:297)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207)
Test should not fail and build should pass ;-)
check out branch withSpringCloudHoxtonM3
(https://github.com/societe-generale/ci-droid-tasks-consumer/tree/withSpringCloudHoxtonM3) and run mvn clean install
Maven home: C:\Program Files\dev\apache-maven-3.5.4\bin..
Java version: 1.8.0_171, vendor: Oracle Corporation, runtime: C:\Program Files\dev\jdk8_171\jre
Default locale: fr_FR, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
I recently noticed that Spring Boot released their first milestone for the v2.2.0.
This new version has updated the JUnit Jupiter dependency from 5.3.2 to 5.4.0.
It could be a good thing to upgrade to this version since we had version conflicts for JUnit Jupiter in #61 and #65 (spring was pulling 5.3.2 which forced us to explicitly add the junit-jupiter-api artifact instead of relying entirely on the junit-jupiter aggregate).
Only question is, should we use the milestone or wait for a more stable release?
It is a :
Similarly to societe-generale/ci-droid#7 , let's get the git login from the Oauthtoken, using https://developer.github.com/v3/users/#get-the-authenticated-user
It is a :
more consistency, and one less field for the user to provide.
right now, any value provided as gitLogin will be used, even if user ID doesn't actually exist
Tasks consumer still looks at @type to find the action type, but it has changed to "class" - this causes a NullPointerException when message is processed.
It is a :
Using CI-droid and tasks consumer v1.0.1, we get a NullPointerException in tasks consumer when the message is processed.
Related to societe-generale/ci-droid#6 : new "pullRequestTitle" field needs to be taken into account when creating the PR
It is a :
the PR is created, but takes the commitMessage as title : now that a dedicated field (pullRequestTitle) has been introduced in the model, we should use it
use pullRequestTitle if provided - otherwise use the branch name as PR title
When using a bulk action with PullRequestGitHubInteraction, the branch for the PR should be created on top of the branch we mention for each resource.
It is a :
it seems to be creating the branch for the PR on top of the default branch of the repository, not the branch we mention for each resource
If I post below action
"gitHubInteractionType": {
"@c": ".PullRequestGitHubInteraction",
"branchNameToCreate":"DTRchange",
"pullRequestTitle":"DTR change to proper value"
},
"resourcesToUpdate": [
{"repoFullName": "myOrg/myProject","filePathOnRepo": "docker-stack.yaml","branchName": "prd"}
]
we expect the "DTRchange" branch to be created on top of "prd" branch
Giving feedback to developers on the size of their PR (too many files/lines modified) would be very helpful :
It is a :
Small, focused PRs are easier to review and are more likely to be accepted. Having PRs that are big beyond a certain threshold, is usually a smell : either the story slicing is not fine enough, or developers is not able to break down the tasks himself.
We implement a PullRequestEventHandler that can be configured with max number of files and lines. if the PR size is bigger than the configured threshold, CI-droid should post a comment on the PR, warning the developer that his/her PR is too big and that it's not a good practice. can he/she try to split his/her change in smaller PRs ? If not, explain why in comments.
have a look at https://github.com/societe-generale/ci-droid-tasks-consumer/blob/master/ci-droid-tasks-consumer-services/src/main/java/com/societegenerale/cidroid/tasks/consumer/services/actionHandlers/BestPracticeNotifierHandler.java to get an idea of what a PullRequestEventHandler looks like
it seems GitHub and BitBucket (at least) won't start in synchronous mode, because of
Ambiguous mapping. Cannot map 'sourceControlEventController' method
The controller is both scanned (because annotated with @RestController
) and instantiated in the respective configs.
see failing tests in https://github.com/societe-generale/ci-droid-tasks-consumer/tree/issue98
Need to find a way to manage both while enabling tests to pass (BitBucketSourceControlEventControllerTest
expects the scanning to happen for instance)
Bit bucket feature to update file works only when last modification of the source branch starts from files first line.
It is a :
It would be nice to close automatically old PRs.
perfoms rebase automatically, so a PR event will be generated.
When that PR event is generated, we could listen to it and close the PR if it's too old
It is a :
When developers don't close PRs , rebasing several old open PRs can be expensive
implementing a https://github.com/societe-generale/ci-droid-tasks-consumer/blob/master/ci-droid-tasks-consumer-services/src/main/java/com/societegenerale/cidroid/tasks/consumer/services/actionHandlers/PullRequestEventHandler.java would be fairly simple
PushEvents are handled by a list of PushEventOnDefaultBranchHandler. If one of them throws a RuntimeException, then others are not called.
It is a :
we should catch runtime exceptions when calling handlers, so that other handlers can be called.
The project could not be analyzed because of maven build errors. Please review the error messages here. Another build will be scheduled within 24 hours. If the build is successful this issue will be closed, otherwise the error message will be updated.
This is an automated GitHub Issue created by Sonatype DepShield. GitHub Apps, including DepShield, can be managed from the Developer settings of the repository administrators.
As mentionned by @juliette-derancourt in #45 , we need to move out of https://github.com/CodeStory/fluent-http which is not actively supported anymore, and use http://www.mock-server.com/ instead.
Mock-server has already been added, so we just need to migrate the tests using fluent-http to mock-server, and remove the dependency.
It is a :
consistency and clarity : both libs are equivalent, one has more features and is maintained, the other isn't.
It may happen that user doesn't provide correct repository name when perfomring bulkAction, for instance, he/she may forget the organizationName.
This will result in a NullPointeException in
It is a :
this case should be anticipated and mapped to a specific com.societegenerale.cidroid.api.ResourceToUpdate.UpdateStatus
Currently, CI-droid works only with Github Enterprise Edition (GHE). We need to make it compatible with github.com
It is a :
To favor the usage outside corporates
interactions with Github.com fail because some calls to the API are hardcoded, and the URL pattern is different between github.com and GHE
Probably need a change similar to societe-generale/github-crawler@8eeb050
When commenting the config for PullRequestEventHandler, the application fails to start
It is a :
When commenting below config
bestPracticeNotifier.enabled: true
patternToResourceMapping:
"**/*Dto.java": "https://sgithub.fr.world.socgen/raw/ItecFccOsd/financing-platform-documentation/master/ci-droid-best-practices/noDtoClass.md"
Application fails to start
• Jul 03 15:54:57 ci-droid-tasks-consumer: WARN | | Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pushOnMasterListener' defined in class path resource [com/societegenerale/cidroid/tasks/consumer/infrastructure/config/InfraConfig.class]: Unsatisfied dependency expressed through method 'pushOnMasterListener' parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pullRequestEventService' defined in class path resource [com/societegenerale/cidroid/tasks/consumer/infrastructure/config/InfraConfig.class]: Unsatisfied dependency expressed through method 'pullRequestEventService' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.util.List<com.societegenerale.cidroid.tasks.consumer.services.actionHandlers.PullRequestEventHandler>' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} | org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext
this part of the config shouldn't be mandatory. If no PullRequestEventHandler is defined, a default NoOp one should be instantiated.
If an unexpected error happen (a null pointer exception for instance), the bulkAction processing will fail, but no notification is sent, leaving the requestor in the unknown.
It is a :
More clarity for end user
send the exception content through notification to the user.
When the app is deployed in a container, it needs to provide a healthcheck so that container can be killed if it's unhealthy.
It is a :
since there's no healthcheck, when deployed as a container, it gets killed every few minutes
Expose an endpoint (through Spring Boot actuator) that can be queried for healthcheck
When sending below action, branch is created, but not the PR :
{
"gitLogin": "vincent-fuchs",
"gitHubOauthToken": "XXXXXXXXXXXXXX",
"email": "[email protected]",
"commitMessage": "removing maven-source-plugin",
"updateAction": {
"@class": "com.societegenerale.cidroid.extensions.actionToReplicate.RemoveMavenDependencyOrPluginAction",
"artifactId": "maven-source-plugin"
},
"gitHubInteractionType": {
"@c": ".PullRequestGitHubInteraction",
"branchNameToCreate": "removingMavenSourcePlugin"
},
"resourcesToUpdate": [
{"repoFullName": "myOrga/myRepo","filePathOnRepo": "pom.xml","branchName": "master"}
]
}
No error in logs either..
It is a :
PR should be created
it would be nice to get easily some usage KPIs on CI-droid bulk actions, ie how many commits, PR have been performed, etc using https://github.com/societe-generale/ci-droid-tasks-consumer/blob/master/ci-droid-tasks-consumer-services/src/main/java/com/societegenerale/cidroid/tasks/consumer/services/monitoring/Event.java
It is a :
get a better view of how the tool is used, by whom, etc
we should be able to configure OAuth token for comments to be posted on PRs.
It is a :
Right now we're getting :
feign.FeignException: status 401 reading
FeignRemoteGitHub#addCommentDescribingRebase(String,int,Comment)
at feign.FeignException.errorStatus(FeignException.java:62)
at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:91)
comments should be posted through API.
current bulk action only allow to modify/create a given resource, not to delete it
It is a :
It's convenient in some cases, to perform some clean-up
the current flow doesn't allow to integrate this feature seamlessly as a regular ActionToReplicate. So we may need to perform some ugly type check at some point, so that if the ActionToReplicate is of type DeleteResourceAction, then don't fetch the content and try to modify it, just delete it.
We'll see later if there are other similar actions that don't "fit" if we can create a better abstraction. But for now, let's manage it like this.
When we post a bulk action, it can happen that we want to create pull request (using .PullRequestGitHubInteraction), but the provided list of resources contains more than 1 resource on the same repository.
It is a :
What will happen in that case is that the commits will end up in the same branch, but several PRs will be created, on top of same branch.
Before creating a PR, check if there's not already one created on top of same branch, with same title. If that's the case, don't create a PR.
in
Because of that, actions like TemplateBasedContentAction fail to be performed.
It is a :
we should be able to send a TemplateBasedContentAction and expect it to be processed correctly, not throw a NullPointerException
Some teams may want to have an additional gate keeper checking the size of a PR (nb of files and lines modified), to give feedback to developers when PRs are too big
It is a :
Spring Boot 2 is now mature, so we should target to migrate towards it
ActionNotificationService is really becoming bulky and needs to be refactored, so that complexity is reduced.
It is a :
better maintainability
we recently removed dummy classes (DummyPullRequestEventHandler and DummyPushEventOnDefaultBranchHandler) :
but they are actually required.
It is a :
if there's no other PullRequestEventHandler class instanciated at startup, then the application fails to start :
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.util.List<com.societegenerale.cidroid.tasks.consumer.services.actionHandlers.PullRequestEventHandler>' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
application should start correctly, even if no PullRequestEventHandler is configured in properties
In #37, we fixed an urgent bug after testing manually.
It is a :
We need to rework the code a bit and add unit tests for the bug we fixed.
right now, it fails with :
feign.FeignException: status 401 reading ContentClient#updateContent(DirectCommit) at feign.FeignException.errorStatus(FeignException.java:62) at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:91) at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:138) at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76) at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103) at com.societegenerale.cidroid.tasks.consumer.infrastructure.$Proxy136.updateContent(Unknown Source) at com.societegenerale.cidroid.tasks.consumer.infrastructure.FeignRemoteGitHub.updateContent(FeignRemoteGitHub.java:97)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.