Make the last command in .phpunit-base's script overridable
Migrated issue
Reported by: wim leers
Problem/Motivation
There are systemic issues of random failures for contrib modules ever since Drupal 11.2 — perhaps only for contrib modules whose test suite generates enough load/concurrency. Canvas' is definitely one of those. See #3500566: "Directory not empty" warning triggered by something in CI.
Quoting @jonathan1055 at #3571997: CI: auto-retry known random Cypress E2E failures + PHPUnit's dreaded "RecursiveDirectoryIterator failed to open directory" (since Drupal 11.2):
Which means I might have to do what I wrote at the end of #10: override the entire script that https://www.drupal.org/project/gitlab_templates sets
If you can make a good case for having that
EXIT_CODEoptional, set on/off via an environment variable that you control, then Gitlab Templates could implement that, and you would not have to duplicate it all.Or maybe we have a separate "exit code handling" snippet/reference, which Gitlab Templates would provide, but which a project like yours could override. You would just rewrite the small few last lines, not the entire script section.
(Emphasis mine.)
This has proven to be necessary, sadly.
For now, Canvas has had to resort to duplicating the entirety of .phpunit-base's script
Steps to reproduce
Run intensive contrib test suite on Drupal >=11.2 on GitLab CI.
Proposed resolution
Allow contrib modules to inject snippet to auto-retry in .phpunit-base. Basically:
…
- cp /var/log/apache2/test.apache.error.log $CI_PROJECT_DIR/apache.error.log.txt
# Auto-retry when random failures occur due to upstream bugs.
# @see https://www.drupal.org/project/canvas/issues/3571997#comment-16458359
- 'grep "RecursiveDirectoryIterator::__construct(/builds/project/canvas/web/sites/simpletest/.*): Failed to open directory: No such file or directory" $CI_PROJECT_DIR/$_WEB_ROOT/sites/default/files/simpletest/phpunit-*.xml && exit 112 || true'
- exit $EXIT_CODE
+
# Auto-retry when random failures occur due to upstream bugs.
# @see https://www.drupal.org/project/canvas/issues/3571997#comment-16458359
retry:
max: 2
exit_codes: 112
Remaining tasks
TBD
User interface changes
None.
API changes
TBD
Data model changes
TBD
Related issue: Issue #3500566
Related issue: Issue #3571997