Skip to content
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

Enhanced the provisioning to better adhere to VVV2 standards #2

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

jcomack
Copy link

@jcomack jcomack commented Oct 31, 2017

This PR introduces a new provisioning script that better adheres the standards of VVV2.

By using this script, the process should also better reflect Yoast standards.

To test, please create a new virtual environment by executing the steps described in README.md and ensure you can run both the PHP and the JavaScript tests.

Copy link
Owner

@kraftner kraftner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First one general thing about the approach: Why did you replace Composer with using WP-CLI for installing WP? I think this makes things way more difficult to read.

I haven't actually tried this, this is just a first look at the changes, will try to do so later this week.

README.md Outdated
repo: https://github.com/kraftner/yoast-acf-analysis-development.git
hosts:
- yoast-acf-analysis.vvv.dev
- yoast-acf.dev
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the naming:

  1. We shouldn't use .dev but .testinstead. See Change TLD for test sites Varying-Vagrant-Vagrants/VVV#583 for details
  2. To stay in line with Rename repository to match the WordPress.org slug Yoast/yoast-acf-analysis#99 I'd say we should call it acf-content-analysis-for-yoast-seo.vvv.test or at least yoast-acf-analysis.vvv.test for now but not a new name again.

README.md Outdated
@@ -36,7 +40,10 @@ If you want to auto-configure your VVV machine with those add the following to y

After that to run the tests for ACF 4 run `npm run test-acf4` inside the plugin folder.

To run the tests for ACF 5 you first need to install ACF 5 as we cannot do this automatically as it isn't a free plugin.
After you've done that you can simply run `npm run test-acf5pro`.
To run tests for ACF 5 you first need to install ACF 5 manually, as we cannot do this automatically due to it not being a free plugin.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should now be ACF 5 PRO as the release of ACF 5 FREE is imminent.

README.md Outdated
After you've installed ACF 5, you can simply run `npm run test-acf5pro`.

**Note:**
If you do not want to run the browser tests with Chrome and/or in headless mode, you'll need to change `nightwatch.json`, `nightwatch.conf.example.js` and `env.js` in your virtual machine.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was intentionally written using some and not and as depending on what you are trying to do only some need to be changed.

This is the relevant docs, maybe a link would be nice though: http://nightwatchjs.org/gettingstarted#settings-file

var page = browser.page.WordPressHelper();
page.login();
}
};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to check back on this but there was a particular reason why I was doing it like this...I just can't remember now. Should have documented that...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I attempted to use the previous configuration, I couldn't get the tests to run at all. @moorscode found that basic configuration which did seem to do the trick, hence why I changed it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I remember now what the issue was: When using the plain chromedriver without xvfb the headless chrome wasn't properly working on any interaction with an input (something about missing keycode conversion without a window manager).
Did you try provisioning with that change and run the Nightwatch tests successfully? Maybe they have meanwhile fixed this in a recent Chrome version.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests weren't successful as logging in resulted in an immediate redirect to the login page. I don't believe that's related to this change.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I've looked into this and it seems as if Chrome fixed this in the meantime, so yeah, this change is ok by now.

yoast-acf.test
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay here is .test like proposed above. This should be the same obviously.

@jcomack
Copy link
Author

jcomack commented Nov 1, 2017

The main reason I removed the Composer package that handles the installation of WordPress, is because VVV had a perfectly fine (and flexible) method to install WordPress for us. See https://github.com/Varying-Vagrant-Vagrants/custom-site-template for the template that I used for this new setup.

Keeping all installations similar in file structure makes it easier to work with this for multiple people. That was my main thought behind all this :)

@kraftner
Copy link
Owner

kraftner commented Nov 2, 2017

First things first: Thanks for the changes, the majority of this looks great!

Concerning the switch away from Composer: Don't get me wrong - I totally understand your reasoning and appreciate the intention to make everything more approachable.

The thing is that the same reasoning goes the other way for me: I build everything WP I do using Composer and WP Starter nowadays so for me personally this complicates things as I need to mentally adapt to another stack. I'm currently pondering if I should just live with that or a fork might be the better option. I'll get back to you on this soon. 😄

@tomjn
Copy link

tomjn commented Nov 3, 2017

I would recommend using WP CLI if a WP root package is necessary, else composer might delete WP and replace it, deleting all the nested packages in the process. It also makes it easier to pass in variables from the provisioner script

acf-content-analysis-for-yoast-seo.test
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file isn't necessary if you've already got the hosts in vvv-custom.yml, support for vvv-hosts is mostly for convenience and backwards compatibility with VVV 1

@kraftner
Copy link
Owner

kraftner commented Nov 3, 2017

@tomjn 👋 How did you end up here 😉
If by root package you mean not having core in a separate folder that is a no-brainer when using composer anyway.
The variables argument is a valid one though.

Copy link
Owner

@kraftner kraftner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I have now finally found time to look into this, thanks for your patience. I am still not totally happy about the switch away from wpstarter/composer but I understand the reasoning to keep it a more standard setup to make it easier to grasp the setup for contributors. So I am willing to merge this in once we have sorted out the issues below.

Concerning the issues you had with running the JS tests I was able to reproduce it and have found the reason:
With the current setup WP Core is in a subfolder, so

http://example.com/wp/wp-admin

which I (unfortunately 😞 ) also hardcoded in the tests here and here

By changing the install to a more default one the extra /wp/ is triggering a logout because of the invalid address (Don't ask me why that is, for some reason WP seems to think it is a smart idea to log out people after opening an invalid admin URL 🙄)

Now, to fix this we need to change this in the main plugin repo which on the other hand breaks all the tests in the current setup. Although this is a breaking change it will only affect people working on the plugin so I think we should do it. But at least do it simultaneously as soon as this PR is ready to be merged in.

- yoast-acf-analysis.vvv.dev
- acf-content-analysis-for-yoast-seo.test

**Note that you can change `acf-content-analysis-for-yoast-seo.test` to any other name, if that's what you prefer.**

If you do not want to provision the default sites that come with VVV make sure to *only* have this in the `site` section.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should say sites here

sed -i "s#{{DOMAIN}}#http://${DOMAINS}#" "${VVV_PATH_TO_SITE}/public_html/wp-content/plugins/yoast-acf-analysis/tests/js/system/nightwatch.conf.js"
echo "Configuring complete"

noroot wp plugin activate --all
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By installing WP without composer we now have "Hello Dolly" and "Akismet" installed. 😒
So I'd either replace this with

 noroot wp plugin activate advanced-custom-fields wordpress-seo yoast-acf-analysis

or add a

noroot wp plugin delete hello akismet

before this line.

cp ${VVV_PATH_TO_SITE}/provision/.env.js ${VVV_PATH_TO_SITE}/public_html/wp-content/plugins/yoast-acf-analysis/tests/js/system/.env.js
cp ${VVV_PATH_TO_SITE}/public_html/wp-content/plugins/yoast-acf-analysis/tests/js/system/nightwatch.conf.example.js ${VVV_PATH_TO_SITE}/public_html/wp-content/plugins/yoast-acf-analysis/tests/js/system/nightwatch.conf.js

sed -i "s#{{DOMAIN}}#http://${DOMAINS}#" "${VVV_PATH_TO_SITE}/public_html/wp-content/plugins/yoast-acf-analysis/tests/js/system/nightwatch.conf.js"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also automatically do

cd ${VVV_PATH_TO_SITE}/public_html/wp-content/plugins/yoast-acf-analysis
composer install
npm install

instead of adding this note. Without that the plugin won't init anyway because of the lack of the vendor folder.

if [[ ! -f "${VVV_PATH_TO_SITE}/public_html/wp-config.php" ]]; then
echo "Configuring WordPress Stable..."
noroot wp core config --dbname="${DB_NAME}" --dbuser=wp --dbpass=wp --quiet --extra-php <<PHP
define( 'WP_DEBUG', true );
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lacks

define( 'AC_YOAST_ACF_ANALYSIS_ENVIRONMENT', 'development' );

without which the testing data won't get loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants