Split the CI workflow into static analysis and tests

Đang mở Phù hợp với người mới
#696 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
github-actions, php, yaml
Lĩnh vực
ci-cd

Hướng nghiên cứu

Đọc .github/workflows/php.yml từ đầu đến cuối và ghi lại ma trận, các khối dịch vụ Memcached/Redis, bước cache, cũng như thứ tự các bước PHP-CS-Fixer, PHPStan, Rector, kiểm thử và coverage. Tách job duy nhất thành job static-analysis (PHP 8.2, không có dịch vụ, composer validate --strict cùng ba công cụ) và job tests giữ nguyên ma trận 8.2/8.3/8.4, các dịch vụ, bước kiểm thử và việc tải lên coverage chỉ chạy trên 8.2. Ngoài ra, khóa cache của Composer theo phiên bản PHP dựa trên composer.json, và chuyển actions/checkout cùng actions/cache sang phiên bản dùng Node.js 24; giữ nguyên trigger và các cờ kiểm thử. Hoàn thành khi cả hai job xuất hiện và vượt qua trên một pull request, phần phân tích tĩnh chỉ chạy một lần và việc tải lên coverage cũng chỉ diễn ra một lần.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
PHP
Star
44
Fork
22
Merge trung bình
2 giờ 57 phút
Pull request đã merge (30 ngày)
52

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của quantum-php/framework

Tất cả issue của quantum-php/framework

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.