-
Notifications
You must be signed in to change notification settings - Fork 39
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
Travis Build Failure monitor(ing) #469
Conversation
ae4cfa6
to
b5e0a68
Compare
b5e0a68
to
15e9ea2
Compare
Update: I think this is a pretty decent working copy for a first pass. Currently this will:
Using the following config settings: ---
# ...
gitter:
api_url: http://localhost:5000
api_prefix: "/api/v1"
# ...
travis_branch_monitor:
included_repos:
- ManageIQ/manageiq: not-real-group/community
- GrumpyTech/manageiq-loggers: not-real-group/community (note: For the following builds for the
I got the following results running |
6ec3222
to
b276186
Compare
b276186
to
cc19d04
Compare
@Fryguy Addressed your changes. Thanks for the feedback. |
e665526
to
64aab6d
Compare
4fdc75a
to
e8fb1db
Compare
FYI: These |
e8fb1db
to
737a524
Compare
737a524
to
2e9adb5
Compare
app/workers/travis_branch_monitor.rb
Outdated
end | ||
|
||
def process_repo(repo) | ||
# repo.regular_branch_names.each do |branch| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most definitely. This code definitely is subject to "copy-pasta syndrome".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Followup: I didn't review this comment without looking at the context.
So I think this is related to the TODO
that is below:
# TODO: Handle this for all release branches
process_branch(repo, 'master')
And probably what should be done is we should be doing repo.regular_branches
(?) and passing the branch_record
directly into process_branch
instead of doing the lookup there. That said, unsure if regular_branches
does what we want in this case. Would have to look.
That is also a question if we want to first start with 'master' for a first pass to test this feature out and then move on to the release branches going forward. That way we can determine if this is indeed the route we want to take with this, or if it is causing too much noise in chat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't want to track all of the regular_branches
it probably only makes sense for a subset (master, jansa, ivanchuk, hammer) or something like that. Maybe that belongs in a setting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that probably makes sense.
This probably falls in the "doesn't need to be a private setting" category argument that I have been making, but we can adjust that at a later date. I will look into making this a regular setting for now. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't want to track all of the regular_branches it probably only makes sense for a subset (master, jansa, ivanchuk, hammer) or something like that. Maybe that belongs in a setting?
We only track branches (in the database) that we care about, so I think all regular branches is ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to do some cleanup then because we are tracking everything back to darga.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently using .regular_branches
for this, so I think that has resolved this from a code aspect. Leaving this unresolved just so it isn't lost as something we might want to look at on prod.
branch_record = repo.regular_branches.where(:name => branch).first | ||
|
||
# If we already have a failure record, call notify with that record | ||
return branch_record.notify_of_failure if branch_record.previously_failing? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check that it's still failing first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this probably is a "naming is hard" problem, but .notify_of_failure
actually does that. It does the .passing?
check which will determine if a repo is still failing for that given branch.
I do forget the rational for my logic as to "why" I split it up like this, so I will have to look at this again, but the logic does as you wish, it just is a little unclear.
> | ||
> **Travis Build**: #{travis_build_url} | ||
MSG | ||
notification_msg << "> **Failure PR**: #{offending_pr}\n" if offending_pr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not always a PR to that repo which causes the failure. Sometimes a merge to core breaks the API repo, but it is only noticed after the API repo cron runs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is why the if offending_pr
is there, which can return nil
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I am open to suggestions on how we can improve this to better provide context for the message. I realize that this could still display a false positive by displaying the "last merged commit" on something that was merged weeks ago, so maybe only display the PR if it was merged recently? Within the last 3 days?
Also, does this need to be rebased due to the rails upgrade? |
Shouldn't, as I just rebased it earlier today (fixing that exact problem) |
2e9adb5
to
1a3473a
Compare
2ab07b5
to
40e5a58
Compare
40e5a58
to
b32a16b
Compare
b32a16b
to
53922e8
Compare
A small Travis API client library that is a compliment to the `travis` gem, but allows the use the v3 API endpoints for specific calls with the v2 based client library entities. Currently implements two methods: * `.repo_branch_builds`: Fetch a collection of builds from a branch * `.repo_build`: Fetch a singular build via ID For the second, the client actually still uses the v2 API, but doesn't use the default model's `.builds.first` approach (doesn't filter/fetch properly), and just fetches using the `find_one` interface.
This class is a service class in charge of the logistics of sending a message to a configured gitter channel for a given repo, notifying there has been a failure.
Use the Branch record to keep track of build failures that we find when polling the Travis API. The main purpose is to avoid spamming gitter with extra notifications, but also can be used to identify that a branch has previously been broken and now has been fixed. Makes sense to also notify on the passing cases so others aren't taking the time to investigate a failure when this has already been investigated/fixed by another.
Worker that is in charge of monitoring Travis for build_failures, and will create BuildFailure records and send messages to gitter as needed.
A task for triggering a single run of the TravisBranchMonitor without needing sidekiq running.
53922e8
to
d68b6a4
Compare
Checked commits NickLaMuro/miq_bot@dad56ec~...d68b6a4 with ruby 2.5.7, rubocop 0.69.0, haml-lint 0.28.0, and yamllint lib/build_failure_notifier.rb
spec/workers/travis_branch_monitor_spec.rb
|
This pull request is not mergeable. Please rebase and repush. |
@Fryguy now that we moved to GitHub Actions, assuming this should be closed? |
Note: Currently still finalizing a lot here, so this is not ready for #PrimeTime™. Just putting this up so folks know what is going on in the bot channel.Adds a new worker that is in charge of monitoring Travis CI for build failures on monitored branches, and will post notifications in their respective channels.
This pull requests adds multiple classes/models/libs to help facilitate this functionality:
TravisBranchMonitor
) class, that is mostly in charge of querying builds we care about,creatingupdatingBuildFailure
Branch
records as needed, and sending BuildFailureNotifications when necessary.AUpdates to thebuild_failures
branches
table/model, which keeps track of previously failed builds (helps to avoid spam in chat, and we can post when a previously failing build has been fixed)BuildFailureNotifier
: A service object in charge of the sending messages togitter
. Uses thegitter-api-ruby
gem to do that.TravisV3Client
: A simpleFaraday
client lib that allows for usingv3
API endpoints with thev2
API basedtravis
gem.travis
gem and addsgitter-api-ruby
.Links