Skip to content

v0.1.34

Choose a tag to compare

@ogorzalka ogorzalka released this 21 Nov 12:06
74ad4f1

Added

  • promote-report reads PERF-01 and PERF-07. It uses the same static assessment as the Performance budgets step (PerformanceCheck::assess(), which run() now shares): would-block with the problems of the budgets file or of the nightly measures, clean, or not-applicable when the repository declares neither. Without it the two rules showed as no-probe once PERF-01 and PERF-07 became observed.

  • PERF-01 and PERF-07 are observed: a Performance budgets step reads the query budgets and the nightly measures of a repository, without running a site. PERF-01: when the repository has a budgets file (tests/e2e/budgets.json by default, the framework's { "pages": { "home": { "wordpress": 24, "laravel": 0 } } }), the step validates its shape (whole numbers or null), lists the null budgets as measured-only and applies a ratchet: a budget that went up, became null or was removed since the base commit (HEAD^1, or check --budgets-base=REF) fails; a base that is not in the checkout, a file new since the base or an unreadable base file give not compared with <base>: <why>, never a pass that did not compare. PERF-07: when the repository has the nightly measuring spec (tests/e2e/specs/perf-metrics.spec.ts) or declares performance.nightly, the step checks that the measuring file and the comparing script exist, that a workflow has an on: schedule with a cron and runs both, and that the comparison's --tolerance is at most 0.1. A repository that declares neither gets skipped with the reason. The new performance key of .harness.json (budgets, nightly.measure, nightly.compare, nightly.workflow, all optional, paths inside the repository) is read, written by ratchet --update and kept by init. The step is observed by default (Plan::OBSERVED_BY_DEFAULT), so check has 13 steps instead of 12; the catalogue now counts 32 enforced, 6 observed and 2 planned rules. The reusable workflow php-package.yml always checks out two commits (fetch-depth: 2; it was 2 only for a limited mutation scope) so that the budgets can be compared.

  • CONV-02 is observed: a WordPress registration is not described by a raw array in the public API. Architecture\RawRegistrationArrays reads the PSR-4 files with nikic/php-parser (no autoloader) and reports (1) a public method or global function whose array parameter flows into register_post_type(), register_taxonomy(), register_block_type(), register_block_type_from_metadata(), register_rest_route() (their $args) or add_menu_page() / add_submenu_page(), through array operations, local variables and closures, and (2) a public method (interface methods too) named register…, create…, define… or add… about a post type, taxonomy, block, route or menu, with an $args, $arguments, $config, $options or $settings parameter that can hold an array. The infrastructure layer (Infrastructure, Adapter namespaces), non-public methods, @internal code, literal arrays built inside a method and object-typed parameters are not reported; the rule's limits (array stored then registered elsewhere, registration through a wrapper) are in the README. A file that does not parse is listed, never skipped. Registered by tests/Arch.php like CONV-08/09/12 (incomplete with the list, not evaluated when there is no class); the catalogue now counts 32 enforced, 5 observed and 3 planned rules. Measured over the 45 repositories (36 have PHP): 10 reports in 2 repositories (framework 8, entity 2), about 1.0 s in total, 0.21 s for the framework.

  • Mutation on pull requests: only what the pull request changes. check takes --mutation-scope=all|changed|added, which wins over mutation.scope of .harness.json for that run (an unknown value, or the option without value, fails before any gate runs). A limited scope is held to mutation.min, or to MutationSettings::PULL_REQUEST_MINIMUM (50 %) when the file sets none. The reusable workflow php-package.yml has a new optional input mutation-on-pull-request (changed by default, all for the old behaviour): on a pull_request event a repository without mutation.scope runs --mutation-scope=changed --mutation-base=HEAD^1 on the merge commit (checkout depth 2); a checkout that is not a merge commit falls back to the whole repository with a warning instead of counting from the wrong base; every other event mutates everything, so the msi ratchet is still measured on the main branch. A pull request without a PHP source file passes with "nothing to mutate". The Ratchet step says msi was not measured on purpose in a limited run. No job name, needs or if changes. Measured cost: the mutation is 80 to 90 % of the quality job (101 jobs, 33 repositories, 20 November). See Mutation on pull requests in the README for the trade-off (the whole score is no longer measured on a pull request).

  • CONV-08, CONV-09 and CONV-12 are observed: three architecture rules read from the files, which report and never block. CONV-08 (a class is final unless it is an extension point: abstract, a builder named …Builder, a class that uses Macroable, or a parent that another class of the repository extends), CONV-09 (a facade is a thin front: only getFacadeAccessor(), returning Service::class or a binding name; a Service::class of the repository that is a concrete class is reported, a contract is an interface) and CONV-12 (no PHPUnit test class: a concrete class extending a …TestCase with a test method is reported; #[RunInSeparateProcess] / #[RunTestsInSeparateProcesses] and the PHPStan rule tests are the documented exceptions; the Fixtures and Stubs directories are not read). They are read from the tokens (Architecture\SourceTypes, FinalClasses, FacadeClasses, TestClasses), without an autoloader. A rule that the catalogue lists as observed is registered by tests/Arch.php as a test that is marked incomplete, with observed, not blocking: <rule> — N problem(s) and the list, when it finds something (the step stays green) and passes when it finds nothing; enforced in the catalogue makes the same test fail. Measured over the 45 repositories of the ecosystem (a script running the three analyses on each repository's files, without vendor/): CONV-08 reports 671 classes in 20 repositories (framework 400, attributes 82, metabox 54, colt 23, skeleton 19, woocommerce 16, nectar 16, query 12, assets 12, entity 11), CONV-09 4 facades in the framework, CONV-12 13 test classes (meilifacets 11, skeleton 2); about 1.1 s in total over the 45 repositories, 0.33 s for the framework. A rule with nothing to read (no class, no test file) is skipped with not evaluated: <rule> — <reason>. The catalogue now counts 32 enforced, 4 observed and 4 planned rules.

  • type_coverage is measured (CONV-11): check and ratchet count the declarations that carry a native type. Metrics\TypeCoverage reads the PHP of the repository with nikic/php-parser (now a requirement, ^5.6: it was only there through Pest's dev dependencies, and PHPStan and Rector ship it inside their phars), so it needs neither Pest's type-coverage plugin (installed in two repositories out of forty-five) nor an autoloader. It counts the return type of every function and method (constructors and destructors excepted), every parameter (promoted ones once) and every property; mixed is a type; closures and arrow functions are out; %placeholder% markers of theme templates are neutralised; the parameters of the methods that override an untyped method of WordPress (Walker*, WP_Widget; the parent must be the global class, \Walker_Nav_Menu) are left out and reported, because a child cannot narrow them. The files read are the psr-4, psr-0, classmap and files entries of autoload plus src and app, minus vendor, node_modules, tests and Blade. The Ratchet step prints the percentage, the share of returns, parameters and properties, the five files that concentrate the gap and any file that does not parse (never ignored silently); a repository that records type_coverage in its ratchet can no longer lower it, and ratchet --update records it. Measured over the 45 repositories: 97.19 % (18 316 of 18 846 declarations) in 1.5 s, 0.46 s for the framework. CONV-11 stays observed until the floors are recorded.

  • pollora-qa promote-report [--json]: what would block if each observed rule became enforced. For every observed rule of the catalogue, in the current repository: the number of problems and the first five, clean, not applicable (nothing to read) or no probe (an observed rule it cannot measure is listed, never left out). CONV-08, CONV-09 and CONV-12 run the same analyses as their Pest tests, CONV-11 compares the static type count with the recorded type_coverage floor. Read only, no tool run, always exit 0; works without .harness.json. README: Promoting a rule.

  • CONV-08, CONV-09 and CONV-12 can be exempted (allow_rules) before they are promoted. They join RuleExemption::EXEMPTIBLE and the rules named by the Architecture and Tests and architecture steps (Plan::ARCHITECTURE_RULES). While a rule is observed its exemption is accepted, counted by the exempted_rules ceiling and shown (declared, not applied while the rule is observed) but not applied: the rule keeps reporting, and the step does not list it as exempted. Once the catalogue says enforced, the same entry skips the rule with its reason.

Changed

  • A ratchet value that cannot be compared makes .harness.json invalid. coverage, type_coverage and msi must be numbers from 0 to 100, phpstan_level an integer from 0 to 10 or "max", phpstan_baseline and exempted_rules whole numbers from 0. Until now "type_coverage": "95" or 120 was read as "never measured" and silently never compared (InvalidConfig::ratchetValue). None of the 45 repositories holds such a value.
  • A layer shared with an installed package is now judged, on the classes of the repository only, instead of not evaluated. The 0.1.32 compromise skipped ARCH-01, ARCH-03, CONV-03, CONV-05 and CONV-07 on a namespace that a package under vendor/ also maps (the framework lost six CONV-07 tests with pollora/media 0.9). Those rules now receive the explicit list of the classes found in the repository's own PSR-4 directories instead of the namespace: the engine of Pest resolves a class name to its own file only, so the package's classes are never read and ObjectDescriptionBase::$path is never reached. Only a class that the package also has under the same name is left out, with a skipped test … (classes shared with a package) that names it, and a namespace with no class to judge is skipped with the reason. The test names are unchanged. ForeignNamespaces keeps the directories of each foreign prefix (directories) and tells a shadowed class (shadows()), Layers::classesIn() lists the classes of a namespace.
  • The job summary table of check has one more column, Time, between Rules and Result.

Fixed

  • SEC-06 no longer reports a bare constant. $token[0] === T_STRING, a lexer token compared with its tokenizer constant, is a type check, not a secret comparison; it joins the literals, null, numbers and Cls::NAME constants that were already left out. Found by the first run of the rule as a blocking one, on the harness's own code (4 findings, src/Architecture/SourceTypes.php); the fixtures that must be detected still are (43 detections, unchanged), a negative fixture was added, and the self scan of src/ goes from 4 findings to none.

  • Fewer HTTP/2 429 from codeload.github.com during composer install. The Composer steps are authenticated with the job's token (COMPOSER_AUTH, github-oauth), the Composer download cache is restored (and saved by non-pull-request runs), and a pull request's older run is cancelled when a new push arrives. Every job has a timeout-minutes.

Security

  • The workflows pin what they run. php-package.yml, template.yml and ci.yml reference actions/checkout, shivammathur/setup-php, actions/upload-artifact, actions/setup-node and the new actions/cache by the full commit SHA of their tag (tag in a comment), install semgrep==1.186.0 and run ghcr.io/gitleaks/gitleaks:v8.30.1 by digest instead of latest. The one ${{ }} of a step output inside a run: (the downstream job's package name) goes through env:. zizmor 1.32.0: 34 high and 1 informational findings before, none after. Inputs, outputs and job names are unchanged. See Reliability and security of the workflows in the README.