Split the CI workflow into static analysis and tests

Aperta Adatta ai principianti
#696 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
github-actions, php, yaml
Ambito
ci-cd

Direzione di ricerca

Leggi .github/workflows/php.yml dall'inizio alla fine e annota la matrice, i blocchi dei servizi Memcached/Redis, il passaggio di cache e l'ordine dei passaggi PHP-CS-Fixer, PHPStan, Rector, test e coverage. Dividi l'unico job in un job static-analysis (PHP 8.2, senza servizi, composer validate --strict più i tre strumenti) e in un job tests che mantenga la matrice 8.2/8.3/8.4, i servizi, i test e il caricamento della coverage limitato a 8.2. Inoltre, indicizza la cache di Composer per versione di PHP su composer.json e porta actions/checkout e actions/cache alle versioni per Node.js 24, lasciando invariati trigger e flag dei test. È completato quando entrambi i job compaiono e passano in una pull request, l'analisi statica viene eseguita una sola volta e il caricamento della coverage avviene una sola volta.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

tech debt testing

Summary

.github/workflows/php.yml runs one job for each PHP version (8.2, 8.3 and 8.4), and each job runs everything in a row: it starts Memcached and Redis, installs the dependencies, runs PHP-CS-Fixer, PHPStan and Rector, runs the tests and uploads the coverage. Split it into a static analysis job that runs once and a test job that runs for each PHP version.

Problems

  • Static analysis runs three times with the same result. PHP-CS-Fixer, PHPStan and Rector check the source, not the runtime: PHPStan analyses it as PHP 8.2 (phpVersion: 80200) and Rector uses the PHP 8.2 level set, whatever PHP runs them. PHPStan is the slowest of them.
  • A style or analysis failure hides the test result. The steps run in order, so a PHP-CS-Fixer finding stops the job before the tests run.
  • The coverage is uploaded three times, once per PHP version.
  • The static checks start Memcached and Redis, which they do not use.
  • The Composer cache is keyed on composer.lock, which the repository does not track, so all PHP versions share one cache key.
  • actions/checkout@v4 and actions/cache@v4 run on Node.js 20, which GitHub is retiring on its runners.

Change

Two jobs in php.yml, which run in parallel:

  1. static-analysis: once, on PHP 8.2, without services: composer validate --strict, PHP-CS-Fixer, PHPStan, Rector.
  2. tests: the matrix PHP 8.2, 8.3 and 8.4 with Memcached and Redis: the tests, and the coverage upload from PHP 8.2 only.

Also: a Composer cache key per PHP version based on composer.json, and the Node.js 24 versions of actions/checkout and actions/cache.

The triggers (push to master and *.x, every pull_request) and the test flags (--fail-on-warning --fail-on-risky) stay as they are. Branch protection requires only the Scrutinizer check, so the new job names need no change there.

The change applies from 3.3.0 on, on master; the release lines keep their current workflow.

Out of scope

  • Other PHP versions or operating systems in the matrix.
Lingua principale
PHP
Stelle
44
Fork
22
Merge medio
2h 57m
PR unite (30g)
52

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di quantum-php/framework

Tutte le issue di quantum-php/framework

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.