Split the CI workflow into static analysis and tests

オープン 初心者向け
#696 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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 と3つのツール)と、tests ジョブに分割します。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分
マージ済み PR(30日)
52

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

quantum-php/framework のほかの issue

quantum-php/framework の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。