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

update live with wordpress trunk related build fixes from develop #1201

Merged
merged 3 commits into from
Oct 1, 2024
Merged
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
36 changes: 34 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,20 @@ jobs:
- run: chmod -R 777 . # required to build the release
- run: sudo chown -R $UID:1000 . # required for wordpress' filesystem direct implementation
- run: docker compose --env-file .env.default --env-file .env up -d wordpress
- run: sleep 60 # wait for docker-compose launch to finish
- run: |
# wait for docker-compose launch to finish
elapsed=0
until [ -e ./docker/wordpress/test/setup_finished ] || (( elapsed++ >= 240 )); do
sleep 1
done

if [ ! -e ./docker/wordpress/test/setup_finished ]; then
echo "did not setup local environment in time"
exit 1
fi
[ -e /tmp/file.txt ] && echo File exists || echo Timeout
- run: npm run compose logs wordpress --no-color # for debugging failures to start
if: always()

- name: Run unit tests
shell: bash
Expand Down Expand Up @@ -213,14 +225,30 @@ jobs:
UID=$UID
WITHOUT_MARKETPLACE=1
WP_DEBUG=true
WP_DEBUG_LOG=true
WP_DEBUG_DISPLAY=false
EOF
env:
PHP_VERSION: ${{ matrix.php-versions }}
WORDPRESS_VERSION: ${{ matrix.wp-versions }}
- run: chmod -R 777 . # required to build the release
- run: docker compose --env-file .env.default --env-file .env up -d wordpress
- run: sleep 60 # wait for docker-compose launch to finish
- run: |
# wait for docker-compose launch to finish
elapsed=0
until [ -e ./docker/wordpress/test/setup_finished ] || (( elapsed++ >= 240 )); do
sleep 1
done

if [ ! -e ./docker/wordpress/test/setup_finished ]; then
echo "did not setup local environment in time"
exit 1
fi
[ -e /tmp/file.txt ] && echo File exists || echo Timeout
- run: |
cp ./functions_override.php ./docker/wordpress/test/wp-includes/functions.php
- run: npm run compose logs wordpress --no-color # for debugging failures to start
if: always()

# build release from current code
- run: |
Expand Down Expand Up @@ -262,6 +290,10 @@ jobs:
if: always()
- run: npm run compose stop

# output debug.concat.log (created in a hook in wdio.conf.ts)
- run: cat ./docker/wordpress/test/wp-content/debug.concat.log || echo "debug.concat.log file does not exist"
if: always()

checkstyle:
runs-on: 'ubuntu-20.04'
steps:
Expand Down
9 changes: 7 additions & 2 deletions matomo.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
exit; // if accessed directly
}

load_plugin_textdomain( 'matomo', false, basename( dirname( __FILE__ ) ) . '/languages' );

if ( ! defined( 'MATOMO_ANALYTICS_FILE' ) ) {
define( 'MATOMO_ANALYTICS_FILE', __FILE__ );
}
Expand All @@ -37,6 +35,13 @@
/** MATOMO_PLUGIN_FILES => used to check for updates etc */
$GLOBALS['MATOMO_PLUGIN_FILES'] = array( MATOMO_ANALYTICS_FILE );

add_action(
'init',
function () {
load_plugin_textdomain( 'matomo', false, basename( dirname( __FILE__ ) ) . '/languages' );
}
);

function matomo_has_compatible_content_dir() {
if ( ! empty( $_SERVER['MATOMO_WP_ROOT_PATH'] )
&& file_exists( rtrim( $_SERVER['MATOMO_WP_ROOT_PATH'], '/' ) . '/wp-load.php' ) ) {
Expand Down
6 changes: 6 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,15 @@ for chunk in ${PIECES[@]}; do
if [[ "$chunk" == "." ]]; then
RSYNC_FROM="$TMP_DIR/"
RSYNC_TO="trunk"

echo "➤ existing trunk version: $(cat readme.txt | grep -oP "Stable tag: \K(.+)")"
fi
rsync -rc "$RSYNC_FROM" "$RSYNC_TO" --delete --delete-excluded

if [[ "$chunk" == "." ]]; then
echo "➤ rsynced version: $(cat readme.txt | grep -oP "Stable tag: \K(.+)")"
fi

if [[ ! -d "trunk/$chunk" ]]; then # sanity check
echo "➤ ERROR: '$chunk' folder does not exist"
exit 1;
Expand Down
7 changes: 6 additions & 1 deletion scripts/local-dev-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ define( 'BLOG_ID_CURRENT_SITE', 1 );
fi

WP_DEBUG="${WP_DEBUG:-false}"
WP_DEBUG_LOG="${WP_DEBUG_LOG:-false}"
WP_DEBUG_DISPLAY="${WP_DEBUG_DISPLAY:-true}"
cat > "/var/www/html/$WORDPRESS_FOLDER/wp-config.php" <<EOF
<?php
define( 'DB_NAME', '$WP_DB_NAME' );
Expand All @@ -122,7 +124,8 @@ define( 'DB_HOST', getenv('WP_DB_HOST') );
define( 'DB_CHARSET', 'utf8' );
define( 'DB_COLLATE', '' );
define( 'WP_DEBUG', $WP_DEBUG );
define( "WP_DEBUG_LOG", false );
define( 'WP_DEBUG_LOG', $WP_DEBUG_LOG );
define( 'WP_DEBUG_DISPLAY', $WP_DEBUG_DISPLAY );
define( 'WP_ENVIRONMENT_TYPE', 'local' );
$MULTISITE_CONFIG

Expand Down Expand Up @@ -465,6 +468,8 @@ find "/var/www/html/$WORDPRESS_FOLDER" -path "/var/www/html/$WORDPRESS_FOLDER/wp
find "/var/www/html/$WORDPRESS_FOLDER" -path "/var/www/html/$WORDPRESS_FOLDER/wp-content/plugins/matomo" -prune -o -exec chmod 0777 {} +
chmod -R 0777 "/var/www/html/$WORDPRESS_FOLDER/wp-content/plugins/matomo/app/tmp" "/var/www/html/index.php" "/usr/local/etc/php/conf.d" "/var/www/html/$WORDPRESS_FOLDER/debug.log" /var/www/html/matomo.wpload_dir.php

touch /var/www/html/$WORDPRESS_FOLDER/setup_finished

if ! which apache2-foreground &> /dev/null; then
# TODO: is it possible to use wp-cli for this?
# make sure home url points to 'nginx' service
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 41 additions & 2 deletions wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import GlobalSetup from './tests/e2e/global-setup.ts';
const dirname = path.dirname(url.fileURLToPath(import.meta.url));

const DOWNLOADS_DIR = path.join(dirname, 'tests', 'e2e', 'downloads');
const WORDPRESS_DIR_NAME = process.env.WORDPRESS_FOLDER || process.env.WORDPRESS_VERSION || '';

if (!fs.existsSync(DOWNLOADS_DIR)) {
fs.mkdirSync(DOWNLOADS_DIR);
Expand All @@ -23,6 +24,32 @@ async function saveScreenshotIfError(test, error) {
}
}

function checkWpDebugLogsForError() {
const wpDebugLogPath = path.join(dirname, 'docker', 'wordpress', WORDPRESS_DIR_NAME, 'wp-content', 'debug.log');
const wpDebugLogConcatPath = path.join(dirname, 'docker', 'wordpress', WORDPRESS_DIR_NAME, 'wp-content', 'debug.concat.log');

if (!fs.existsSync(wpDebugLogPath)) {
return;
}

try {
let contents = fs.readFileSync(wpDebugLogPath).toString('utf-8');

fs.appendFileSync(wpDebugLogConcatPath, contents);

let lines = contents.split("\n");
let matomoErrors = lines.filter((line) => {
return /php (notice|warning|error|deprecated):/i.test(line) && line.toLowerCase().includes('matomo');
});

if (matomoErrors.length) {
throw new Error(`Found Matomo related errors/warnings in debug.log:\n- ${matomoErrors.join("\n- ")}`);
}
} finally {
fs.unlinkSync(wpDebugLogPath); // reset the wp-debug log file
}
}

export const config: Options.Testrunner = {
//
// ====================
Expand Down Expand Up @@ -218,8 +245,20 @@ export const config: Options.Testrunner = {
// it and to build services around it. You can either apply a single function or an array of
// methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
// resolved to continue.
async afterTest(test, context, { error }) {
await saveScreenshotIfError(test, error);
async afterTest(test, context, params) {
let { error } = params;

if (error) {
await saveScreenshotIfError(test, error);
return;
}

try {
checkWpDebugLogsForError();
} catch (err) {
await saveScreenshotIfError(test, err);
throw err;
}
},

async afterHook(test, context, { error }) {
Expand Down
Loading