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

Try/new workflow #36

Draft
wants to merge 32 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
abfcb62
Start some files polish
overclokk Jul 11, 2023
1a90d48
CS:FIX with PSR12
overclokk Jul 11, 2023
c7ca74c
PSR-12 and Docker stuff
overclokk Jul 13, 2023
56eac6d
CS:FIX
overclokk Jul 14, 2023
3a14cbd
Add workflow
overclokk Jul 16, 2023
379a480
Update files
overclokk Jul 16, 2023
1eb846c
Add integration files in _support
overclokk Jul 16, 2023
824a727
CS:FIX
overclokk Jul 16, 2023
f8e5384
Add some fixtures files
overclokk Jul 16, 2023
8dbbf0f
Fix already defined constant
overclokk Jul 16, 2023
1ad07de
Fix wpunit to integration name
overclokk Jul 16, 2023
ba16d78
Update .env file
overclokk Jul 16, 2023
45c9bbf
Update .env file
overclokk Jul 16, 2023
6b67b6f
Update .env file
overclokk Jul 16, 2023
bb67f91
Update WP vesion to fixed 6.0
overclokk Jul 16, 2023
ea34b58
Try acceptance
overclokk Jul 16, 2023
96ae5bb
Try test
overclokk Jul 16, 2023
4ad1ef4
Try test
overclokk Jul 16, 2023
9301f4b
Try not to replace url in DB
overclokk Jul 16, 2023
346c708
Update functional test
overclokk Jul 16, 2023
9f44bd6
Bash files
overclokk Jul 18, 2023
1de7a6e
Update Debug package
overclokk Aug 20, 2023
dabb86d
Try new Empress version
overclokk Aug 20, 2023
015ef01
Experiment a little bit with ProvidersCollection
overclokk Aug 20, 2023
81d1954
move to new injector and event way
overclokk Sep 23, 2023
53ddf0f
start restructure folders
overclokk Sep 23, 2023
b7b7756
Restructure all files and dirs
overclokk Sep 26, 2023
dfa4de9
try new events
overclokk Sep 27, 2023
08fb1ea
CS:fix
overclokk Sep 27, 2023
dddf4d8
Restructure UI of the theme
overclokk Oct 1, 2023
27a0c3f
Restructure tests and try Patterns
overclokk Oct 8, 2023
2107101
Try new version of Empress and new version of Event
overclokk Oct 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
47 changes: 17 additions & 30 deletions .docker/.env
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
COMPOSE_PROJECT_NAME=italystrap
PROJECT_NAME=italystrap
PHP_VERSION=7.4
WP_VERSION=6.0
WP_PORT_TEST=8888
DB_PORT_TEST=8889
PMA_PORT_TEST=8890
# Docker only
PROJECT_NAME="italystrap"
PHP_VERSION="7.4"
WP_VERSION="6.0"

DB_HOST=mysql
DB_NAME=test
DB_USER=root
DB_PASSWORD=root
TABLE_PREFIX=wp_
WP_PORT=8888
DB_PORT=8889
PMA_PORT=8890

TEST_SITE_DB_DSN=mysql:host=localhost;dbname=test
WP_ROOT_FOLDER="/tmp/wordpress"
TEST_SITE_WP_ADMIN_PATH="/wp-admin"
TEST_SITE_DB_NAME="test"
TEST_SITE_DB_HOST="localhost"
TEST_SITE_DB_USER="root"
TEST_SITE_DB_PASSWORD="root"
TEST_SITE_TABLE_PREFIX="wp_"
TEST_DB_NAME="test"
TEST_DB_HOST="localhost"
TEST_DB_USER="root"
TEST_DB_PASSWORD="root"
TEST_TABLE_PREFIX="wp_"
TEST_SITE_WP_URL="http://wp.localhost"
TEST_SITE_WP_DOMAIN="wp.localhost"
TEST_SITE_ADMIN_EMAIL="[email protected]"
TEST_SITE_ADMIN_USERNAME="admin"
TEST_SITE_ADMIN_PASSWORD="password"
# Docker and Codeception
DB_NAME="test"
DB_HOST="mysql"
DB_USER="root"
DB_PASSWORD="root"

# Functional tests
APP_URL=http://localhost
ADMIN_USERNAME=root
ADMIN_PASSWORD=root
5 changes: 4 additions & 1 deletion .docker/codecept
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env bash

docker exec -w //var/www/html/wp-content/themes/italystrap italystrap_test sh -c "vendor/bin/codecept ${*}"
# Get project name from .env file
PROJECT_NAME=$(grep PROJECT_NAME .env | cut -d '=' -f2 | tr -d '"')

docker exec -w /var/www/html/wp-content/themes/"${PROJECT_NAME}" "${PROJECT_NAME}"_test sh -c "vendor/bin/codecept ${*}"
5 changes: 4 additions & 1 deletion .docker/composer
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env bash

docker-compose run -w //var/www/html/wp-content/themes/italystrap --rm wordpress sh -c "composer ${*}"
# Get project name from .env file
PROJECT_NAME=$(grep PROJECT_NAME .env | cut -d '=' -f2 | tr -d '"')

docker-compose run -w /var/www/html/wp-content/themes/"${PROJECT_NAME}" --rm wordpress sh -c "composer ${*}"
40 changes: 11 additions & 29 deletions .docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
container_name: ${PROJECT_NAME:-wordpress}_test
restart: always
ports:
- ${WP_PORT_TEST}:80
- ${WP_PORT}:80
environment:
WORDPRESS_DB_HOST: ${DB_HOST:-mysql}
WORDPRESS_DB_NAME: ${DB_NAME:-test}
Expand All @@ -20,46 +20,28 @@ services:
WORDPRESS_DEBUG: 1
volumes:
- ../:/var/www/html/wp-content/themes/${PROJECT_NAME:-wordpress}
- ../tests/_output/:/var/www/html/wp-content/themes/${PROJECT_NAME:-wordpress}/tests/_output/
- ./codeception.yml:/var/www/html/wp-content/themes/${PROJECT_NAME:-wordpress}/codeception.yml
#- ./mu-plugins/:/var/www/html/wp-content/mu-plugins/
depends_on:
- mysql
networks:
wpbrowser:
# aliases:
# - wp

# https://mklasen.com/adding-and-using-wp-cli-in-a-docker-compose-setup/
# wpcli:
# container_name: ${PROJECT_NAME:-wp-cli}-cli_test
# depends_on:
# - wordpress
# image: wordpress:cli
## user: 1000:1000
# command: tail -f /dev/null
# volumes:
# - wordpress:/var/www/html
# environment:
# WORDPRESS_DB_HOST: ${NAME}-db:3306
# WORDPRESS_DB_USER: ${DB_USER}
# WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
# WORDPRESS_DB_NAME: ${DB_NAME}
# profiles:
# - dev
integration_test_networks:

mysql:
image: mysql:${DB_VERSION:-5.7}
container_name: ${PROJECT_NAME:-wordpress}_mysql_test
restart: always
ports:
- ${DB_PORT_TEST}:3306
- ${DB_PORT}:3306
environment:
MYSQL_DATABASE: ${DB_NAME:-test}
#MYSQL_USER: ${TEST_SITE_DB_USER:-root}
#MYSQL_USER: ${DB_USER:-root}
MYSQL_PASSWORD: ${DB_PASSWORD:-root}
#MYSQL_RANDOM_ROOT_PASSWORD: '1'
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-root}
networks:
- wpbrowser
- integration_test_networks

phpmyadmin:
depends_on:
Expand All @@ -68,14 +50,14 @@ services:
container_name: ${PROJECT_NAME}_phpmyadmin_test
restart: always
ports:
- ${PMA_PORT_TEST}:80
- ${PMA_PORT}:80
environment:
# For max upload from PHPMYADMIN https://github.com/10up/wp-local-docker-v2/issues/40#issuecomment-719915040
UPLOAD_LIMIT: 1G
PMA_HOST: ${DB_HOST:-mysql}
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-root}
networks:
- wpbrowser
- integration_test_networks

chromedriver:
image: selenium/standalone-chrome:4.6.0-20221104
Expand All @@ -85,8 +67,8 @@ services:
- "4444:4444"
- "7900:7900"
networks:
- wpbrowser
- integration_test_networks

networks:
wpbrowser:
integration_test_networks:
driver: bridge
5 changes: 4 additions & 1 deletion .docker/ssh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env bash

docker exec -it -w //var/www/html/wp-content/themes/italystrap italystrap_test sh
# Get project name from .env file
PROJECT_NAME=$(grep PROJECT_NAME .env | cut -d '=' -f2 | tr -d '"')

docker exec -it -w //var/www/html/wp-content/themes/"${PROJECT_NAME}" "${PROJECT_NAME}"_test sh
17 changes: 17 additions & 0 deletions .docker/wordpress/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,30 @@ ARG WP_VERSION

FROM wordpress:${WP_VERSION}-php${PHP_VERSION}

# Install pcov for code coverage
RUN set -eux; \
pecl install pcov; \
docker-php-ext-enable pcov

# If you want to use xdebug, uncomment the following lines
# Install xdebug for code coverage
#RUN set -eux; \
# pecl install xdebug-3.1.4; \
# docker-php-ext-enable xdebug

# Set XDEBUG_MODE=coverage or xdebug.mode=coverage
#ENV XDEBUG_MODE=coverage

RUN set -eux; \
apt-get update && apt-get install -y \
git \
nano \
less # Needed for the WP-CLI \
rm -rf /var/lib/apt/lists/*

# Git add safe directory for the working directory


# Needed for Db driver
# https://github.com/Codeception/Codeception/issues/3605
RUN docker-php-ext-install \
Expand Down
3 changes: 0 additions & 3 deletions .docker/wp

This file was deleted.

46 changes: 13 additions & 33 deletions .env
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
TEST=test
COMPOSE_PROJECT_NAME=italystrap
PROJECT_NAME=italystrap
FOLDER_NAME=italystrap
PHP_VERSION=7.4
MATRIX_PHP_VERSION=80
WP_VERSION=6.0
WP_PORT_TEST=8888
DB_PORT_TEST=8889
Expand All @@ -19,63 +21,41 @@ TABLE_PREFIX=wp_

TESTS_DIR=tests/php

#WP_ROOT_FOLDER="../../../"
WP_ROOT_FOLDER="/var/www/html"
WP_ROOT_FOLDER="../../../"

# WPUnit Suite config
WPUNIT_ROOT_FOLDER="../../../"
#WPUNIT_ROOT_FOLDER="/var/www/html"

WPUNIT_DB_NAME=test
WPUNIT_DB_HOST=mysql
WPUNIT_DB_HOST=localhost
WPUNIT_DB_USER=root
WPUNIT_DB_PASSWORD=root
WPUNIT_TABLE_PREFIX=wp_
WPUNIT_SITE_WP_DOMAIN=localhost.local
[email protected]

# Functional and Acceptance Unit Suite config for WPDB driver
WPDB_DB_DSN=mysql:host=mysql;dbname=test
WPDB_DB_DSN=mysql:host=localhost;dbname=test
WPDB_DB_USER=root
WPDB_DB_PASSWORD=root
# This is the url inside the container
WPDB_WP_URL=http://localhost
WPDB_WP_DOMAIN=localhost
WPDB_WP_URL=http://localhost:8888
#WPDB_WP_DOMAIN=localhost:8888
WPDB_TABLE_PREFIX=wp_
WPDB_DUMP_FILE="tests/_data/dump.sql"

# Functional and Acceptance Unit Suite config for WPBrowser driver
# This is the url inside the container
WPBROWSER_WP_URL=http://localhost
#WPBROWSER_ADMIN_USERNAME=root
#WPBROWSER_ADMIN_PASSWORD=root
WPBROWSER_ADMIN_USERNAME=admin
WPBROWSER_ADMIN_PASSWORD=password
WPBROWSER_WP_URL=http://localhost:8888
WPBROWSER_ADMIN_USERNAME=root
WPBROWSER_ADMIN_PASSWORD=root
WPBROWSER_WP_ADMIN_PATH=/wp-admin

# Used only for acceptance.suite.yml tests inside WPWebDriver configuration.
# The value must be the name of the WordPress container
# for resolving the correct IP of the machine if you use Docker as environment.
# This will be also used for replace the hardcoded dump URL with the one below
CHROMEDRIVER_WP_URL="http://italystrap_test"
CHROMEDRIVER_WP_URL="http://localhost:8888"
# This must be the name of the Selenium container
CHROMEDRIVER_HOST=chromedriver
CHROMEDRIVER_HOST=localhost
CHROMEDRIVER_PORT="4444"

#TEST_SITE_DB_DSN=mysql:host=localhost;dbname=test
#WP_ROOT_FOLDER="/tmp/wordpress"
#TEST_SITE_WP_ADMIN_PATH="/wp-admin"
#TEST_SITE_DB_NAME="test"
#TEST_SITE_DB_HOST="localhost"
#TEST_SITE_DB_USER="root"
#TEST_SITE_DB_PASSWORD="root"
#TEST_SITE_TABLE_PREFIX="wp_"
#TEST_DB_NAME="test"
#TEST_DB_HOST="localhost"
#TEST_DB_USER="root"
#TEST_DB_PASSWORD="root"
#TEST_TABLE_PREFIX="wp_"
#TEST_SITE_WP_URL="http://wp.localhost"
#TEST_SITE_WP_DOMAIN="wp.localhost"
#TEST_SITE_ADMIN_EMAIL="[email protected]"
#TEST_SITE_ADMIN_USERNAME="admin"
#TEST_SITE_ADMIN_PASSWORD="password"
106 changes: 106 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: CI

env:
REPOSITORY_NAME: italystrap
PROJECT_KIND: themes
DB_HOST: localhost
DB_NAME: test
DB_USER: root
DB_PASSWORD: root
TABLE_PREFIX: wp_
APP_FOLDER_PATH: /tmp/app
APP_PORT: 8888
APP_HOST: localhost
APP_USER: root
APP_PASSWORD: root

on:
push:
branches:
- master
pull_request:

workflow_dispatch:

jobs:

tests:
name: 🐘 Tests on PHP ${{matrix.php_versions}} & APP version ${{matrix.app_versions}}

strategy:
matrix:
php_versions: ['8']
app_versions: ['6.0']

runs-on: ubuntu-latest
continue-on-error: ${{ matrix.php_versions == '8.2' }}
if: "!contains(github.event.head_commit.message, '--skip ci') && !github.event.pull_request.draft"

steps:
- uses: actions/checkout@v3

- name: Start Selenium for using later
run: docker run -d --net=host --shm-size=2g selenium/standalone-chrome:4.6.0-20221104

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{matrix.php_versions}}

- name: Start MySQL
run: |
sudo systemctl start mysql.service
mysql -e "CREATE DATABASE IF NOT EXISTS ${{env.DB_NAME}};" -u${{env.DB_USER}} -p${{env.DB_PASSWORD}}

- name: Install CLI
run: |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
wp cli info

- name: Create folder for running the App
run: mkdir -p ${{env.APP_FOLDER_PATH}}

- name: Install App
working-directory: ${{env.APP_FOLDER_PATH}}
run: |
wp core download --version="${{matrix.app_versions}}"
wp config create --dbname="${{env.DB_NAME}}" --dbuser="${{env.DB_USER}}" --dbpass="${{env.DB_PASSWORD}}" --dbhost="${{env.DB_HOST}}" --dbprefix="${{env.TABLE_PREFIX}}"
wp core install --url="${{env.APP_HOST}}:${{env.APP_PORT}}" --title="Test" --admin_user="${{env.APP_USER}}" --admin_password="${{env.APP_PASSWORD}}" --admin_email="${{env.APP_USER}}@${{env.APP_HOST}}.test" --skip-email
wp core update-db
cp -r $GITHUB_WORKSPACE ${{env.APP_FOLDER_PATH}}/wp-content/${{env.PROJECT_KIND}}/${{env.REPOSITORY_NAME}}

- uses: "ramsey/composer-install@v2"
with:
working-directory: "${{env.APP_FOLDER_PATH}}/wp-content/${{env.PROJECT_KIND}}/${{env.REPOSITORY_NAME}}"

- name: Activate ${{env.REPOSITORY_NAME}}
working-directory: ${{env.APP_FOLDER_PATH}}
run: |
wp plugin deactivate --all
wp site empty --yes
wp theme activate ${{env.REPOSITORY_NAME}}
wp theme list --status=active
chmod -R 777 wp-content/${{env.PROJECT_KIND}}/${{env.REPOSITORY_NAME}}
ls -la wp-content/${{env.PROJECT_KIND}}/${{env.REPOSITORY_NAME}}
wp db export wp-content/${{env.PROJECT_KIND}}/${{env.REPOSITORY_NAME}}/tests/_data/dump.sql

- name: Build codeception
working-directory: ${{env.APP_FOLDER_PATH}}/wp-content/${{env.PROJECT_KIND}}/${{env.REPOSITORY_NAME}}
run: ./vendor/bin/codecept build

- name: Run Unit & Integration test
working-directory: ${{env.APP_FOLDER_PATH}}/wp-content/${{env.PROJECT_KIND}}/${{env.REPOSITORY_NAME}}
run: |
./vendor/bin/codecept run unit
./vendor/bin/codecept run integration

- name: Start dev server
run: php -S ${{env.APP_HOST}}:${{env.APP_PORT}} -t ${{env.APP_FOLDER_PATH}} >/dev/null 2>&1 &

- name: Run Functional and Acceptance test
working-directory: ${{env.APP_FOLDER_PATH}}/wp-content/${{env.PROJECT_KIND}}/${{env.REPOSITORY_NAME}}
run: |
./vendor/bin/codecept run functional --debug
./vendor/bin/codecept run acceptance --debug
Loading