Page MenuHomePhabricator

Syntax error in PHP test coverage CI job due to outdated dependency of phpunit-patch-coverage
Closed, ResolvedPublicBUG REPORT

Description

Steps to reproduce

Look at https://integration.wikimedia.org/ci/job/mwext-phpunit-coverage-patch-docker/74896/console (PHP coverage test for https://gerrit.wikimedia.org/r/c/mediawiki/extensions/DoubleWiki/+/781012).

Actual result

The following error message appeared:

$ exec phpunit-patch-coverage check --command 'php -d extension=pcov.so -d pcov.enabled=1 -d pcov.directory=/workspace/src/extensions/DoubleWiki -d pcov.exclude='\''@(tests|vendor)@'\'' -d pcov.initial.files=3000 "$MW_INSTALL_PATH"/tests/phpunit/phpunit.php' --html /workspace/log/coverage.html
Finding coverage difference in 62c8dd6b3d2de55ac62857328e9988c473ced82f

In ParserAbstract.php line 293:
                                                                               
  Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST on line   
  37                                                                           

and jenkins-bot reported that the PHP test coverage decreased.

Expected result

No syntax error, no report about decreased test coverage (zero coverage cannot be decreased…).

Other information

I don’t know what this ParserAbstract.php is or in what environment it’s run, but my first instinct is that a file updated for PHP 7.4 (by adding attribute type declarations, which are T_STRING‌s) is run under PHP 7.3 or lower:

class ParserAbstract {
	private     int        $foo;
//	^ T_PRIVATE ^ T_STRING ^ T_VARIABLE

Event Timeline

Umherirrender added subscribers: Legoktm, Umherirrender.

The error message is misleading. The fault is not in ParserAbstract.php line 293, that the line where the error is emitted from the nikic/php-parser package of mediawiki/phpunit-patch-coverage

The current used version of the parser is 3.1.3. According to https://github.com/nikic/PHP-Parser the 3.* version are for parsing <= php7.2

Needs some new version to run on php7.4

Change 855702 had a related patch set uploaded (by Reedy; author: Reedy):

[mediawiki/tools/phpunit-patch-coverage@master] composer.json: Updates

https://gerrit.wikimedia.org/r/855702

Change 855702 merged by jenkins-bot:

[mediawiki/tools/phpunit-patch-coverage@master] composer.json: Updates

https://gerrit.wikimedia.org/r/855702

Change 855605 had a related patch set uploaded (by Reedy; author: Reedy):

[labs/libraryupgrader/config@master] Bump mediawiki/phpunit-patch-coverage to 0.0.11

https://gerrit.wikimedia.org/r/855605

Change 855605 abandoned by Reedy:

[labs/libraryupgrader/config@master] Bump mediawiki/phpunit-patch-coverage to 0.0.11

Reason:

Wrong place

https://gerrit.wikimedia.org/r/855605

Change 855726 had a related patch set uploaded (by Reedy; author: Reedy):

[integration/config@master] quibble-buster-php74-coverage: Bump mediawiki/phpunit-patch-coverage

https://gerrit.wikimedia.org/r/855726

Change 855716 had a related patch set uploaded (by Jforrester; author: Jforrester):

[integration/config@master] jjb: Switch quibble-buster-php74-coverage jobs to have phpunit-patch-coverage

https://gerrit.wikimedia.org/r/855716

Change 855726 merged by jenkins-bot:

[integration/config@master] dockerfiles: [quibble-buster-php74-coverage] Bump phpunit-patch-coverage

https://gerrit.wikimedia.org/r/855726

Mentioned in SAL (#wikimedia-releng) [2022-11-10T21:33:38Z] <James_F> Docker: Upgrading quibble-buster-php74-coverage with a new vesion of phpunit-patch-coverage for T322864

Jdforrester-WMF renamed this task from Syntax error in PHP test coverage CI job to Syntax error in PHP test coverage CI job due to outdated dependency of phpunit-patch-coverage.Thu, Nov 10, 9:39 PM
Jdforrester-WMF closed this task as Resolved.
Jdforrester-WMF assigned this task to Reedy.

Change 855716 merged by jenkins-bot:

[integration/config@master] jjb: Switch quibble-buster-php74-coverage jobs to have phpunit-patch-coverage

https://gerrit.wikimedia.org/r/855716

Thanks for the quick fix! However, after commenting check coverage, now I get

rsync: [sender] change_dir "/castor-mw-ext-and-skins/master/mwext-phpunit-coverage-patch-docker" (in caches) failed: No such file or directory (2)

Is it a regression from this change, an unrelated issue, or something I don’t have to worry about as it’ll go away by itself?

Thanks for the quick fix! However, after commenting check coverage, now I get

rsync: [sender] change_dir "/castor-mw-ext-and-skins/master/mwext-phpunit-coverage-patch-docker" (in caches) failed: No such file or directory (2)

Is it a regression from this change, an unrelated issue, or something I don’t have to worry about as it’ll go away by itself?

If it otherwise works, I'd probably just ignore it!

It still reported a decrease in coverage, and this was the first thing after which it said set -o pipefail, so I thought this made the job fail… Am I wrong? Anyways, it’s certainly not a big deal, since coverage reports make no sense until T315812 is fixed.

There's a lot of noise in the test logs, which can be false positives...

But this part is fairly clear (as you say, because there's no test), why it's failing:

15:11:36 INFO:quibble.commands:>>> Start: User commands: mwext-phpunit-coverage-patch
15:11:36 INFO:quibble.commands:User commands, working directory: /workspace/src
15:11:36 INFO:quibble.commands:mwext-phpunit-coverage-patch
15:11:36 ++ basename mediawiki/extensions/DoubleWiki
15:11:36 + EXT_NAME=DoubleWiki
15:11:36 WARNING:backend.ChromeWebDriver:[1668118289.359][SEVERE]: bind() failed: Cannot assign requested address (99)
15:11:36 + cd /workspace/src/extensions/DoubleWiki
15:11:36 + phpunit-suite-edit /workspace/src/tests/phpunit/suite.xml --cover-extension DoubleWiki
15:11:36 + exec phpunit-patch-coverage check --command 'php -d extension=pcov.so -d pcov.enabled=1 -d pcov.directory=/workspace/src/extensions/DoubleWiki -d pcov.exclude='\''@(tests|vendor)@'\'' -d pcov.initial.files=3000 "$MW_INSTALL_PATH"/tests/phpunit/phpunit.php' --html /workspace/log/coverage.html
15:11:36 Finding coverage difference in 62c8dd6b3d2de55ac62857328e9988c473ced82f
15:11:36 
15:11:36 In Finder.php line 592:
15:11:36                                                  
15:11:36   The "tests/phpunit" directory does not exist.  
15:11:36                                                  
15:11:36 
15:11:36 check [--sha1 [SHA1]] [--test-dir TEST-DIR] [--html [HTML]] [--command COMMAND]
15:11:36 
15:11:36 INFO:quibble.commands:<<< Finish: User commands: mwext-phpunit-coverage-patch, in 0.254 s
15:11:36 INFO:backend.ChromeWebDriver:Terminating ChromeWebDriver
15:11:36 INFO:backend.Xvfb:Terminating Xvfb
15:11:36 INFO:backend.MySQL:Terminating MySQL
15:11:36 Traceback (most recent call last):
15:11:36   File "/usr/local/bin/quibble", line 10, in <module>
15:11:36     sys.exit(main())
15:11:36   File "/usr/local/lib/python3.7/dist-packages/quibble/cmd.py", line 803, in main
15:11:36     cmd.execute(plan, dry_run=args.dry_run)
15:11:36   File "/usr/local/lib/python3.7/dist-packages/quibble/cmd.py", line 514, in execute
15:11:36     quibble.commands.execute_command(command)
15:11:36   File "/usr/local/lib/python3.7/dist-packages/quibble/commands.py", line 26, in execute_command
15:11:36     command.execute()
15:11:36   File "/usr/local/lib/python3.7/dist-packages/quibble/commands.py", line 971, in execute
15:11:36     env=userscripts_env,
15:11:36   File "/usr/lib/python3.7/subprocess.py", line 347, in check_call
15:11:36     raise CalledProcessError(retcode, cmd)
15:11:36 subprocess.CalledProcessError: Command 'mwext-phpunit-coverage-patch' returned non-zero exit status 1.
15:11:36 Build step 'Execute shell' marked build as failure
15:11:36 [PostBuildScript] - [INFO] Executing post build scripts.
15:11:36 [mwext-phpunit-coverage-patch-docker] $ /bin/bash /tmp/jenkins1074967713143357052.sh
15:11:36 + set -o pipefail
15:11:37 ++ pwd
15:11:37 + exec docker run --entrypoint=/bin/rm --volume /srv/jenkins/workspace/mwext-phpunit-coverage-patch-docker/log:/log --security-opt seccomp=unconfined --init --rm --label jenkins.job=mwext-phpunit-coverage-patch-docker --label jenkins.build=74930 --env-file /dev/fd/63 docker-registry.wikimedia.org/buster:latest -fR /log/rawSeleniumVideoGrabs
15:11:37 ++ /usr/bin/env
15:11:37 ++ egrep -v '^(HOME|SHELL|PATH|LOGNAME|MAIL)='
15:11:38 [PostBuildScript] - [INFO] Executing post build scripts.
15:11:38 [mwext-phpunit-coverage-patch-docker] $ /bin/bash -xe /tmp/jenkins510680551843797393.sh
15:11:38 + find log/ -name 'mw-debug-*.log' -exec gzip '{}' +

It's probably just the wrapper handling that takes any failure as a decrease in test coverage

Oh, really, I should have scrolled to the bottom… Thanks!