Comments (7)
this sounds pretty awesome! 👍
from semantic-release.
@boennemann that's a really cool idea. Keep in mind that it will report a lot of false positives (eg. if my unit tests test a method's implementation, not interface), and will fail to report a lot of stuff (eg. if a test didn't test the right thing, or if an argument type change still makes tests pass).
i took a very different approach with india, relying on jsdoc instead: https://github.com/bcherny/india. Your way of doing it is less fragile than my approach, I think, but may be less accurate.
from semantic-release.
@bcherny Thank you very much for this comment!
False negatives:
I was thinking about this stuff and what it comes down to is that whenever this method fails your test setup isn't optimal. I know that this happens a lot, but I'm not trying to fix these testing problems, but I'm trying to achieve automation for software releases that is better, or at least on par, with what the human would decide. I doubt you would recognize these breaking changes by hand, if your tests are that insufficient.
The way to make the automation better is to stick to best practices and that's a pretty cool thing actually.
False positives:
Same as above: in your example the tests are the problem. There are probably some scenarios where false positives would still be reported. We should add an option to pass the "breaking change detection" for these cases.
I had a brief look at india, and I really like this as well. I would be more than happy if we could build both strategies, or even a combination into this.
Also I should probably make the breaking-change
detection its own module.
from semantic-release.
I think it's more than the test setup being "unoptimal". There are different ways of unit testing stuff, and depending on what you're testing it's reasonable to use the approach that's the best fit. Some examples of this are:
- Fully sandboxed unit testing (mocking out all dependencies, Jest-style)
- Sometimes-sandboxed unit testing (mocking out some dependencies)
- Never-sandboxed unit testing (driving partial-stack integration tests with unit tests)
- Testing implementations (eg. #foo called #bar with "bar", example)
- Testing state (example)
- Testing interfaces (example)
- Testing DOM-related stuff with a detached DOM (example)
- etc.
With good test coverage, it's typical to have some mix of the above in your tests (not just interface tests). Interface tests are good for supplementing JavaScript's lack of static typing, but other types of tests are useful for other things.
False negatives can potentially be an issue too. For example, say I have this code:
// source
function multiply (a, b) {
return a * b
}
// test
assert(multiply(2,2) === 4)
I then decide that multiply
should also accept Strings, so I add some tests:
assert(multiply('2',2) === 4)
assert(multiply('2','2') === 4)
Because multiply
doesn't typecheck its arguments, it ends up being more permissive than it ought to be. An automated semver tool would mark this as a patch change, but really it's a minor change because you went from accepting arguments of type Number
to arguments of type String|Number
(as specified in the tests).
I'm worried that there are too many edge cases like these to make an automated semver tool based on unit tests useful in large projects. On the flip side, my approach with India creates the risk that jsdoc annotations will grow out of sync with function signatures, and makes maintaining your jsdoc necessary. Though Google Closure has enforced type annotations for years (in service of compiling code more efficiently), and Facebook's Flow does as well.
What do you think?
from semantic-release.
@bcherny Thanks again for the comment. I really appreciate the discussion here :)
I think you are raising very valid concerns.
Probably the breaking change detection should never automatically cause a major version bump, but only raise an error that one can suppress with explicitly marking the commit as non-breaking.
That said I would wan't to implement this in a "plugin" kind of way (see #9) and I think both india and my approach would make for a great plugin for semantic-release
. In the end it comes down to individual preferences and I would be happy to fulfill any of these with a modular approach :)
from semantic-release.
(I didn't read the discussion completely, so excuse if i have duplicate input)
Only updating the test folder assumes that all tests in the test folder test only public API. This means that way of detecting breaking changes strongly depends on the way testing was done in this project. Quickly the mockist vs. classisist discussion comes to my mind, or unit and BDD style testing. They all have different implications.
Maybe a "new" category of tests can be defined, kinda like "API tests", "public tests" or maybe even integration tests ... not sure. And those can be used to test what you described. But still that means it depends on people doing it right in this category.
from semantic-release.
https://github.com/christophwitzko/cracks
from semantic-release.
Related Issues (20)
- Issue with commit type "chore(deps):", not ending up in CHANGELOG.MD HOT 2
- TypeError: ((intermediate value) || (intermediate value)) is not a function from commit-analyzer HOT 1
- Semantic-Release can't access to Azure DevOps OnPrem server Git - fatal: Authentication failed
- JSR suggestion HOT 4
- Add plugin semantic-release-hackage
- bad substitution when using nextRelease.version or nextRelease.notes
- fatal: tag already exists HOT 5
- Fetch branches in parallel HOT 1
- Pre-release "counter" not incrementing HOT 6
- Unexpected Minor Version Bump in Beta Release Sequence HOT 9
- Missing Release Notes HOT 1
- Publishing a GitHub release & triggering another workflow HOT 2
- Allow --dry-run option to ignore configured release branches HOT 3
- An error occurred while running semantic-release: SyntaxError: Unexpected identifier 'assert' HOT 6
- Allow branches not under --heads (/ref/heads) to be used as release branches HOT 3
- --plugins CLI flag does not honor plugin configurations
- An error occurred while running semantic-release: Error: Cannot find module `@semantic-release/changelog` HOT 3
- releaserc didn't produce expected results HOT 2
- RangeError: Invalid time value HOT 7
- RangeError: Invalid time value HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from semantic-release.