Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress CI in Gitlab

Is there any reference of Implementing WorPress (WP_UnitTestCase) using Gitlab CI?

I have already tried configuring the .gitlab-ci.yml, it implements the build, but no test are runned.

This is the .gitlab-ci.yml file:

image: php:5.6

variables:
  # Configure mysql service (https://hub.docker.com/_/mysql/)
  MYSQL_DATABASE: wordpress_tests
  MYSQL_ROOT_PASSWORD: mysql

before_script:
  # Install dependencies
  - bash ci/docker_install.sh wordpress_tests root mysql tutum-wordpress latest

stages:
  - test

# test:PHP5.3:MySQL:
#   image: tetraweb/php:5.3
#   script:
#   - phpunit --configuration phpunit.xml.dist

test:PHP5.4:MySQL:
  image: tetraweb/php:5.4
  services:
  - tutum/wordpress:latest
  script:
  - phpunit --configuration phpunit.xml.dist

# test:PHP5.6:MySQL:
#   image: php:5.6
#   script:
#   - phpunit --configuration phpunit.xml.dist

# test:PHP7:MySQL:
#   image: php:7
#   script:
#   - phpunit --configuration phpunit.xml.dist
like image 615
StevenV Avatar asked Jan 06 '23 20:01

StevenV


2 Answers

After a lot of trial and error I got it working for me, you can see the tests for PHP5.3 through PHP7.0 are running properly for a test plugin I created here

This is how my .gitlab-ci.yml looks like. and the shell script to setup the environment is here

To use this in your project,just copy the .gitlab-ci.yml, bin/install_gitlab_tests.sh to your project.

like image 108
Nikhil Chavan Avatar answered Jan 13 '23 11:01

Nikhil Chavan


I had a similar issue. Looks like it was a wordpress compatibility problem with phpunit 6.0. Fixed by downgranding phpunit to 5.6. See: https://github.com/wp-cli/wp-cli/issues/3802

like image 36
Daniel Hernandes Avatar answered Jan 13 '23 12:01

Daniel Hernandes