diff --git a/.github/workflows/reusable-testing.yml b/.github/workflows/reusable-testing.yml index 702a634..33b0f62 100644 --- a/.github/workflows/reusable-testing.yml +++ b/.github/workflows/reusable-testing.yml @@ -11,12 +11,7 @@ concurrency: jobs: - unit: #----------------------------------------------------------------------- - name: Unit test / PHP ${{ matrix.php }} - strategy: - fail-fast: false - matrix: - php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] + has_unit_tests: runs-on: ubuntu-20.04 steps: @@ -29,8 +24,26 @@ jobs: with: files: "composer.json, phpunit.xml.dist" + outputs: + exists: ${{ steps.check_files.outputs.files_exists }} + + unit: + name: Unit tests on PHP ${{ matrix.php }} + needs: + - has_unit_tests + if: ${{ needs.has_unit_tests.outputs.exists == 'true' }} + strategy: + fail-fast: false + matrix: + php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] + runs-on: ubuntu-20.04 + + steps: + - name: Check out source code + uses: actions/checkout@v3 + - name: Set up PHP environment (PHP 5.6 - 7.1) - if: ${{ matrix.php < '7.2' && steps.check_files.outputs.files_exists == 'true'}} + if: ${{ matrix.php < '7.2' }} uses: shivammathur/setup-php@v2 with: php-version: '${{ matrix.php }}' @@ -41,35 +54,52 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set up PHP environment (PHP 7.2+) - if: ${{ matrix.php >= '7.2' && steps.check_files.outputs.files_exists == 'true'}} + if: ${{ matrix.php >= '7.2' }} + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} uses: shivammathur/setup-php@v2 with: php-version: '${{ matrix.php }}' coverage: none tools: composer,cs2pr - env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install Composer dependencies & cache dependencies - if: steps.check_files.outputs.files_exists == 'true' - uses: "ramsey/composer-install@v2" env: COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }} + uses: "ramsey/composer-install@v2" with: # Bust the cache at least once a month - output format: YYYY-MM. - custom-cache-suffix: $(date -u "+%Y-%m") + custom-cache-suffix: | + $(date -u "+%Y-%m") - name: Setup problem matcher to provide annotations for PHPUnit - if: steps.check_files.outputs.files_exists == 'true' run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - name: Run PHPUnit - if: steps.check_files.outputs.files_exists == 'true' - continue-on-error: ${{ matrix.php == '8.2' }} run: composer phpunit + continue-on-error: ${{ matrix.php == '8.2' }} + + has_functional_tests: + runs-on: ubuntu-20.04 - functional: #---------------------------------------------------------------------- + steps: + - name: Check out source code + uses: actions/checkout@v3 + + - name: Check existence of composer.json & behat.yml files + id: check_files + uses: andstor/file-existence-action@v2 + with: + files: "composer.json, behat.yml" + + outputs: + exists: ${{ steps.check_files.outputs.files_exists }} + + functional: name: Functional - WP ${{ matrix.wp }} on PHP ${{ matrix.php }} with MySQL ${{ matrix.mysql }} + needs: + - has_functional_tests + if: ${{ needs.has_functional_tests.outputs.exists == 'true' }} strategy: fail-fast: false matrix: @@ -114,55 +144,45 @@ jobs: image: mysql:${{ matrix.mysql }} ports: - 3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=wp_cli_test --entrypoint sh mysql:${{ matrix.mysql }} -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password" + options: | + --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=wp_cli_test --entrypoint sh mysql:${{ matrix.mysql }} -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password" steps: - name: Check out source code uses: actions/checkout@v3 - - name: Check existence of composer.json & behat.yml files - id: check_files - uses: andstor/file-existence-action@v2 - with: - files: "composer.json, behat.yml" - - name: Install Ghostscript - if: steps.check_files.outputs.files_exists == 'true' run: | sudo apt-get update - sudo apt-get install ghostscript -y + sudo apt-get install -y ghostscript - name: Set up PHP environment - if: steps.check_files.outputs.files_exists == 'true' + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} uses: shivammathur/setup-php@v2 with: php-version: '${{ matrix.php }}' extensions: gd, imagick, mysql, zip coverage: none tools: composer - env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Change ImageMagick policy to allow pdf->png conversion. - if: steps.check_files.outputs.files_exists == 'true' run: | sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml - name: Install Composer dependencies & cache dependencies - if: steps.check_files.outputs.files_exists == 'true' - uses: "ramsey/composer-install@v2" env: COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }} + uses: "ramsey/composer-install@v2" with: # Bust the cache at least once a month - output format: YYYY-MM. - custom-cache-suffix: $(date -u "+%Y-%m") + custom-cache-suffix: | + $(date -u "+%Y-%m") - name: Start MySQL server - if: steps.check_files.outputs.files_exists == 'true' run: sudo systemctl start mysql - name: Configure DB environment - if: steps.check_files.outputs.files_exists == 'true' run: | echo "MYSQL_HOST=127.0.0.1" >> $GITHUB_ENV echo "MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV @@ -174,18 +194,15 @@ jobs: echo "WP_CLI_TEST_DBHOST=127.0.0.1:${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV - name: Prepare test database - if: steps.check_files.outputs.files_exists == 'true' run: composer prepare-tests - name: Check Behat environment - if: steps.check_files.outputs.files_exists == 'true' env: WP_VERSION: '${{ matrix.wp }}' run: WP_CLI_TEST_DEBUG_BEHAT_ENV=1 composer behat - name: Run Behat - if: steps.check_files.outputs.files_exists == 'true' - continue-on-error: ${{ matrix.php == '8.2' }} env: WP_VERSION: '${{ matrix.wp }}' run: composer behat || composer behat-rerun + continue-on-error: ${{ matrix.php == '8.2' }} diff --git a/.github/workflows/sync-workflows.yml b/.github/workflows/sync-workflows.yml index 33d6964..38928cc 100644 --- a/.github/workflows/sync-workflows.yml +++ b/.github/workflows/sync-workflows.yml @@ -11,7 +11,7 @@ on: jobs: - sync-workflows: #------------------------------------------------------------- + sync-workflows: name: Sync GitHub Actions workflows runs-on: ubuntu-latest if: ${{ github.repository_owner == 'wp-cli' }} @@ -68,7 +68,7 @@ jobs: wp-cli/wp-super-cache-cli GITHUB_TOKEN: ${{ secrets.ACTIONS_BOT }} - sync-dependabot: #------------------------------------------------------------ + sync-dependabot: name: Sync Dependabot configuration runs-on: ubuntu-latest if: ${{ github.repository_owner == 'wp-cli' }}