assertwell / wp-core-test-framework

Streamline testing WordPress plugins and themes using the WordPress core test framework
MIT License
9 stars 1 forks source link

Automate checks for upstream changes #1

Open stevegrunwell opened 4 years ago

stevegrunwell commented 4 years ago

It would be great if we were periodically (once a week, or so) checking the upstream script file to see if anything's changed.

This would be a great opportunity to explore GitHub Actions, and I have the basic logic started:

name: Check for out-of-date shell scripts

on:
  # Run this every Monday at 00:00:00.
  schedule:
  - cron: "0 0 0 0 1"

jobs:
  check-dependencies:
    steps:
      - name: Refresh bin/install-wp-tests.sh
        run: composer refresh-install-wp-tests
      - name: Verify if anything has changed
        run: git diff --exit-code

The last thing needed is to notify repo maintainers if changes were found so we can update + tag a new release accordingly.

szepeviktor commented 3 years ago

@stevegrunwell It is update time :)

index f8db3cc..6a295fa 100644
--- a/bin/install-wp-tests.sh
+++ b/bin/install-wp-tests.sh
@@ -17,7 +17,7 @@ SKIP_DB_CREATE=${6-false}
 TMPDIR=${TMPDIR-/tmp}
 TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//")
 WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib}
-WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress/}
+WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress}

 download() {
     if [ `which curl` ]; then
@@ -64,10 +64,9 @@ install_wp() {
    mkdir -p $WP_CORE_DIR

    if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
-       mkdir -p $TMPDIR/wordpress-nightly
-       download https://wordpress.org/nightly-builds/wordpress-latest.zip  $TMPDIR/wordpress-nightly/wordpress-nightly.zip
-       unzip -q $TMPDIR/wordpress-nightly/wordpress-nightly.zip -d $TMPDIR/wordpress-nightly/
-       mv $TMPDIR/wordpress-nightly/wordpress/* $WP_CORE_DIR
+       mkdir -p $TMPDIR/wordpress-trunk
+       svn export --quiet https://core.svn.wordpress.org/trunk $TMPDIR/wordpress-trunk/wordpress
+       mv $TMPDIR/wordpress-trunk/wordpress/* $WP_CORE_DIR
    else
        if [ $WP_VERSION == 'latest' ]; then
            local ARCHIVE_NAME='latest'
@@ -109,8 +108,8 @@ install_test_suite() {
    if [ ! -d $WP_TESTS_DIR ]; then
        # set up testing suite
        mkdir -p $WP_TESTS_DIR
-       svn co --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
-       svn co --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
+       svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
+       svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
    fi

    if [ ! -f wp-tests-config.php ]; then
@@ -167,8 +166,7 @@ install_db() {
    fi

    # create database
-   # Overwritten to incorporate https://github.com/wp-cli/scaffold-command/pull/255.
-   if [ $(mysql --user="$DB_USER" --password="$DB_PASS" --execute='show databases;' | grep ^$DB_NAME$) ]
+   if [ $(mysql --user="$DB_USER" --password="$DB_PASS"$EXTRA --execute='show databases;' | grep ^$DB_NAME$) ]
    then
        echo "Reinstalling will delete the existing test database ($DB_NAME)"
        read -p 'Are you sure you want to proceed? [y/N]: ' DELETE_EXISTING_DB

May I send a PR?

stevegrunwell commented 3 years ago

Please feel free, and I'll make sure you get Hacktoberfest credit for it, too :wink: Thank you!

szepeviktor commented 3 years ago

you get Hacktoberfest credit for it,

Okay, no need for that. Just send €1 000 000 to me.