diff --git a/.github/workflows/test-php.yml b/.github/workflows/test-php.yml index 0a9ed4bca..b8a7f0680 100644 --- a/.github/workflows/test-php.yml +++ b/.github/workflows/test-php.yml @@ -3,6 +3,9 @@ run-name: '[Test] ${{ github.event.head_commit.message }}' on: [push, workflow_dispatch] +env: + COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.COMPOSER_TOKEN }}"}}' + jobs: test: runs-on: ubuntu-latest @@ -19,6 +22,11 @@ jobs: - uses: actions/checkout@v4 + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php }}" + - uses: oven-sh/setup-bun@v1 with: bun-version: latest @@ -30,45 +38,11 @@ jobs: - name: Build packages run: bun run build - - name: Install composer - run: sudo composer self-update --stable + - name: Validate composer.json and composer.lock + run: composer validate - # Composer validate doesn't like our type of "wordpress-plugin" - # - name: Validate composer.json and composer.lock - # run: composer validate - - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v4 - with: - path: | - vendor - vendor-prod - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - - - name: Install composer dependencies - if: steps.composer-cache.outputs.cache-hit != 'true' - env: - COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.COMPOSER_TOKEN }}"}}' - run: | - composer config store-auths false - composer install --no-progress --no-suggest --ignore-platform-reqs - - - name: Install composer vendor-prod - if: steps.composer-cache.outputs.cache-hit != 'true' - env: - COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.COMPOSER_TOKEN }}"}}' - COMPOSER_VENDOR_DIR: vendor-prod - run: | - composer config store-auths false - composer install --prefer-dist --no-dev --no-ansi --no-interaction - composer du -a --no-dev --no-ansi --no-interaction - - - name: Generate autoloader - if: steps.composer-cache.outputs.cache-hit == 'true' - run: composer du + - name: Install Composer dependencies + uses: ramsey/composer-install@v2 - name: Setup environment run: envsubst < tests/docker-compose.codeception.env > tests/codeception.env @@ -88,8 +62,15 @@ jobs: run: | sed -i -e 's/WP_VERSION=""/WP_VERSION="nightly"/g' tests/codeception.env - - name: Setup docker - run: ./bin/setup-docker.sh + - name: Set UID and GID for docker + run: | + printf 'UID=%d\nGID=%d\n' $(id -u) $(id -g) > .env.ci + + - name: Start project containers + run: docker compose --env-file .env --env-file .env.ci up -d + + - name: Wait for project to be ready + run: ./bin/wait-for-it.sh http://localhost:7253 - name: Run tests run: | diff --git a/bin/test-up.sh b/bin/test-up.sh index 216b4f0df..9317b27f3 100755 --- a/bin/test-up.sh +++ b/bin/test-up.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash docker-compose -f docker-compose.yml up -d -docker-compose exec -T wordpress chown www-data:www-data wp-content wp-content/plugins +docker-compose exec -T wordpress chown -R www-data:www-data /var/www/html/wp-content/ diff --git a/composer.json b/composer.json index 136961e49..ce3fdec5f 100644 --- a/composer.json +++ b/composer.json @@ -1,12 +1,18 @@ { "name": "kadencewp/kadence-blocks", - "dsecription": "Kadence Blocks - Gutenberg Blocks for Page Building", + "description": "Kadence Blocks - Gutenberg Blocks for Page Building", "type": "wordpress-plugin", "homepage": "https://www.kadencewp.com", + "license": "GPL-2.0-or-later", "config": { "preferred-install": "dist", + "sort-packages": true, + "optimize-autoloader": true, "platform": { "php": "7.2.34" + }, + "allow-plugins": { + "composer/installers": true } }, "repositories": [ @@ -28,6 +34,7 @@ } ], "require": { + "composer/installers": "^2.0", "psr/container": "^1.0", "lucatume/di52": "^3.3", "stellarwp/telemetry": "^2.3", @@ -62,7 +69,7 @@ "vendor/bin/stellar-uplink domain=kadence-blocks" ], "strauss": [ - "test -f ./bin/strauss.phar || curl -o bin/strauss.phar -L -C - https://github.com/BrianHenryIE/strauss/releases/download/0.14.1/strauss.phar", + "test -f ./bin/strauss.phar || curl -o bin/strauss.phar -L -C - https://github.com/BrianHenryIE/strauss/releases/download/0.16.0/strauss.phar", "@php bin/strauss.phar", "@composer dump-autoload" ], @@ -87,13 +94,10 @@ "classmap_prefix": "Kadence_Blocks_", "constant_prefix": "KADENCE_BLOCKS_", "namespace_prefix": "KadenceWP\\KadenceBlocks\\", - "delete_vendor_packages": true, + "delete_vendor_packages": false, "exclude_from_prefix": { "file_patterns": [ "/symfony\\/polyfill-(.*)/" - ], - "packages": [ - "symfony/service-contracts" ] } } diff --git a/composer.lock b/composer.lock index 21295a0e8..9c6ea84d8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "46dc3fe8ddd36ffd5288899e5ce3bbc2", + "content-hash": "47a4074726db0b48e5e80d3d4ca819bd", "packages": [ { "name": "adbario/php-dot-notation", @@ -59,6 +59,151 @@ }, "time": "2022-10-14T20:31:46+00:00" }, + { + "name": "composer/installers", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/composer/installers.git", + "reference": "c29dc4b93137acb82734f672c37e029dfbd95b35" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/installers/zipball/c29dc4b93137acb82734f672c37e029dfbd95b35", + "reference": "c29dc4b93137acb82734f672c37e029dfbd95b35", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "composer/composer": "1.6.* || ^2.0", + "composer/semver": "^1 || ^3", + "phpstan/phpstan": "^0.12.55", + "phpstan/phpstan-phpunit": "^0.12.16", + "symfony/phpunit-bridge": "^5.3", + "symfony/process": "^5" + }, + "type": "composer-plugin", + "extra": { + "class": "Composer\\Installers\\Plugin", + "branch-alias": { + "dev-main": "2.x-dev" + }, + "plugin-modifies-install-path": true + }, + "autoload": { + "psr-4": { + "Composer\\Installers\\": "src/Composer/Installers" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kyle Robinson Young", + "email": "kyle@dontkry.com", + "homepage": "https://github.com/shama" + } + ], + "description": "A multi-framework Composer library installer", + "homepage": "https://composer.github.io/installers/", + "keywords": [ + "Dolibarr", + "Eliasis", + "Hurad", + "ImageCMS", + "Kanboard", + "Lan Management System", + "MODX Evo", + "MantisBT", + "Mautic", + "Maya", + "OXID", + "Plentymarkets", + "Porto", + "RadPHP", + "SMF", + "Starbug", + "Thelia", + "Whmcs", + "WolfCMS", + "agl", + "annotatecms", + "attogram", + "bitrix", + "cakephp", + "chef", + "cockpit", + "codeigniter", + "concrete5", + "croogo", + "dokuwiki", + "drupal", + "eZ Platform", + "elgg", + "expressionengine", + "fuelphp", + "grav", + "installer", + "itop", + "known", + "kohana", + "laravel", + "lavalite", + "lithium", + "magento", + "majima", + "mako", + "matomo", + "mediawiki", + "miaoxing", + "modulework", + "modx", + "moodle", + "osclass", + "pantheon", + "phpbb", + "piwik", + "ppi", + "processwire", + "puppet", + "pxcms", + "reindex", + "roundcube", + "shopware", + "silverstripe", + "sydes", + "sylius", + "tastyigniter", + "wordpress", + "yawik", + "zend", + "zikula" + ], + "support": { + "issues": "https://github.com/composer/installers/issues", + "source": "https://github.com/composer/installers/tree/v2.2.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-08-20T06:45:11+00:00" + }, { "name": "graham-campbell/result-type", "version": "v1.1.2", @@ -3437,16 +3582,16 @@ }, { "name": "doctrine/inflector", - "version": "2.0.9", + "version": "2.0.10", "source": { "type": "git", "url": "https://github.com/doctrine/inflector.git", - "reference": "2930cd5ef353871c821d5c43ed030d39ac8cfe65" + "reference": "5817d0659c5b50c9b950feb9af7b9668e2c436bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/2930cd5ef353871c821d5c43ed030d39ac8cfe65", - "reference": "2930cd5ef353871c821d5c43ed030d39ac8cfe65", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/5817d0659c5b50c9b950feb9af7b9668e2c436bc", + "reference": "5817d0659c5b50c9b950feb9af7b9668e2c436bc", "shasum": "" }, "require": { @@ -3508,7 +3653,7 @@ ], "support": { "issues": "https://github.com/doctrine/inflector/issues", - "source": "https://github.com/doctrine/inflector/tree/2.0.9" + "source": "https://github.com/doctrine/inflector/tree/2.0.10" }, "funding": [ { @@ -3524,7 +3669,7 @@ "type": "tidelift" } ], - "time": "2024-01-15T18:05:13+00:00" + "time": "2024-02-18T20:23:39+00:00" }, { "name": "doctrine/instantiator", @@ -9959,5 +10104,5 @@ "platform-overrides": { "php": "7.2.34" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/docker-compose.yml b/docker-compose.yml index cf3bb312e..2338f64bc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,24 +9,33 @@ services: restart: always ports: - ${WP_PORT}:80 + user: "${UID:-1000}:${GID:-1000}" environment: WORDPRESS_DB_HOST: db WORDPRESS_DB_NAME: wp - WORDPRESS_DB_USER: wp - WORDPRESS_DB_PASSWORD: pass + WORDPRESS_DB_USER: root + WORDPRESS_DB_PASSWORD: password WORDPRESS_SKIP_INSTALL: 'yes' + WORDPRESS_DEBUG: 1 volumes: - ./:/var/www/html/wp-content/plugins/kadence-blocks depends_on: - - db + db: + condition: service_healthy db: - image: mariadb:10.5 + image: mariadb:10.7.8 restart: always + healthcheck: # The `wp` db should exist. + test: mysqlshow -u root -ppassword wp + start_period: 5s + interval: 1s + timeout: 3s + retries: 30 ports: - ${DB_PORT}:3306 environment: MYSQL_DATABASE: wp - MYSQL_USER: wp - MYSQL_PASSWORD: pass - MYSQL_RANDOM_ROOT_PASSWORD: '1' + MYSQL_ROOT_PASSWORD: password + tmpfs: + - /var/lib/mysql diff --git a/tests/codeception.env b/tests/codeception.env index bdb90ae2c..24d66ed5f 100644 --- a/tests/codeception.env +++ b/tests/codeception.env @@ -5,8 +5,8 @@ TEST_SITE_WP_ADMIN_PATH="/wp-admin" TEST_SITE_DB_NAME="wp" TEST_SITE_DB_HOST="db" TEST_SITE_DB_PORT="3306" -TEST_SITE_DB_USER="wp" -TEST_SITE_DB_PASSWORD="pass" +TEST_SITE_DB_USER="root" +TEST_SITE_DB_PASSWORD="password" TEST_SITE_TABLE_PREFIX="wp_" TEST_SITE_WP_URL="http://localhost" TEST_SITE_WP_DOMAIN="localhost" @@ -16,6 +16,6 @@ TEST_SITE_ADMIN_PASSWORD="admin" TEST_DB_NAME="wp" TEST_DB_HOST="db" -TEST_DB_USER="wp" -TEST_DB_PASSWORD="pass" +TEST_DB_USER="root" +TEST_DB_PASSWORD="password" TEST_TABLE_PREFIX="wp_" diff --git a/tests/docker-compose.codeception.env b/tests/docker-compose.codeception.env index bdb90ae2c..24d66ed5f 100644 --- a/tests/docker-compose.codeception.env +++ b/tests/docker-compose.codeception.env @@ -5,8 +5,8 @@ TEST_SITE_WP_ADMIN_PATH="/wp-admin" TEST_SITE_DB_NAME="wp" TEST_SITE_DB_HOST="db" TEST_SITE_DB_PORT="3306" -TEST_SITE_DB_USER="wp" -TEST_SITE_DB_PASSWORD="pass" +TEST_SITE_DB_USER="root" +TEST_SITE_DB_PASSWORD="password" TEST_SITE_TABLE_PREFIX="wp_" TEST_SITE_WP_URL="http://localhost" TEST_SITE_WP_DOMAIN="localhost" @@ -16,6 +16,6 @@ TEST_SITE_ADMIN_PASSWORD="admin" TEST_DB_NAME="wp" TEST_DB_HOST="db" -TEST_DB_USER="wp" -TEST_DB_PASSWORD="pass" +TEST_DB_USER="root" +TEST_DB_PASSWORD="password" TEST_TABLE_PREFIX="wp_"