-
Notifications
You must be signed in to change notification settings - Fork 160
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
Allow testing of multiple library versions #203
Conversation
…ace-php into tests/move-integrations-tests
…llow-testing-multiple-libray-versions
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.
Great work at tackling this tough problem, @labbati! :) I have one little issue with the scenario command changing a file in the working directory.
Other than that, everything looks great! My biggest question is around running the entire test suite. Right now this PR changes the behavior of $ composer test
which now runs only a subset of the tests:
Time: 3.66 seconds, Memory: 10.00MB
OK (155 tests, 221 assertions)
Compared to the entire test suite:
Time: 11.89 seconds, Memory: 22.00MB
OK (345 tests, 1583 assertions)
I think it's really important to be able to run all the tests before submitting a PR, so is there a command we can run that will just run the entire test suite with this change? :)
As an example, in order to run Guzzle tests with Guzzle v5 library, run: | ||
|
||
# Only the first time, to create all the different scenarios | ||
$ composer scenario:update |
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.
After running this command, the LICENSE
file gets updated. Here's the diff:
diff --git a/LICENSE b/LICENSE
index be5bf07..1e187aa 100644
--- a/LICENSE
+++ b/LICENSE
@@ -27,3 +27,16 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DEPENDENCY LICENSES:
+
+Name Version License
+ircmaxell/password-compat v1.0.4 MIT
+opentracing/opentracing 1.0.0-beta5 MIT
+paragonie/random_compat v9.99.99 MIT
+psr/http-message 1.0.1 MIT
+psr/log 1.1.0 MIT
+symfony/polyfill-php55 v1.10.0 MIT
+symfony/polyfill-php56 v1.10.0 MIT
+symfony/polyfill-php70 v1.10.0 MIT
+symfony/polyfill-util v1.10.0 MIT
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.
Thanks for noticing it, let me look at it!
…llow-testing-multiple-libray-versions
The biggest problem here is that while circleci is PHP version aware, composer is not. Some tests, e.g. |
@SammyK I tried to move all the various env specific definitions from circleci's config to composer. I think it makes a lot of sense. What do you think about it? |
@@ -1,5 +1,6 @@ | |||
**/vendor/ | |||
composer.lock | |||
.scenarios.lock/ |
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.
If you want to use composer-test-scenarios to do highest/lowest testing (I recommend this, even for libraries), then you should commit composer.lock and .scenarios.lock. If you only want to do highest testing, then what you're doing here is fine.
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 actually want to test only specific versions that we support. But highest/lowest testing would be a dream for us at a certain point. Thanks for pointing this out.
} | ||
}, | ||
"scenario-options": { | ||
"dependency-licenses": false |
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.
Maybe this should be the default. I like keeping my dependency licenses listed and up-to-date in the LICENSE file, but this feature is orthogonal to the primary purpose of composer-test-scenarios.
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.
Maybe this should be the default.
It probably would make sense, as you suggested this is orthogonal to the purpose of this library. Very nice feature though, and the fact that it is on/off configurable denoted a very forward-thinking approach!
"@composer test -- --testsuite=integration" | ||
], | ||
"test-integrations-56": [ | ||
"@composer scenario:update", |
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.
Are these lists of commands going to be the same across each PHP version?
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.
Right now only mongo tests are different, I expect that as we add more and more versions (soon) they will diverge quite a bit.
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.
👍
Great work @labbati! :) I really like how I can run all the tests with one command. One thing that I think we should consider going forward is how long it takes to run all the tests now. Considering that the tests suite takes several minutes to run and that time will certainly increase with every integration we add, this will eventually become a big issue for development going forward. I'm not sure of an obvious solution right now but I think we should definitely be thinking of some ways to speed this up with caching or something. :) |
Ops sorry @SammyK I had missed this comment before merging. |
Setting up individual pipelines for integrations in circleci config is also an option - doesn't the python integration do something like that? |
Description
When we integrate with different versions of the same library we need a structured way to define the various test scenarios for the several versions. @inverse mentioned this excellent library from @greg-1-anderson that seems to be the perfect tool for us: https://github.com/g1a/composer-test-scenarios
This PR aims at integrating this tool into our code base!
Readiness checklist