diff --git a/.github/workflows/integrationtest.yml b/.github/workflows/test.yml similarity index 63% rename from .github/workflows/integrationtest.yml rename to .github/workflows/test.yml index 19a9bc4e4f6..0a74ffd1e73 100644 --- a/.github/workflows/integrationtest.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Integration Test +name: Test on: # Run on pushes to select branches and on all pull requests. @@ -20,6 +20,69 @@ concurrency: cancel-in-progress: true jobs: + unit-test: + runs-on: ubuntu-latest + + strategy: + matrix: + php_version: ["7.2", "7.4", "8.0", "8.1", "8.2"] + + name: "Unit Test: PHP ${{ matrix.php_version }}" + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + # The prefix-dependencies task makes use of reflection-based PHP code that only works on PHP > 7.2. + - name: Install PHP 7.x for generating the vendor_prefixed directory and dependency injection + uses: shivammathur/setup-php@v2 + with: + php-version: 7.2 + coverage: none + + - name: Install Composer dependencies, generate vendor_prefixed directory and run dependency injection + uses: ramsey/composer-install@v2 + with: + # Bust the cache at least once a week - output format: YYYY-MM-DD. + custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F") + + # Remove packages which are not PHP cross-version compatible and only used for the prefixing. + # - humbug/php-scoper is only needed to actually do the prefixing, so won't be shipped anyway. + - name: Delete dev dependencies which are not cross-version compatible + run: composer remove --dev --no-scripts humbug/php-scoper + + - name: Remove vendor directory + run: rm -rf vendor/* + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php_version }} + ini-values: zend.assertions=1, error_reporting=-1, display_errors=On + coverage: none + + # The PHP platform requirement would prevent updating the test utilities to the appropriate versions. + # As long as the `composer update` is run selectively to only update the test utils, removing this is fine. + - name: "Composer: remove the PHP platform requirement" + run: composer config --unset platform.php + + # Install dependencies and handle caching in one go. + # - Updates the test utilities (and only those!) to the most appropriate version + # for the PHP version on which the tests will be run. + # @link https://github.com/marketplace/actions/install-composer-dependencies + - name: Install Composer dependencies + uses: ramsey/composer-install@v2 + with: + # Force a `composer update` run. + dependency-versions: "highest" + # But make it selective. + composer-options: "yoast/wp-test-utils --with-dependencies --no-scripts" + # Bust the cache at least once a week - output format: YYYY-MM-DD. + custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F") + + - name: Run unit tests + run: composer test + integration-test: runs-on: ubuntu-latest diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml deleted file mode 100644 index bf6646a2cd2..00000000000 --- a/.github/workflows/unittest.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: Unit Test - -on: - # Run on pushes to select branches and on all pull requests. - push: - branches: - - main - - trunk - - "release/**" - - "hotfix/[0-9]+.[0-9]+*" - - "feature/**" - pull_request: - # Allow manually triggering the workflow. - workflow_dispatch: - -# Cancels all previous workflow runs for the same branch that have not yet completed. -concurrency: - # The concurrency group contains the workflow name and the branch name. - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - unit-test: - runs-on: ubuntu-latest - - strategy: - matrix: - php_version: ["7.2", "7.4", "8.0", "8.1", "8.2"] - - name: "Unit Test: PHP ${{ matrix.php_version }}" - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - # The prefix-dependencies task makes use of reflection-based PHP code that only works on PHP > 7.2. - - name: Install PHP 7.x for generating the vendor_prefixed directory and dependency injection - uses: shivammathur/setup-php@v2 - with: - php-version: 7.2 - coverage: none - - - name: Install Composer dependencies, generate vendor_prefixed directory and run dependency injection - uses: ramsey/composer-install@v2 - with: - # Bust the cache at least once a week - output format: YYYY-MM-DD. - custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F") - - # Remove packages which are not PHP cross-version compatible and only used for the prefixing. - # - humbug/php-scoper is only needed to actually do the prefixing, so won't be shipped anyway. - - name: Delete dev dependencies which are not cross-version compatible - run: composer remove --dev --no-scripts humbug/php-scoper - - - name: Remove vendor directory - run: rm -rf vendor/* - - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php_version }} - ini-values: zend.assertions=1, error_reporting=-1, display_errors=On - coverage: none - - # The PHP platform requirement would prevent updating the test utilities to the appropriate versions. - # As long as the `composer update` is run selectively to only update the test utils, removing this is fine. - - name: "Composer: remove the PHP platform requirement" - run: composer config --unset platform.php - - # Install dependencies and handle caching in one go. - # - Updates the test utilities (and only those!) to the most appropriate version - # for the PHP version on which the tests will be run. - # @link https://github.com/marketplace/actions/install-composer-dependencies - - name: Install Composer dependencies - uses: ramsey/composer-install@v2 - with: - # Force a `composer update` run. - dependency-versions: "highest" - # But make it selective. - composer-options: "yoast/wp-test-utils --with-dependencies --no-scripts" - # Bust the cache at least once a week - output format: YYYY-MM-DD. - custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F") - - - name: Run unit tests - run: composer test diff --git a/README.md b/README.md index 4c443e4bbce..ef2863cd0e9 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ [![Lint](https://github.com/Yoast/wordpress-seo/actions/workflows/lint.yml/badge.svg)](https://github.com/Yoast/wordpress-seo/actions/workflows/lint.yml) [![LintJS](https://github.com/Yoast/wordpress-seo/actions/workflows/jslint.yml/badge.svg)](https://github.com/Yoast/wordpress-seo/actions/workflows/jslint.yml) [![TestJS](https://github.com/Yoast/wordpress-seo/actions/workflows/jstest.yml/badge.svg)](https://github.com/Yoast/wordpress-seo/actions/workflows/jstest.yml) -[![Unit Tests](https://github.com/Yoast/wordpress-seo/actions/workflows/unittest.yml/badge.svg)](https://github.com/Yoast/wordpress-seo/actions/workflows/unittest.yml) -[![Integration Tests](https://github.com/Yoast/wordpress-seo/actions/workflows/integrationtest.yml/badge.svg)](https://github.com/Yoast/wordpress-seo/actions/workflows/integrationtest.yml) +[![Test](https://github.com/Yoast/wordpress-seo/actions/workflows/test.yml/badge.svg)](https://github.com/Yoast/wordpress-seo/actions/workflows/test.yml) [![Deployment](https://github.com/Yoast/wordpress-seo/actions/workflows/deploy.yml/badge.svg)](https://github.com/Yoast/wordpress-seo/actions/workflows/deploy.yml) + [![Stable Version](https://poser.pugx.org/yoast/wordpress-seo/v/stable.svg)](https://packagist.org/packages/yoast/wordpress-seo) [![License](https://poser.pugx.org/yoast/wordpress-seo/license.svg)](https://packagist.org/packages/yoast/wordpress-seo)