Skip to content

Commit

Permalink
Testing: Speed up Docker setup on Travis for PHP tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed May 21, 2019
1 parent 54f33f9 commit 53a4ea9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
27 changes: 24 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,37 @@ branches:
only:
- master

before_install:
- nvm install --latest-npm

env: PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true

jobs:
include:
- name: Lint
before_install:
- nvm install --latest-npm
install:
- npm ci
script:
- npm run lint

- name: Build artifacts
before_install:
- nvm install --latest-npm
install:
- npm ci
script:
- npm run check-local-changes

- name: License compatibility
before_install:
- nvm install --latest-npm
install:
- npm ci
script:
- npm run check-licenses

- name: JavaScript unit tests
before_install:
- nvm install --latest-npm
install:
- npm ci
script:
Expand Down Expand Up @@ -83,6 +88,8 @@ jobs:

- name: E2E tests (Admin with plugins) (1/4)
env: WP_VERSION=latest SCRIPT_DEBUG=false POPULAR_PLUGINS=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
before_install:
- nvm install --latest-npm
install:
- npm ci
- ./bin/setup-travis-e2e-tests.sh
Expand All @@ -93,6 +100,8 @@ jobs:

- name: E2E tests (Admin with plugins) (2/4)
env: WP_VERSION=latest SCRIPT_DEBUG=false POPULAR_PLUGINS=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
before_install:
- nvm install --latest-npm
install:
- npm ci
- ./bin/setup-travis-e2e-tests.sh
Expand All @@ -103,6 +112,8 @@ jobs:

- name: E2E tests (Admin with plugins) (3/4)
env: WP_VERSION=latest SCRIPT_DEBUG=false POPULAR_PLUGINS=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
before_install:
- nvm install --latest-npm
install:
- npm ci
- ./bin/setup-travis-e2e-tests.sh
Expand All @@ -113,6 +124,8 @@ jobs:

- name: E2E tests (Admin with plugins) (4/4)
env: WP_VERSION=latest SCRIPT_DEBUG=false POPULAR_PLUGINS=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
before_install:
- nvm install --latest-npm
install:
- npm ci
- ./bin/setup-travis-e2e-tests.sh
Expand All @@ -123,6 +136,8 @@ jobs:

- name: E2E tests (Author without plugins) (1/4)
env: WP_VERSION=latest SCRIPT_DEBUG=false E2E_ROLE=author PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
before_install:
- nvm install --latest-npm
install:
- npm ci
- ./bin/setup-travis-e2e-tests.sh
Expand All @@ -133,6 +148,8 @@ jobs:

- name: E2E tests (Author without plugins) (2/4)
env: WP_VERSION=latest SCRIPT_DEBUG=false E2E_ROLE=author PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
before_install:
- nvm install --latest-npm
install:
- npm ci
- ./bin/setup-travis-e2e-tests.sh
Expand All @@ -143,6 +160,8 @@ jobs:

- name: E2E tests (Author without plugins) (3/4)
env: WP_VERSION=latest SCRIPT_DEBUG=false E2E_ROLE=author PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
before_install:
- nvm install --latest-npm
install:
- npm ci
- ./bin/setup-travis-e2e-tests.sh
Expand All @@ -153,6 +172,8 @@ jobs:

- name: E2E tests (Author without plugins) (4/4)
env: WP_VERSION=latest SCRIPT_DEBUG=false E2E_ROLE=author PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=
before_install:
- nvm install --latest-npm
install:
- npm ci
- ./bin/setup-travis-e2e-tests.sh
Expand Down
15 changes: 10 additions & 5 deletions bin/run-wp-unit-tests.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
#!/usr/bin/env bash


# Set up environment variables
. "$(dirname "$0")/bootstrap-env.sh"

# Include useful functions
. "$(dirname "$0")/includes.sh"

cd "$(dirname "$0")/../"

export PATH="$HOME/.composer/vendor/bin:$PATH"
if [[ $DOCKER = "true" ]]; then
bin/setup-local-env.sh
# Download image updates.
echo -e $(status_message "Downloading Docker image updates...")
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS pull composer mysql wordpress_phpunit

# Launch the containers.
echo -e $(status_message "Starting Docker containers...")
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS up -d composer mysql wordpress_phpunit >/dev/null

# Install the PHPUnit test scaffolding.
echo -e $(status_message "Installing PHPUnit test scaffolding...")
Expand All @@ -24,11 +32,8 @@ else
# Run the build because otherwise there will be a bunch of warnings about
# failed `stat` calls from `filemtime()`.
composer install || exit 1
npm install || exit 1
fi

npm run build || exit 1

echo Running with the following versions:
if [[ $DOCKER = "true" ]]; then
docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm wordpress_phpunit php -v
Expand Down

0 comments on commit 53a4ea9

Please sign in to comment.