2017 © Pedro Peláez
 

library travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

image

typisttech/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  • Tuesday, February 6, 2018
  • by TangRufus
  • Repository
  • 2 Watchers
  • 3 Stars
  • 33,612 Installations
  • Shell
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 18 Versions
  • 12 % Grown

The README.md

Travis CI Nginx WordPress Test

Latest Stable Version Total Downloads Build Status PHP Versions Tested License Hire Typist Tech, (*1)

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure., (*2)

, (*3)

What is the purpose of this repo?

Do you need to run some automated tests that rely on Nginx on Travis CI? Do you want those tests to run on the Docker container-based infrastructure? Are you pulling your hair out trying to get this all to work? Then this repo is for you., (*4)

Travis CI does not come with Nginx pre-installed so the install needs to be scripted. Since Travis CI's container-based infrastructure doesn't allow sudo privileges this installation is non-trivial. Hopefully, by providing this repo I can save someone some hassle trying to get Nginx set up for their project., (*5)

Installation and Usage

The script is tailored on Travis CI PHP build images and might not work in every situation. Below is an basic example of .travis.yml:, (*6)


# .travis.yml language: php services: - mysql cache: apt: true directories: - $HOME/.composer/cache/files addons: apt: packages: - nginx hosts: - wp.dev php: - 7.1 - 7.2 - nightly env: global: - COMPOSER_NO_INTERACTION=1 matrix: - WP_VERSION=nightly - WP_VERSION=latest - WP_VERSION=4.9.3 - WP_VERSION=4.8.5 before_install: # Install helper scripts - composer global require --prefer-dist "typisttech/travis-nginx-wordpress:^1.0.0" - export PATH=$HOME/.composer/vendor/bin:$PATH - tnw-install-nginx - tnw-install-wordpress - tnw-prepare-codeception install: # Build the test suites - cd $TRAVIS_BUILD_DIR - composer install -n --prefer-dist - vendor/bin/codecept build -n script: # Run the tests - cd $TRAVIS_BUILD_DIR - vendor/bin/codecept run -n --coverage --coverage-xml after_script: - tnw-upload-coverage-to-scrutinizer - tnw-upload-coverage-to-codecov

And, this is an basic example of codeception.dist.yml which compatible with the above Travis settings:, (*7)


# codeception.dist.yml actor: Tester paths: tests: tests log: tests/_output data: tests/_data helpers: tests/_support settings: bootstrap: _bootstrap.php colors: true memory_limit: 1024M coverage: enabled: true include: - src/my-plugin/* exclude: - src/my-plugin/partials/* params: [env] # get parameters from environment vars modules: config: WPDb: dsn: 'mysql:host=localhost;dbname=wordpress' user: 'root' password: '' dump: 'tests/_data/dump.sql' url: 'http://wp.dev:8080' WPBrowser: url: 'http://wp.dev:8080' adminUsername: 'admin' adminPassword: 'password' adminPath: '/wp-admin' WordPress: depends: WPDb wpRootFolder: '/tmp/wordpress' adminUsername: 'admin' adminPassword: 'password' WPLoader: wpRootFolder: '/tmp/wordpress' dbName: 'wordpress_int' dbHost: 'localhost' dbUser: 'root' dbPassword: '' tablePrefix: 'int_wp_' domain: 'wordpress.dev' adminEmail: 'admin@wordpress.dev' WPWebDriver: url: 'http://wp.dev:8080' port: 4444 window_size: '1024x768' adminUsername: 'admin' adminPassword: 'password' adminPath: '/wp-admin'

Customization

The default scripts install WordPress core on /tmp/wordpress and serve it at http://wp.dev:8080., (*8)

You can customize the build via environment variables. Check the variables of the functions in the bin director for available configuration., (*9)

How does it works?

All of the setup scripts are located in the bin directory and template files are in the tpl directory. They are short and basic so it should be relatively easy to follow. The repository defines 6 setup scripts:, (*10)

  1. tnw-install-wordpress
    • Install WordPress
  2. tnw-install-nginx
    • Setup Nginx to serve a website from a folder on a local domain
  3. tnw-prepare-codeception
  4. tnw-upload-coverage-to-codecov
  5. tnw-upload-coverage-to-scrutinizer

WordPress

The WordPress installation is done through the tnw-install-wordpress bash script. The basic install process goes as follows:, (*11)

  1. Create the WordPress database.
  2. Download WordPress core.
  3. Generate the wp-config.php file.
    • Note that define( 'AUTOMATIC_UPDATER_DISABLED', true ); is added.
  4. Install the WordPress database.

Nginx

The Nginx installation is done through the tnw-install-nginx bash script. The basic install process goes as follows:, (*12)

  1. Install Nginx using the apt addon via entries in the .travis.yml file.
  2. Copy the configuration templates to a new directory while replacing placeholders with environment variables.
  3. Start php-fpm and Nginx with our custom configuration file instead of the default.

Codeception

The Codeception preparation is done through the tnw-prepare-codeception bash script. The basic install process goes as follows:, (*13)

  1. Replace phantomjs path to the TravisCI one in codeception.yml and codeception.dist.yml.
  2. Create an extra database for testing.
  3. Import database dump to WordPress.
  4. Upgrade the WordPress database.
  5. Export the WordPress database dump for later use.

Note: The phantomjs path must be wrapped in single quotes., (*14)

extensions:
  enabled:
    - Codeception\Extension\Phantoman
  config:
    Codeception\Extension\Phantoman:
      path: '/usr/bin/phantomjs'
      port: 4444
      suites: ['acceptance']

Codecov.io

The Codecov.io test coverage uploading is done through the tnw-upload-coverage-to-codecov bash script. The basic install process goes as follows:, (*15)

  1. Run the codecov-bash script.

Scrutinizer CI

The Scrutinizer CI test coverage uploading is done through the tnw-upload-coverage-to-scrutinizer bash script. The basic install process goes as follows:, (*16)

  1. Download ocular.
  2. Upload the test coverage file to Scrutinizer CI.

Known Issues

  • Nginx gives alert messages during start which is safe to ignore., (*17)

    $ install-nginx
    [26-Dec-2046 00:00:00] NOTICE: [pool travis] 'user' directive is ignored when FPM is not running as root
    nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
    

See Also

Real life examples that use this package

Here you go:, (*18)

Add your own here, (*19)

Support!

Love Travis CI Nginx WordPress Test? Help me maintain Travis CI Nginx WordPress Test, a donation here can help with it., (*20)

Why don't you hire me?

Ready to take freelance WordPress jobs. Contact me via the contact form here or, via email info@typist.tech, (*21)

Want to help in other way? Want to be a sponsor?

Contact: Tang Rufus, (*22)

Change Log

See CHANGELOG.md., (*23)

Credit

Travis CI Nginx WordPress Test is originally forked from the Travis CI Nginx Test project. Special thanks to its author Todd Burry., (*24)

License

Travis CI Nginx WordPress Test is released under the MIT License., (*25)

The Versions

06/02 2018

dev-master

9999999-dev https://www.typist.tech/projects/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  Sources   Download

MIT

The Requires

 

wordpress phpcs codeception nginx travis acceptance test wpcs wp browser

06/02 2018

3.0.0

3.0.0.0 https://www.typist.tech/projects/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  Sources   Download

MIT

The Requires

 

wordpress phpcs codeception nginx travis acceptance test wpcs wp browser

06/02 2018

dev-version-bump

dev-version-bump https://www.typist.tech/projects/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  Sources   Download

MIT

The Requires

 

wordpress phpcs codeception nginx travis acceptance test wpcs wp browser

06/02 2018

dev-remove

dev-remove https://www.typist.tech/projects/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  Sources   Download

MIT

The Requires

 

wordpress phpcs codeception nginx travis acceptance test wpcs wp browser

06/02 2018

dev-travis

dev-travis https://www.typist.tech/projects/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  Sources   Download

MIT

The Requires

 

wordpress phpcs codeception nginx travis acceptance test wpcs wp browser

27/10 2017

dev-misc

dev-misc https://www.typist.tech/projects/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  Sources   Download

MIT

The Requires

 

wordpress phpcs codeception nginx travis acceptance test wpcs wp browser

06/08 2017

2.1.0

2.1.0.0 https://www.typist.tech/projects/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  Sources   Download

MIT

The Requires

 

wordpress phpcs codeception nginx travis acceptance test wpcs wp browser

06/08 2017

dev-composer-update

dev-composer-update https://www.typist.tech/projects/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  Sources   Download

MIT

The Requires

 

wordpress phpcs codeception nginx travis acceptance test wpcs wp browser

15/07 2017

dev-add-tnw-stop-nginx

dev-add-tnw-stop-nginx https://www.typist.tech/projects/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  Sources   Download

MIT

The Requires

 

wordpress phpcs codeception nginx travis acceptance test wpcs wp browser

01/06 2017

2.0.2

2.0.2.0 https://www.typist.tech/projects/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  Sources   Download

MIT

The Requires

 

wordpress phpcs codeception nginx travis acceptance test wpcs wp browser

01/06 2017

dev-wp-cli-1-1

dev-wp-cli-1-1 https://www.typist.tech/projects/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  Sources   Download

MIT

The Requires

 

wordpress phpcs codeception nginx travis acceptance test wpcs wp browser

26/03 2017

2.0.1

2.0.1.0 https://www.typist.tech/projects/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  Sources   Download

MIT

The Requires

 

wordpress phpcs codeception nginx travis acceptance test wpcs wp browser

09/03 2017

2.0.0

2.0.0.0 https://github.com/TypistTech/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  Sources   Download

MIT

The Requires

 

wordpress phpcs codeception nginx travis acceptance test wpcs wp browser

24/02 2017

1.2.1

1.2.1.0 https://github.com/TypistTech/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  Sources   Download

MIT

The Requires

 

wordpress phpcs codeception nginx travis acceptance test wpcs wp browser

24/02 2017

1.2.0

1.2.0.0 https://github.com/TypistTech/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  Sources   Download

MIT

The Requires

 

wordpress phpcs codeception nginx travis acceptance test wpcs wp browser

19/02 2017

1.1.1

1.1.1.0 https://github.com/TypistTech/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  Sources   Download

MIT

The Requires

 

wordpress phpcs codeception nginx travis acceptance test wpcs wp browser

18/02 2017

1.1.0

1.1.0.0 https://github.com/TypistTech/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  Sources   Download

MIT

The Requires

 

wordpress phpcs codeception nginx travis acceptance test wpcs wp browser

17/02 2017

1.0.0

1.0.0.0 https://github.com/TypistTech/travis-nginx-wordpress

A basic template for Nginx and WordPress running on Travis CI's container based infrastructure.

  Sources   Download

MIT

The Requires

 

wordpress phpcs codeception nginx travis acceptance test wpcs wp browser