Split the CI workflow into static analysis and tests

未關閉 適合新手
#696 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
72/100
Issue 類型
重構
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
github-actions, php, yaml
領域
ci-cd

研究方向

從頭到尾閱讀 .github/workflows/php.yml,記下矩陣、Memcached/Redis 服務區塊、快取步驟,以及 PHP-CS-Fixer、PHPStan、Rector、測試和覆蓋率步驟的順序。將單一工作拆分為 static-analysis 工作(PHP 8.2,無服務,composer validate --strict 加上三個工具)和 tests 工作,後者保留 8.2/8.3/8.4 矩陣、服務、測試,以及僅在 8.2 上執行的覆蓋率上傳。另外,將 Composer 快取依 PHP 版本以 composer.json 為鍵,並將 actions/checkout 和 actions/cache 升級到 Node.js 24 對應版本,觸發條件和測試旗標維持不變。完成標準是:兩個工作都出現在拉取請求中並通過,靜態分析只執行一次,覆蓋率只上傳一次。

由索引模型根據 Issue 內容生成。

描述

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.
主要語言
PHP
星號
44
分支
22
平均合併
2 小時 57 分鐘
30 天內合併 PR
52

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

quantum-php/framework 的其他 Issue

查看 quantum-php/framework 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。