From 1008bd62c8881b6e26c01c97ff266a4bc1798bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 13:11:43 +0200 Subject: [PATCH] test --- .forgejo/workflows/phpcs.yml | 2 +- .forgejo/workflows/phpunit.yml | 7 ++++--- bin/install-wp-tests.sh | 22 +++++++++++++++++++--- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.forgejo/workflows/phpcs.yml b/.forgejo/workflows/phpcs.yml index 3338848..7b30c4a 100755 --- a/.forgejo/workflows/phpcs.yml +++ b/.forgejo/workflows/phpcs.yml @@ -33,7 +33,7 @@ jobs: ./vendor/ /root/.cache/composer/ /usr/local/bin/composer - key: cache-composer-2 + key: cache-composer-3 - name: Setup PHP uses: https://github.com/shivammathur/setup-php@v2 diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 06eb2cf..9efddd0 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -65,13 +65,14 @@ jobs: packages: mysql-client version: 1.0 - # - name: Install mysqladmin - # run: sudo apt update && sudo apt -y upgrade && sudo apt -y install mysql-client - - name: Setup Test Environment if: steps.cache-wordpress.outputs.cache-hit != 'true' run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 6.6 + - name: Setup WordPress Test Database + if: steps.cache-wordpress.outputs.cache-hit != 'false' + run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 6.6 false true true true + - run: composer show -i - name: Unit Testing diff --git a/bin/install-wp-tests.sh b/bin/install-wp-tests.sh index e772021..f10e7c3 100644 --- a/bin/install-wp-tests.sh +++ b/bin/install-wp-tests.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash if [ $# -lt 3 ]; then - echo "usage: $0 [db-host] [wp-version] [skip-database-creation]" + echo "usage: $0 [db-host] [wp-version] [skip-database-creation] [skip-wp-install] [skip-plugins] [skip-test-suite]" exit 1 fi @@ -11,6 +11,10 @@ DB_PASS=$3 DB_HOST=${4-localhost} WP_VERSION=${5-latest} SKIP_DB_CREATE=${6-false} +SKIP_WP_INSTALL=${7-false} +SKIP_PLUGINS_INSTALL=${8-false} +SKIP_TEST_SUITE_INSTALL=${9-false} + TMPDIR=${TMPDIR-/tmp} TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//") @@ -54,7 +58,10 @@ fi set -ex install_wp() { - rm -rf $WP_CORE_DIR + if [ "$SKIP_WP_INSTALL" = "true" ]; then + echo "Skipping WordPress installation." + return 0 + fi if [ -d $WP_CORE_DIR ]; then return; @@ -97,6 +104,11 @@ install_wp() { } install_test_suite() { + if [ "$SKIP_TEST_SUITE_INSTALL" = "true" ]; then + echo "Skipping test suite installation." + return 0 + fi + # portable in-place argument for both GNU sed and Mac OSX sed if [[ $(uname -s) == 'Darwin' ]]; then local ioption='-i.bak' @@ -178,7 +190,11 @@ install_db() { } install_wp_plugins() { - download https://downloads.wordpress.org/plugin/activitypub.3.2.5.zip $TMPDIR/activitypub.zip + if [ "$SKIP_PLUGINS_INSTALL" = "true" ]; then + echo "Skipping WordPress plugin installation." + return 0 + fi + download https://downloads.wordpress.org/plugin/activitypub.3.2.5.zip $TMPDIR/activitypub.zip unzip $TMPDIR/activitypub.zip -d $WP_CORE_DIR/wp-content/plugins/ }