-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Detect from commit history which service tests to run #1936
Conversation
Generated by 🚫 dangerJS |
…into auto-service-tests
# Conflicts: # package.json
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.
Apart from the minor observations regarding the logs, two points come to mind:
- if my understanding is correct, affected-services.js is not calling
identifyTesters
, therefore if only the tests are modified, they won't be run? Is this really what we want? - "The test runner examines the commit history to automatically detect which services to test. If for any reason it's not detecting the correct services [...]". What about changes made to server.js? Most of our services are currently in there and it's still the way of doing things recommended by the tutorial. I feel like we would be confusing contributors if we're basically saying that something is expected to happen but it won't actually happen in most cases, at least in the current state of things.
Let me know whether this makes sense!
if (services.length === 0) { | ||
console.error('No services found. Nothing to do.') | ||
} else { | ||
console.error( |
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.
Why is this logged as an error?
console.error( | ||
`Services: (${services.length} found) ${services.join(', ')}\n` | ||
) | ||
console.log(services.join('\n')) |
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.
Isn't this similar to the previous log line? Also, we're logging about the found services in cli.js, so do we need these logs here at all?
Thanks for the review comments! What you're saying makes perfect sense. I'll respond soon in more detail. |
Good points made by @PyvesB - agree with both points. Also thanks for getting into the more detailed stuff. I haven't done a properly detailed read of this code, but I've had a think about the top-level concept and I've also checked out the code to try a few things and I do have some thoughts on this:
|
yourself: | ||
|
||
npm run test:services -- --only=travis | ||
|
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 should add a note to the docs here that we can also run npm run test:services -- --all
to run the full service test suite.
Thanks for the additional comments! I pretty much agree with you. In my workflow I'm typically refactoring heavily until I finish, so I alternate between troubleshooting an individual service and making sure I broke nothing else. Troubleshooting an individual service – is that similar to the mode you're describing? I could see testing on my uncommitted changes covering that case pretty well. Are these the four cases we want to support?
This is possible with this code by putting the customary bracketed names into a commit message. Want to give that a shot and see how it feels? |
I meant to add: sorry my responses have been a little short this week! I've had a busy several days and am trying to squeeze in as much Shields work as possible into short sprints here and there. |
Yeah, sorry. "uncommitted" would be a better word than "unstaged" 👍
Is the PR title supported, or only the commit message?. I think its still important to be able to use the PR title: If you think about a dependency, having to check out dependabot's branch, edit the commit message and force-push it back up is additional friction especially when we'll probably lose it again when dependabot auto-rebases. |
A few options to think about…
Only the commit message. I think you've seen it happen (and commented recently) that CircleCI builds don't correctly detect that they are on a PR. There is no way to do that reliably with CircleCI. Actually, that's not completely true. There is one way to do it: configure CircleCI to run only on PRs. That would necessitate either:
Alternatively, we could experiment with another way to handle Dependabot, which is to check out the branch and push a second commit. Or to edit something in the UI (we could designate a dummy file to edit, like a Finally, we could consider running service tests through a different CI service that is more tightly bound to PRs. Rather than editing the PR, we could have a bot that listened for comments like @shields-ci test appveyor service and triggered additional builds. Finally, we could combine these techniques. If Dependabot plays well enough with additional commits on the branch, we could use PR comments to trigger a bot that pushed a commit. |
Having done a quick test: #1949 (comment) we lose that as soon as we push another commit. I think not having that feature will become annoying.
Personally I think this is the nicest suggestion as it fits in quite nicely with the dependabot Another option, of course, is we can run the relevant tests locally (I probably prefer that to losing dependabot auto-rebase). If we can solve everything else, that's a viable interim solution because we can use the commit message text in the case where we're making a modification to base classes/error handling/etc which doesn't directly touch any service but has impact on multiple services. |
Totally agreed. Merging master through the UI (using the Update branch button) is not much harder than manually rebasing; I wouldn't mind doing that in the interim. |
I'm not happy with the current state of affairs, and while there are aspects of this approach I really prefer, it's clear it will need to be rethought through. Maybe we should use a bot. Could be in conjunction with CircleCI, another on-demand system, or something like Drone. I'd prefer something on-demand so it doesn't require sysadmin effort or create a knowledge or access bottleneck. |
This reworking of the service test detection decouples it from pull requests. It automatically detects which services to run by examining the git working tree and commit history. This is a really nice dev experience. You run
npm run test:services
and it does the right thing. In the rare case where you don't want that, you can pass-- --all
or-- --only=
.CircleCI seems to clone the entire history and all its branches by default, so I think this will work there, too. 🤞
Service tests can no longer be tagged in the PR title. However, they can be tagged in a commit message. Any tagged services are tested in addition to the auto-detected services. There's a minor tradeoff here in the manual tagging: services can be tagged prior to opening the PR and the PR titles are less cluttered; however, it's necessary to push a commit if you want to test more services.
This approach is way more reliable and much simpler: a net deletion of 2 scripts, a temporary file, and 100 lines of code.