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 摘要。