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

Improve the build scripts #4465

Merged
merged 23 commits into from
Jan 17, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a974e15
Add some common functions to an include file
pento Jan 15, 2018
70b7a90
Add a script to instal NVM, and check and install the current node ve…
pento Jan 15, 2018
9352818
Reshuffle the setup-local-env.sh script, and add some extra checks be…
pento Jan 15, 2018
a69357e
Use the common download() function in install-wp-tests.sh
pento Jan 15, 2018
5cce301
Improve NVM and Node installation status feedback
pento Jan 15, 2018
692ee2a
Improve Docker feedback
pento Jan 15, 2018
91719b0
Run npm install after Node is updated
pento Jan 15, 2018
0ed636d
Add a message to switch Node versions after updating
pento Jan 15, 2018
74f6fd7
Check if npm install caused package-lock.json to change.
pento Jan 15, 2018
d29b64d
Use Docker to run Composer commands
pento Jan 15, 2018
ec0b412
Don't run NVM/Node updates on Travis
pento Jan 15, 2018
fe92cb9
Show the download progress of Docker containers, as it causes the int…
pento Jan 15, 2018
e044bfc
Always run `npm run build` before running the PHP unit tests.
pento Jan 15, 2018
e1f8a8a
chmod a+x
pento Jan 15, 2018
f71aaa0
Allow overriding the site port in docker-compose.override.yml
pento Jan 15, 2018
5e5791d
Update Cypress to version 1.4.1, for the plugin API
pento Jan 15, 2018
aab85e2
Add a Cypress plugin that checks what port the WordPress Docker conta…
pento Jan 15, 2018
f6c32c9
Update CONTRIBUTING.md to call out setup-local-env.sh.
pento Jan 15, 2018
10e84c1
Add a welcome message at the end of setup-local-env.sh
pento Jan 15, 2018
c653359
Improve the welcome message kerning, just for @jasmussen. 😉
pento Jan 16, 2018
9b98afd
Add a timeout parameter to the ask() function
pento Jan 16, 2018
f18b232
Clarify the NPM cache cleanup question, and add a timeout.
pento Jan 16, 2018
b64b8f2
Add action_format(), to format commands or URLs that the user should …
pento Jan 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ To test the plugin, or to contribute to it, you can clone this repository and bu
First, you need a WordPress Environment to run the plugin on. The quickest way to get up and running is to use the provided docker setup. Just install [docker](https://www.docker.com/) on your machine and run `./bin/setup-local-env.sh`.

The WordPress installation should be available at `http://localhost:8888` (username: `admin`, password: `password`).
Inside the "docker" directory, you can use any docker command to interact with your containers.
Inside the "docker" directory, you can use any docker command to interact with your containers. If this port is in use, you can override it in your `docker-compose.override.yml` file.
Copy link
Member

@ntwb ntwb Jan 15, 2018

Choose a reason for hiding this comment

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

Thanks for this Gary 💯

The Cypress baseUrl also needs to be overwritten for this to work I believe

Adding the following to your cypress.env.json file and replacing 8888 with the same port number used in your docker-compose.override.yml file should do the trick (I didn't get this far in my local attempts to get an alternate port working):

{
  "CYPRESS_BASE_URL": "http://localhost:8888"
}

See https://docs.cypress.io/guides/guides/environment-variables.html#Overriding-Configuration

Copy link
Member Author

Choose a reason for hiding this comment

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

I was just writing the docs for this. 🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

So, it turns out that baseUrl can't be overridden from cypress.env.json. Also, it seems that file is probably going to be deprecated at some point. Working on an automated way of doing it.

Copy link
Member

Choose a reason for hiding this comment

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

Just noting that package.json file has config field available:
https://docs.npmjs.com/files/package.json#config

I think Cypress is able to consume it. Let me find the related doc.

Copy link
Member

Choose a reason for hiding this comment

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

It might be possible to set it up using Cypress.config():

https://docs.cypress.io/guides/references/configuration.html#Environment-Variables

Copy link
Member Author

Choose a reason for hiding this comment

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

I mean, I could do that. Or I could write a silly little Cypress plugin. 😉


Alternatively, you can use your own local WordPress environment and clone this repository right into your `wp-content/plugins` directory.

Expand Down
18 changes: 12 additions & 6 deletions bin/install-docker.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash
NVM_VERSION="v0.33.8"

# Exit if any command fails
set -e
Expand Down Expand Up @@ -28,17 +27,25 @@ if ! docker-compose up -d; then
docker-compose up -d
fi

HOST_PORT=$(docker inspect --format '{{(index (index .HostConfig.PortBindings "80/tcp") 0).HostPort}}' wordpress-dev)

# Wait until the docker containers are setup properely
echo -en $(status_message "Attempting to connect to wordpress...")
until $(curl -L http://localhost:8888 -so - 2>&1 | grep -q "WordPress"); do
until $(curl -L http://localhost:$HOST_PORT -so - 2>&1 | grep -q "WordPress"); do
echo -n '.'
sleep 5
done
echo ' done!'

# Install WordPress
echo -en $(status_message "Installing WordPress...")
docker run -it --rm --volumes-from wordpress-dev --network container:wordpress-dev wordpress:cli core install --url=localhost:8888 --title=Gutenberg --admin_user=admin --admin_password=password --admin_email=test@test.com >/dev/null
docker run -it --rm --volumes-from wordpress-dev --network container:wordpress-dev wordpress:cli core install --url=localhost:$HOST_PORT --title=Gutenberg --admin_user=admin --admin_password=password --admin_email=test@test.com >/dev/null

CURRENT_URL=$(docker run -it --rm --volumes-from wordpress-dev --network container:wordpress-dev wordpress:cli option get siteurl)
if [ "$CURRENT_URL" != "http://localhost:$HOST_PORT" ]; then
docker run -it --rm --volumes-from wordpress-dev --network container:wordpress-dev wordpress:cli option update home "http://localhost:$HOST_PORT"
docker run -it --rm --volumes-from wordpress-dev --network container:wordpress-dev wordpress:cli option update siteurl "http://localhost:$HOST_PORT"
fi
echo ' done!'

# Activate Gutenberg
Expand All @@ -52,6 +59,5 @@ docker-compose run --rm wordpress_phpunit /app/bin/install-wp-tests.sh wordpress
echo ' done!'

# Install Composer
echo -en $(status_message "Installing Composer...")
docker-compose run --rm composer install >/dev/null
echo ' done!'
echo -e $(status_message "Installing and updating Composer modules...")
docker-compose run --rm composer install