From f0027aa70dab2eafdf3a8f640366f0123086bd5f Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Fri, 19 Jul 2024 00:12:36 +0800 Subject: [PATCH 1/4] Migrate the tests from Travis CI to GitHub Actions --- .github/workflows/tests.yml | 32 +++++++++++++++++++ .travis.yml | 63 ------------------------------------- README.md | 2 +- 3 files changed, 33 insertions(+), 64 deletions(-) create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..315e267 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,32 @@ +name: Run Tests + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + php-version: [7.1, 7.2, 7.3, 7.4] + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + + - name: Install dependencies + run: composer install --prefer-source --no-interaction --dev + + - name: Run tests + run: vendor/bin/phpunit diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f07ffb9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,63 +0,0 @@ -language: php - -notifications: - email: - on_success: never - on_failure: change - -cache: - directories: - - vendor - - $HOME/.composer/cache - -matrix: - include: - - php: 7.4 - env: WP_VERSION=latest - - php: 7.3 - env: WP_VERSION=latest - - php: 7.2 - env: WP_VERSION=latest - - php: 7.1 - env: WP_VERSION=latest - - php: 7.1 - env: WP_VERSION=4.9 - - php: 7.1 - env: WP_VERSION=4.8 - - php: 7.1 - env: WP_VERSION=4.7 - - php: 7.1 - env: WP_TRAVISCI=phpcs - allow_failures: - - php: 7.1 - env: WP_TRAVISCI=phpcs - -branches: - only: - - master - -before_script: - - export PATH="$HOME/.composer/vendor/bin:$PATH" - - | - if [[ ! -z "$WP_VERSION" ]] ; then - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION - phpenv config-rm xdebug.ini - composer global require "phpunit/phpunit=5.7.*" - fi - - | - if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then - composer global require wp-coding-standards/wpcs - phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs - fi - - composer install --prefer-source --no-interaction --dev - -script: - - | - if [[ ! -z "$WP_VERSION" ]] ; then - phpdbg -qrr phpunit - WP_MULTISITE=1 phpdbg -qrr phpunit - fi - - | - if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then - phpcs --standard=phpcs.ruleset.xml $(find . -name '*.php') - fi diff --git a/README.md b/README.md index 8c0b951..ab6a088 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Disable Comments for WordPress -[![Build Status](https://travis-ci.org/solarissmoke/disable-comments.svg?branch=master)](https://travis-ci.org/solarissmoke/disable-comments) +[![Build Status](https://github.com/WPDevelopers/disable-comments/actions/workflows/tests.yml/badge.svg)](https://github.com/WPDevelopers/disable-comments/actions/workflows/tests.yml) This is the development respository for the [Disable Comments](https://wordpress.org/plugins/disable-comments/) WordPress plugin. Send pull requests here, download the latest stable version there! From c6e043f36b540e4298ff54e1db7ee7c0b38b17f8 Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Fri, 19 Jul 2024 00:21:54 +0800 Subject: [PATCH 2/4] test --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 315e267..0f01920 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,4 +29,4 @@ jobs: run: composer install --prefer-source --no-interaction --dev - name: Run tests - run: vendor/bin/phpunit + run: ./vendor/bin/phpunit From 7466e5ac98870b1bd2095a3d476bb9663cfe9c49 Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Fri, 19 Jul 2024 00:28:38 +0800 Subject: [PATCH 3/4] test --- .github/workflows/tests.yml | 58 +++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0f01920..1d04a83 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,32 +1,66 @@ -name: Run Tests +name: WordPress Plugin CI on: push: branches: - master pull_request: - branches: - - master jobs: test: runs-on: ubuntu-latest - strategy: matrix: - php-version: [7.1, 7.2, 7.3, 7.4] + php: [7.4, 7.3, 7.2, 7.1] + wp: [latest, '4.9', '4.8', '4.7'] + include: + - php: 7.1 + wp: latest + run_phpcs: true + exclude: + - php: 7.4 + wp: '4.9' + - php: 7.4 + wp: '4.8' + - php: 7.4 + wp: '4.7' + - php: 7.3 + wp: '4.9' + - php: 7.3 + wp: '4.8' + - php: 7.3 + wp: '4.7' + - php: 7.2 + wp: '4.9' + - php: 7.2 + wp: '4.8' + - php: 7.2 + wp: '4.7' steps: - - name: Checkout code - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - - name: Set up PHP + - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-version }} + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick + coverage: none - name: Install dependencies - run: composer install --prefer-source --no-interaction --dev + run: composer install --prefer-dist --no-progress --no-suggest + + - name: Install WordPress test suite + run: bash bin/install-wp-tests.sh wordpress_test root '' localhost ${{ matrix.wp }} + + - name: Run PHPUnit + run: | + phpunit + WP_MULTISITE=1 phpunit - - name: Run tests - run: ./vendor/bin/phpunit + - name: Run PHPCS + if: ${{ matrix.run_phpcs }} + run: | + composer global require wp-coding-standards/wpcs + phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs + phpcs --standard=phpcs.ruleset.xml $(find . -name '*.php') \ No newline at end of file From 9148ec75f5423f072cf1cd55f75d5e279b942f49 Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Fri, 19 Jul 2024 00:31:55 +0800 Subject: [PATCH 4/4] test --- .github/workflows/tests.yml | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1d04a83..9a93b66 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,33 +9,23 @@ on: jobs: test: runs-on: ubuntu-latest + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: rootpassword + ports: + - 3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + strategy: matrix: php: [7.4, 7.3, 7.2, 7.1] - wp: [latest, '4.9', '4.8', '4.7'] + wp: [latest, '5.9', '5.8', '5.7'] include: - - php: 7.1 + - php: 7.4 wp: latest run_phpcs: true - exclude: - - php: 7.4 - wp: '4.9' - - php: 7.4 - wp: '4.8' - - php: 7.4 - wp: '4.7' - - php: 7.3 - wp: '4.9' - - php: 7.3 - wp: '4.8' - - php: 7.3 - wp: '4.7' - - php: 7.2 - wp: '4.9' - - php: 7.2 - wp: '4.8' - - php: 7.2 - wp: '4.7' steps: - uses: actions/checkout@v2 @@ -51,7 +41,10 @@ jobs: run: composer install --prefer-dist --no-progress --no-suggest - name: Install WordPress test suite - run: bash bin/install-wp-tests.sh wordpress_test root '' localhost ${{ matrix.wp }} + env: + WP_VERSION: ${{ matrix.wp }} + run: | + bash bin/install-wp-tests.sh wordpress_test root rootpassword 127.0.0.1:${{ job.services.mysql.ports['3306'] }} $WP_VERSION - name: Run PHPUnit run: |