Skip to content

Commit 4bffa22

Browse files
committed
Refactor CI workflow for improved coverage and efficiency
Updated matrix strategy to better support PHP versions and dependencies across different OSes. Added Redis setup steps for all platforms, adjusted service configurations, optimized Composer caching, and streamlined conditional logic for clarity. Enhanced CI execution time and reliability.
1 parent 34b3488 commit 4bffa22

1 file changed

Lines changed: 57 additions & 36 deletions

File tree

.github/workflows/continuous-integration.yml

Lines changed: 57 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ on:
44
push:
55
paths-ignore:
66
- '**/*.md'
7+
- '**/*.txt'
8+
- 'LICENSE'
79
pull_request:
810
paths-ignore:
911
- '**/*.md'
12+
- '**/*.txt'
13+
- 'LICENSE'
1014
workflow_dispatch:
1115

1216
env:
@@ -17,109 +21,126 @@ jobs:
1721
phpunit:
1822
name: PHPUnit (${{ matrix.os }} - PHP ${{ matrix.php-version }} - ${{ matrix.dependencies }})
1923
runs-on: ${{ matrix.os }}
24+
timeout-minutes: 20
2025
strategy:
2126
fail-fast: false
2227
matrix:
2328
include:
24-
# Ubuntu: 全てのPHPバージョンでテスト
29+
# Ubuntu: Test all PHP versions
2530
- os: ubuntu-latest
26-
php-version: 8.1
31+
php-version: "8.1"
2732
dependencies: highest
2833
- os: ubuntu-latest
29-
php-version: 8.2
34+
php-version: "8.2"
3035
dependencies: lowest
3136
- os: ubuntu-latest
32-
php-version: 8.2
37+
php-version: "8.2"
3338
dependencies: highest
3439
- os: ubuntu-latest
35-
php-version: 8.3
40+
php-version: "8.3"
3641
dependencies: lowest
3742
- os: ubuntu-latest
38-
php-version: 8.3
43+
php-version: "8.3"
3944
dependencies: highest
4045
- os: ubuntu-latest
41-
php-version: 8.4
46+
php-version: "8.4"
4247
dependencies: lowest
4348
- os: ubuntu-latest
44-
php-version: 8.4
49+
php-version: "8.4"
4550
dependencies: highest
51+
# Windows: Latest PHP only for CI speed
4652
- os: windows-latest
47-
php-version: 8.4
53+
php-version: "8.4"
4854
dependencies: lowest
4955
- os: windows-latest
50-
php-version: 8.4
56+
php-version: "8.4"
5157
dependencies: highest
58+
# macOS: Latest PHP only for CI speed
5259
- os: macos-latest
53-
php-version: 8.4
60+
php-version: "8.4"
5461
dependencies: lowest
5562
- os: macos-latest
56-
php-version: 8.4
63+
php-version: "8.4"
5764
dependencies: highest
5865

5966
services:
6067
redis:
61-
image: redis
62-
ports: [6379:6379]
68+
image: redis:7-alpine
69+
ports:
70+
- 6379:6379
6371
options: >-
6472
--health-cmd "redis-cli ping"
6573
--health-interval 10s
6674
--health-timeout 5s
6775
--health-retries 3
6876
6977
steps:
70-
- name: Check out repository
78+
- name: Checkout repository
7179
uses: actions/checkout@v4
7280

73-
- name: Setup PHP ${{ matrix.php-version }}
74-
uses: shivammathur/setup-php@v2
75-
with:
76-
php-version: ${{ matrix.php-version }}
77-
coverage: pcov
78-
ini-values: zend.assertions=1
79-
tools: composer
81+
- name: Setup Redis (Ubuntu)
82+
if: runner.os == 'Linux'
83+
run: |
84+
# Use Redis service container - just verify connection
85+
redis-cli -h localhost -p 6379 ping
8086
81-
- name: Start Redis on Windows
87+
- name: Setup Redis (Windows)
8288
if: runner.os == 'Windows'
89+
shell: powershell
8390
run: |
91+
# Quick Redis setup for CI testing
8492
$ProgressPreference = "SilentlyContinue"
85-
Invoke-WebRequest -Uri https://github.com/microsoftarchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.zip -OutFile redis.zip
86-
Expand-Archive redis.zip -DestinationPath redis
87-
Start-Process redis/redis-server.exe -WindowStyle Hidden
88-
Start-Sleep 5
93+
Invoke-WebRequest -Uri "https://github.com/microsoftarchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.zip" -OutFile "redis.zip"
94+
Expand-Archive "redis.zip" -DestinationPath "redis"
95+
Start-Process -FilePath "redis/redis-server.exe" -WindowStyle Hidden
96+
Start-Sleep -Seconds 8
97+
redis/redis-cli.exe ping
8998
90-
- name: Start Redis on macOS
99+
- name: Setup Redis (macOS)
91100
if: runner.os == 'macOS'
92101
run: |
102+
# Fast Redis setup for CI
93103
brew install redis
94104
brew services start redis
95105
sleep 5
106+
redis-cli ping
96107
97-
- name: Cache dependencies
108+
- name: Setup PHP ${{ matrix.php-version }}
109+
uses: shivammathur/setup-php@v2
110+
with:
111+
php-version: ${{ matrix.php-version }}
112+
coverage: pcov
113+
ini-values: zend.assertions=1
114+
tools: composer
115+
extensions: redis
116+
117+
- name: Cache Composer dependencies
98118
uses: actions/cache@v4
99119
with:
100120
path: ~/.composer/cache
101121
key: ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
102122
restore-keys: |
103123
${{ runner.os }}-php-${{ matrix.php-version }}-composer-
104124
105-
- name: Configure dependency resolution
125+
- name: Install dependencies
106126
run: |
107127
composer config platform --unset
108-
109-
- name: Update dependencies
110-
run: composer update ${{ matrix.dependencies == 'lowest' && '--prefer-lowest' || '' }} ${{ env.COMPOSER_FLAGS }}
128+
composer update ${{ matrix.dependencies == 'lowest' && '--prefer-lowest' || '' }} ${{ env.COMPOSER_FLAGS }}
111129
112130
- name: Run PHPUnit tests
113131
run: ./vendor/bin/phpunit --coverage-clover=coverage.xml
114132

115133
- name: Upload coverage report
134+
# Only upload coverage once to avoid duplication
135+
if: matrix.os == 'ubuntu-latest' && matrix.php-version == '8.4' && matrix.dependencies == 'highest'
116136
uses: codecov/codecov-action@v4
117137
with:
118138
files: coverage.xml
119-
fail_ci_if_error: true
139+
fail_ci_if_error: false
120140

121-
- name: Prepare and run demo
122-
if: ${{ env.SCRIPT != '' && matrix.os == 'ubuntu-latest' }}
141+
- name: Run demo script
142+
# Only run demo on one matrix combination to save CI time
143+
if: env.SCRIPT != '' && matrix.os == 'ubuntu-latest' && matrix.php-version == '8.4' && matrix.dependencies == 'highest'
123144
run: |
124145
composer require doctrine/cache:"^1.12" --no-update
125146
composer update ${{ env.COMPOSER_FLAGS }}

0 commit comments

Comments
 (0)