-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Added JS Jasmine tests to Travis CI #9013
Conversation
Hi @Igloczek Could you please look into some questions I've left in the comments? Thanks! |
@ishakhsuvarov I'm pretty sure you forgot to hit "Submit review" 😉 |
dev/travis/js/config.php
Outdated
@@ -0,0 +1,360 @@ | |||
<?php |
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.
Adding a hard-coded configuration may be too fragile, since it may be a subject for modification. Please consider installing to get the generated file
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.
I was following docs in this matter, b/c installing the whole application, just to get statics, it's serious overhead for me.
Maybe simpler option will be to work on source files, rather than processing them through M core, before running tests? It should be also easier for development purposes.
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.
The documentation in question is about generating static on a non-production machine, so this is a slightly different case. Providing a hard-coded configuration file is not the best practice and needs to be maintained all the time.
I would still suggest installing application for now, at least for consistency, since internally this is what we do to run Jasmine tests.
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.
@ishakhsuvarov could you move some internal code to public maybe so that we don't have two different implementations?
From https://github.com/magento/magento2/blob/develop/dev/travis/before_script.sh#L61 it looks it is not so easy to steal application installation from integration tests and it is placed somewhere inside framework.
As to me hardcoded config seems fine at least as a temporary solution if we add comment on top of it how to regenerate file.
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.
@orlangur It is executed under different infrastructure then Travis CI. Would not solve the issue in question.
"Stealing" application from the integration tests is not a good solution either. Clean install should do the trick for now, while no better solution is available.
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.
@ishakhsuvarov what do you mean by clean install? :) I thought installation in scope of integration tests is clean. Is it possible to install application without database at all, for example?
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.
@ishakhsuvarov Could you share part of your tests configuration related to installation? Will be much easier to copy-paste(-adjust) working solution 😉
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.
@Igloczek So, I've done some brief experiments with Travis CI and here is what seems to be working:
- Instead of bundling
config.php
add the minimum installation as follows (it does not add too much time to the execution):
echo "Installing Magento"
mysql -uroot -e 'CREATE DATABASE magento2;'
php bin/magento setup:install -q --admin-user="admin" --admin-password="123123q" --admin-email="[email protected]" --admin-firstname="John" --admin-lastname="Doe"
- You may do some experiments with the static content deployment settings to add a bit more performance. Here is what worked for me (may not be the best solution, just experiment):
echo "Deploying Static Content"
php bin/magento setup:static-content:deploy -f -q -j=2 --no-css --no-less --no-images --no-fonts --no-misc --no-html-minify
dev/travis/before_script.sh
Outdated
|
||
cp package.json.sample package.json | ||
cp Gruntfile.js.sample Gruntfile.js | ||
npm install -g yarn |
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.
Is it really viable to install yarn
just to install grunt-cli
?
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.
Not only grunt-cli
, all dependencies defined in package.json
are downloaded using yarn
in line 90 (yarn
is replacement for npm install
).
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 clarification.
@Igloczek You are so right |
dev/travis/before_script.sh
Outdated
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash | ||
export NVM_DIR="$HOME/.nvm" | ||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm | ||
nvm install --lts |
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.
I believe it would be more robust to specify some concrete version, like in https://github.com/BanzaiMan/travis_production_test/blob/9c02aef/.travis.yml#L15, so that we see in environment variable which version we test against
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.
I'm not sure if we really need to care about precise versioning, b/c in Oct 2017 we should be ready to use v7 without any issues and necessary updates in code base.
Node.js LTS plan is precisely described here - https://github.com/nodejs/LTS
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 I understood the doc right v7 is not LTS and will not be used in such code.
The point is that I don't see any value in dynamic Node.js
version, it can only bring us some headache when the LTS version will switch. Explicit is better than implicit.
As soon as v8
stable is released we can change value in our config if the tests still pass. Current version is like specifying php: stable
version instead of concrete value.
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.
You are right, v8, not v7.
LTS means more than stable, b/c stable v8 will be released in April 2017, but will be marked as LTS in Oct 2017. It's a different approach than PHP takes.
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.
Is it guaranteed that using v6 for tests before, we will not have any issues under v8 when it become LTS? What's BC police?
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.
OFC there are BC between major releases, but major becomes LTS after half year and most of the packages get updates during this period, so migration is in most of the cases are seamless.
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 does not mean all our tests will work without changes.
Just answer the simple question - what is the value of NOT specifying a concrete version but using LTS instead?
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.
By the way, package.json.sample
bundled with Magento also has version requirement.
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.
You are always up to date, don't have to follow releases schedule etc. When new LTS version will be up, your tests will start using it.
But to just quit discussion, I'll change it to 6
and this will be good enough till next LTS.
Docs about engines
option from package.json
this field is advisory only will produce warnings when your package is installed as a dependency.
So in our case, we can simply remove this param.
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!
When new LTS version will be up, your tests will start using it.
Yeah, that's a scary part as to me, as put our builds a bit out of control.
before_install: ./dev/travis/before_install.sh | ||
install: composer install --no-interaction --prefer-dist | ||
before_script: ./dev/travis/before_script.sh | ||
script: | ||
- test $TEST_SUITE = "static" && TEST_FILTER='--filter "Magento\\Test\\Php\\LiveCodeTest"' || true | ||
- phpunit -c dev/tests/$TEST_SUITE $TEST_FILTER | ||
- if [ $TEST_SUITE != "js" ]; then phpunit -c dev/tests/$TEST_SUITE $TEST_FILTER; fi | ||
- if [ $TEST_SUITE == "js" ]; then grunt spec; fi |
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.
Looking at https://travis-ci.org/magento/magento2/jobs/215020317 - is there some less verbose mode? Display only failed tests maybe...
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.
No idea, for now I just focuses on make this test running, then we can think about some adjustments / improvements.
PS. I really hate Grunt, so if I don't have to modify this, I will be more than happy to leave it as it is 😉
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.
Ok, I didn't use it as well, and didn't google for a solution just in case you know the answer.
It can wait until it become a problem "output is too big" some day (hopefully never).
@Igloczek Looks good to me now! Thanks for the fixes. |
You are faster than my thoughts, I was going to do same thing 😄 |
Please stop the merging process, I found a bug related to NVM and we are now using some built-in Node.js version. |
@Igloczek Thanks for reporting |
Fixed. |
dev/travis/before_script.sh
Outdated
@@ -80,8 +80,8 @@ case $TEST_SUITE in | |||
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash | |||
export NVM_DIR="$HOME/.nvm" | |||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm | |||
bash -c "nvm install $NODE_JS_VERSION" || true |
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 there was bash
used at all in the first place?
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.
Just b/c I'm a dumb copy-paster 🙄
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's absolutely fine as I had just an approximate understanding of what is going on when reviewed your code as well 👍
Hope we have some decent DevOps in Magento Community or in Magento Team to review Travis scripts :)
@Igloczek thank you for your contribution! |
JS tests are already written, but not used on Travis CI pipeline, so I added the necessary config to enable them.