Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
378 changes: 74 additions & 304 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,306 +1,76 @@
variables:
# Configure mysql service (https://hub.docker.com/_/mysql/)
MYSQL_DATABASE: wordpress_tests
MYSQL_ROOT_PASSWORD: mysql

stages:
- verify
- test
- release

PHPCS:
stage: verify
image: wpunit/php:wpcs
script:
- phpcs

Coverage:
stage: test
image: wpunit/php:7.3-extended
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql latest true
- XDEBUG_MODE=coverage phpunit --coverage-text --colors=never --configuration phpunit.xml.dist
coverage: /^\s*Lines:\s*\d+.\d+\%/

WP-Latest:PHP8.0:
stage: test
image: wpunit/php:8.0
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql latest true
- phpunit --configuration phpunit.xml.dist
allow_failure: true

WP-Latest:PHP7.4:
stage: test
image: wpunit/php:7.4
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql latest true
- phpunit --configuration phpunit.xml.dist

WP-Latest:PHP7.3:
stage: test
image: wpunit/php:7.3
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql latest true
- phpunit --configuration phpunit.xml.dist

WP-Latest:PHP5.6:
stage: test
image: wpunit/php:5.6
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql latest true
- phpunit --configuration phpunit.xml.dist

WP-Nightly:PHP8.0:
stage: test
image: wpunit/php:8.0
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql nightly true
- phpunit --configuration phpunit.xml.dist
allow_failure: true

WP-Nightly:PHP7.4:
stage: test
image: wpunit/php:7.4
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql nightly true
- phpunit --configuration phpunit.xml.dist
allow_failure: true

WP-Nightly:PHP7.3:
stage: test
image: wpunit/php:7.3
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql nightly true
- phpunit --configuration phpunit.xml.dist
allow_failure: true

WP-Nightly:PHP5.6:
stage: test
image: wpunit/php:5.6
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql nightly true
- phpunit --configuration phpunit.xml.dist
allow_failure: true

WP5.4:PHP7.4:
stage: test
image: wpunit/php:7.4
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql 5.4 true
- phpunit --configuration phpunit.xml.dist

WP5.3:PHP7.4:
stage: test
image: wpunit/php:7.4
variables:
PHPUNIT_VERSION: 5
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql 5.3 true
- phpunit --configuration phpunit.xml.dist

WP5.2:PHP7.4:
stage: test
image: wpunit/php:7.4
variables:
PHPUNIT_VERSION: 5
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql 5.2 true
- phpunit --configuration phpunit.xml.dist
- verify
- test
- deploy

WP5.1:PHP7.2:
stage: test
image: wpunit/php:7.2
variables:
PHPUNIT_VERSION: 5
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql 5.1 true
- phpunit --configuration phpunit.xml.dist

WP5.0:PHP7.2:
stage: test
image: wpunit/php:7.2
variables:
PHPUNIT_VERSION: 5
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql 5.0 true
- phpunit --configuration phpunit.xml.dist

WP4.9:PHP7.2:
stage: test
image: wpunit/php:7.2
variables:
PHPUNIT_VERSION: 5
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql 4.9 true
- phpunit --configuration phpunit.xml.dist

WP4.8:PHP7.2:
stage: test
image: wpunit/php:7.2
variables:
PHPUNIT_VERSION: 5
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql 4.8 true
- phpunit --configuration phpunit.xml.dist

WP4.7:PHP7.2:
stage: test
image: wpunit/php:7.2
variables:
PHPUNIT_VERSION: 5
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql 4.7 true
- phpunit --configuration phpunit.xml.dist

WP4.6:PHP5.6:
stage: test
image: wpunit/php:5.6
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql 4.6 true
- phpunit --configuration phpunit.xml.dist

WP4.5:PHP5.6:
stage: test
image: wpunit/php:5.6
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql 4.5 true
- phpunit --configuration phpunit.xml.dist

WP4.4:PHP5.6:
stage: test
image: wpunit/php:5.6
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql 4.4 true
- phpunit --configuration phpunit.xml.dist

WP4.3:PHP5.6:
stage: test
image: wpunit/php:5.6
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql 4.3 true
- phpunit --configuration phpunit.xml.dist

WP4.2:PHP5.6:
stage: test
image: wpunit/php:5.6
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql 4.2 true
- phpunit --configuration phpunit.xml.dist

WP4.1:PHP5.6:
stage: test
image: wpunit/php:5.6
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql 4.1 true
- phpunit --configuration phpunit.xml.dist

WP4.0:PHP5.6:
stage: test
image: wpunit/php:5.6
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql 4.0 true
- phpunit --configuration phpunit.xml.dist

WP3.9:PHP5.6:
stage: test
image: wpunit/php:5.6
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql 3.9 true
- phpunit --configuration phpunit.xml.dist

WP3.8:PHP5.6:
stage: test
image: wpunit/php:5.6
services:
- mysql:5.6
script:
# Set up WordPress tests
- bash bin/install-wp-tests.sh wordpress_tests root mysql mysql 3.8 true
- phpunit --configuration phpunit.xml.dist

Release:
stage: release
environment:
name: Release
image: wpunit/php:svn-release
when: manual
script:
- bash bin/gitlab-deploy.sh
only:
- tags
variables:
# Configure mysql service
MYSQL_DATABASE: wordpress_test
MYSQL_ROOT_PASSWORD: root
# Cache vars
npm_config_cache: "$CI_PROJECT_DIR/.npm"

cache:
key: "${CI_JOB_NAME}-${WP_VERSION}"
paths:
- vendor/
- .npm/
# Persist WordPress downloads to speed up builds
- /tmp/wordpress
- /tmp/wordpress-tests-lib

# Job 1: Standards
standards:
stage: verify
image: wpunit/php:7.4
script:
- composer install --prefer-dist --no-progress
- vendor/bin/phpcs

# Job 2: Tests (Matrix)
tests:
stage: test
image: wpunit/php:${PHP_VERSION}
services:
- name: mysql:5.7
alias: mysql
parallel:
matrix:
- PHP_VERSION: ['5.6', '7.4', '8.0']
WP_VERSION: ['latest', 'nightly']
script:
# Install system dependencies
# We use || true for apt-get update to avoid failing on EOL distros if the image is old
# but we try to install necessary packages.
- apt-get update || true
- apt-get install -y git subversion mysql-client zip unzip || true

# Install dependencies
- composer install --prefer-dist --no-progress

# Handle PHPUnit version for newer PHP versions
- |
if [[ "$PHP_VERSION" == "7.4" ]] || [[ "$PHP_VERSION" == "8.0" ]]; then
echo "Upgrading PHPUnit for PHP $PHP_VERSION..."
composer remove phpunit/phpunit --dev --no-update
composer config --unset platform.php
composer require phpunit/phpunit:"^9.0" --dev --update-with-dependencies --ignore-platform-reqs
fi

# Setup WordPress Test Suite
# Arguments: db-name db-user db-pass db-host wp-version skip-db-create
- bash bin/install-wp-tests.sh wordpress_test root root mysql $WP_VERSION

# Run tests
- vendor/bin/phpunit

# Job 3: Deploy
deploy:
stage: deploy
image: alpine:latest
only:
- tags
before_script:
- apk add --no-cache bash git svn rsync findutils
script:
- bash bin/gitlab-deploy.sh
Loading