Page MenuHomePhabricator

Investigate tooling for enforcing architectural boundaries
Closed, ResolvedPublic

Description

T286029 has a nice list already. There also used to be a similar check in place in Wikibase.git to ensure view/ doesn't depend on repo/ or client/, but that may no longer exist.

Event Timeline

Change 786278 had a related patch set uploaded (by Jakob; author: Jakob):

[mediawiki/extensions/Wikibase@master] REST: Enforce architectural boundaries with phparch

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

I took a brief look into PHPArch. I liked how simple and expressive it is, and got a proof of concept (sort of) working quite easily. The main issue is that the version of the library that supports PHP 7.2 is incompatible one of our other dependencies. This could probably be fixed upstream if we really wanted to use this library. The issue goes away as soon as we can use PHP 7.4 in CI.

11:19:35     - Root composer.json requires j6s/phparch ^1.2.0 -> satisfiable by j6s/phparch[1.2.0].
11:19:35     - j6s/phparch 1.2.0 requires thecodingmachine/safe ^0.1.15 -> found thecodingmachine/safe[v0.1.15, v0.1.16] but it conflicts with your root composer.json require (1.3.3).

There were some other awkward bits but maybe I just didn't use it the right way:

  • how to tell it that I'm ok with depending on PHP core classes. I explicitly allowed them one by one.
  • how to declare multiple allowed dependencies of a component. I ended up specifying a "main" dependency with $component->mustOnlyDependOn(...) and then adding additional ones via $component->isAllowedToDependOn(...).

Other than that it worked well and is easy to use. Example patch is here: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/786278

Change 786278 abandoned by Jakob:

[mediawiki/extensions/Wikibase@master] REST: Enforce architectural boundaries with phparch

Reason:

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

Change 786278 restored by Jakob:

[mediawiki/extensions/Wikibase@master] REST: Enforce architectural boundaries with phparch

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

Change 786278 abandoned by Jakob:

[mediawiki/extensions/Wikibase@master] REST: Enforce architectural boundaries with phparch

Reason:

phparch is no longer maintained

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

Jakob_WMDE claimed this task.

We agreed earlier today that this can now be considered done. We chose PHPat. It's not perfect but it works well enough. Some issues with it are outlined in the commit message of the patch linked below. The patch is already merged and dependency checks for the REST API namespaces are now active in our CI system: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/865577/