Skip to content

Commit

Permalink
Merge pull request #133 from Yoast/2.x
Browse files Browse the repository at this point in the history
Release version 2.0.0
  • Loading branch information
jrfnl committed Jun 6, 2023
2 parents 3b59ade + cf3c4bf commit c758753
Show file tree
Hide file tree
Showing 68 changed files with 2,108 additions and 2,303 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/.remarkignore export-ignore
/.remarkrc export-ignore
/phpunit.xml.dist export-ignore
/phpunit10.xml.dist export-ignore
/tests/ export-ignore

#
Expand Down
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ updates:
prefix: "GH Actions:"
labels:
- "Type: chores/QA"
reviewers:
- "jrfnl"

# Maintain dependencies for Composer.
- package-ecosystem: "composer"
Expand All @@ -27,3 +29,5 @@ updates:
prefix: "Composer:"
labels:
- "Type: chores/QA"
reviewers:
- "jrfnl"
7 changes: 4 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

strategy:
matrix:
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']

continue-on-error: ${{ matrix.php == '8.3' }}

Expand All @@ -36,6 +36,7 @@ jobs:
php-version: ${{ matrix.php }}
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
coverage: none
tools: cs2pr

- name: 'Composer: remove PHPUnit (not needed for lint)'
run: composer remove phpunit/phpunit --no-update --no-interaction
Expand All @@ -59,12 +60,12 @@ jobs:

- name: "Lint PHP files against parse errors - PHP < 7.0"
if: ${{ matrix.php < 7.0 }}
run: composer lint-lt70
run: composer lint-lt70 -- --checkstyle | cs2pr

- name: "Lint PHP files against parse errors - PHP 7.x"
if: ${{ startsWith( matrix.php, '7' ) }}
run: composer lint7

- name: "Lint PHP files against parse errors - PHP >= 8.0"
if: ${{ matrix.php >= 8.0 }}
run: composer lint-gte80
run: composer lint-gte80 -- --checkstyle | cs2pr
2 changes: 1 addition & 1 deletion .github/workflows/markdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ jobs:
remark-preset-lint-markdown-style-guide
remark-lint-checkbox-content-indent
remark-lint-linebreak-style
remark-lint-no-dead-urls
remark-lint-no-empty-url
remark-lint-no-heading-like-paragraph
remark-lint-no-reference-like-url
Expand All @@ -94,7 +95,6 @@ jobs:
remark-lint-list-item-punctuation
remark-lint-match-punctuation
remark-lint-no-hr-after-heading
remark-lint-are-links-valid-alive
remark-lint-are-links-valid-duplicate
remark-validate-links
Expand Down
117 changes: 101 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,64 +20,92 @@ jobs:

strategy:
matrix:
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
phpunit: ['auto']
coverage: [true]
experimental: [false]

include:
# Test against a version on the low-end of the PHPUnit versions supported for each PHP version.
# On PHP 5.4 and 5.5, only PHPUnit 4.x is supported and the lowest and the
# highest supported version would be the same.
# Using the Composer `--prefer-lowest` option is, unfortunately, not viable, as
# PHPUnit 4.8.36 doesn't have proper PHP restrictions, which means that it
# would always be installed as "low", which would break the builds for PHP 7.2+.
# it would result PHP 5.6 - 7.4 all using PHPUnit 5.7.21, which is not the intention.
# It also would run into trouble with PHP 8.5.12 being used on PHP 8.0+, while the
# 8.5.12 release still contained a bug which makes it incompatible with PHP 8.1+,
# even though it officially allows for it..
- php: '5.6'
phpunit: '5.7.21'
coverage: true
experimental: false
- php: '7.0'
phpunit: '5.7.27'
coverage: true
experimental: false
- php: '7.1'
phpunit: '5.7.21'
coverage: true
experimental: false
- php: '7.2'
phpunit: '6.3.1'
coverage: true
experimental: false
- php: '7.3'
phpunit: '7.2.7'
coverage: true
experimental: false
- php: '7.4'
phpunit: '8.1.6'
coverage: true
experimental: false
- php: '8.0'
phpunit: '8.5.16'
# PHPUnit 8.x does not support code coverage on PHP 8.x.
coverage: false
experimental: false
- php: '8.0'
phpunit: '9.3.0'
coverage: true
experimental: false
- php: '8.1'
phpunit: '9.3.0'
coverage: true
experimental: false
- php: '8.1'
# Specifically set at 10.0.12 minimum to prevent needing a toggle in the tests for something
# related to the ArrayIsList polyfill, but not necessarily relevant.
phpunit: '10.0.12'
coverage: true
experimental: false
- php: '8.2'
phpunit: '9.3.0'
coverage: true
experimental: false
- php: '8.2'
phpunit: '10.1.0'
coverage: true
experimental: false

# Experimental builds.
- php: '8.3'
phpunit: 'auto' # PHPUnit 9.x.
phpunit: '^9.6'
coverage: false
experimental: true

- php: '8.1'
phpunit: '^10.0'
- php: '8.3'
phpunit: 'auto' # PHPUnit 10.x.
coverage: false
experimental: true

- php: '8.2'
phpunit: '^10.0'
phpunit: 'dev-main'
coverage: false
experimental: true

name: "Tests: PHP ${{ matrix.php }} - PHPUnit: ${{matrix.phpunit}}"

continue-on-error: ${{ matrix.experimental }}

env:
EXTRA_PHPUNIT_CLIARGS: '--fail-on-deprecation --fail-on-notice'

steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -87,7 +115,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
coverage: none
coverage: ${{ matrix.coverage == true && 'xdebug' || 'none' }}

- name: 'Composer: set PHPUnit version for tests'
if: ${{ matrix.phpunit != 'auto' }}
Expand All @@ -110,11 +138,68 @@ jobs:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

- name: Run the unit tests
if: ${{ matrix.phpunit != '^10.0' }}
- name: Grab PHPUnit version
id: phpunit_version
run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT

- name: "DEBUG: Show grabbed version"
run: echo ${{ steps.phpunit_version.outputs.VERSION }}

- name: "Run the unit tests (PHPUnit < 10)"
if: ${{ matrix.coverage == false && ! startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
run: composer test

- name: Trial run the unit tests against PHPUnit 10.0
if: ${{ matrix.phpunit == '^10.0' }}
- name: "Run the unit tests with code coverage (PHPUnit < 10)"
if: ${{ matrix.coverage == true && ! startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
run: composer coverage

# Migrate PHPUnit configuration to deal with changes in the coverage/source setting across PHPUnit 10.x
# versions as otherwise the warning about these would fail the build (which to me, feels like a bug).
- name: "Migrate configuration (PHPUnit 10.0+)"
continue-on-error: true
run: composer test
if: ${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) && steps.phpunit_version.outputs.VERSION != '10.0' }}
run: vendor/bin/phpunit -c phpunit10.xml.dist --migrate-configuration

- name: "Run the unit tests (PHPUnit 10.0+)"
if: ${{ matrix.coverage == false && startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
# Don't fail the build on a test run failure against a future PHPUnit version.
continue-on-error: ${{ matrix.phpunit == 'dev-main' }}
run: composer test10 -- ${{ steps.phpunit_version.outputs.VERSION != '10.0' && env.EXTRA_PHPUNIT_CLIARGS || '' }}

- name: "Run the unit tests with code coverage (PHPUnit 10.0+)"
if: ${{ matrix.coverage == true && startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
# Don't fail the build on a test run failure against a future PHPUnit version.
continue-on-error: ${{ matrix.phpunit == 'dev-main' }}
run: composer coverage10 -- ${{ steps.phpunit_version.outputs.VERSION != '10.0' && env.EXTRA_PHPUNIT_CLIARGS || '' }}

# PHP Coveralls doesn't fully support PHP 8.x yet, so switch the PHP version.
- name: Switch to PHP 7.4
if: ${{ success() && matrix.coverage == true && startsWith( matrix.php, '8' ) }}
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none

# Global install is used to prevent a conflict with the local composer.lock in PHP 8.0+.
- name: Install Coveralls
if: ${{ success() && matrix.coverage == true }}
run: composer global require php-coveralls/php-coveralls:"^2.5.3" --no-interaction

- name: Upload coverage results to Coveralls
if: ${{ success() && matrix.coverage == true }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: php-${{ matrix.php }}-phpunit-${{ matrix.phpunit }}
run: php-coveralls -v -x build/logs/clover.xml

coveralls-finish:
needs: test
runs-on: ubuntu-latest

steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.COVERALLS_TOKEN }}
parallel-finished: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ vendor/
/phpcs.xml
.cache/phpcs.cache
/phpunit.xml
/phpunit10.xml
/.phpunit.result.cache
/build/
6 changes: 0 additions & 6 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,6 @@
<exclude-pattern>/src/TestListeners/TestListenerDefaultImplementationPHPUnitGte7\.php$</exclude-pattern>
</rule>

<!-- The @throws tags in the docblocks are correct, but the sniff can't analyse this correctly. -->
<rule ref="Squiz.Commenting.FunctionCommentThrowTag.Missing">
<exclude-pattern>/src/Polyfills/AssertFileDirectory\.php$</exclude-pattern>
<exclude-pattern>/src/Polyfills/ExpectException\.php$</exclude-pattern>
</rule>

<!-- Make some allowances for test files. -->
<rule ref="WordPress.PHP.DevelopmentFunctions">
<exclude-pattern>/tests/*\.php$</exclude-pattern>
Expand Down
9 changes: 8 additions & 1 deletion .remarkrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
["remark-lint-linebreak-style", "unix"],
["remark-lint-link-title-style", "\""],
["remark-lint-ordered-list-marker-style", "."],
[
"remark-lint-no-dead-urls",
{
"skipUrlPatterns": [
"^https?://github\\.com/Yoast/PHPUnit-Polyfills/compare/[0-9\\.]+?\\.{3}[0-9\\.]+"
]
}
],
"remark-lint-no-duplicate-definitions",
"remark-lint-no-empty-url",
"remark-lint-no-file-name-consecutive-dashes",
Expand All @@ -28,7 +36,6 @@
"remark-lint-list-item-punctuation",
"remark-lint-match-punctuation",
"remark-lint-no-hr-after-heading",
"remark-lint-are-links-valid-alive",
"remark-lint-are-links-valid-duplicate",
"remark-validate-links"
]
Expand Down
Loading

0 comments on commit c758753

Please sign in to comment.