Skip to content

Commit 9b7dcd3

Browse files
committed
Refactor CI workflow for improved clarity and flexibility
Simplified dependency resolution, updated caching, and revamped matrix strategy to support more OS combinations. Enhanced readability with consistent naming and conditional logic improvements. Updated actions versions and streamlined demo script execution.
1 parent b942f72 commit 9b7dcd3

1 file changed

Lines changed: 45 additions & 69 deletions

File tree

.github/workflows/continuous-integration.yml

Lines changed: 45 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3,105 +3,81 @@ name: Continuous Integration
33
on:
44
push:
55
paths-ignore:
6-
- '**.md'
6+
- '**/*.md'
77
pull_request:
8+
paths-ignore:
9+
- '**/*.md'
810
workflow_dispatch:
911

1012
env:
11-
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist --no-plugins"
12-
COMPOSER_UPDATE_FLAGS: ""
13-
script: demo/run.php
13+
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
14+
SCRIPT: "demo/run.php"
1415

1516
jobs:
1617
phpunit:
17-
name: PHPUnit
18-
runs-on: ubuntu-latest
19-
services:
20-
redis:
21-
image: redis
22-
ports:
23-
- 6379:6379
24-
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
18+
name: PHPUnit (${{ matrix.os }} - PHP ${{ matrix.php-version }} - ${{ matrix.dependencies }})
19+
runs-on: ${{ matrix.os }}
2520
strategy:
21+
fail-fast: false
2622
matrix:
27-
php-version: [8.2, 8.3, 8.4]
28-
dependencies: [highest, lowest]
29-
os: [ubuntu-latest]
30-
include:
31-
- php-version: 8.1
32-
os: windows-latest
23+
os: [ubuntu-latest, windows-latest, macos-latest]
24+
php-version: [8.1, 8.2, 8.3, 8.4]
25+
dependencies: [lowest, highest]
26+
exclude:
3327
- php-version: 8.1
34-
os: macos-latest
35-
- php-version: 8.2
36-
dependencies: lowest
3728
os: ubuntu-latest
38-
- php-version: 8.2
39-
dependencies: highest
40-
os: ubuntu-latest
41-
- php-version: 8.3
42-
dependencies: highest
43-
os: ubuntu-latest
44-
- php-version: 8.3
45-
dependencies: lowest
46-
os: ubuntu-latest
47-
- php-version: 8.4
48-
dependencies: highest
49-
os: ubuntu-latest
50-
- php-version: 8.4
29+
- php-version: 8.1
5130
dependencies: lowest
52-
os: ubuntu-latest
31+
32+
services:
33+
redis:
34+
image: redis
35+
ports: [6379:6379]
36+
options: >-
37+
--health-cmd "redis-cli ping"
38+
--health-interval 10s
39+
--health-timeout 5s
40+
--health-retries 3
41+
5342
steps:
54-
- name: Checkout
55-
uses: actions/checkout@v3
43+
- name: Check out repository
44+
uses: actions/checkout@v4
5645

5746
- name: Setup PHP ${{ matrix.php-version }}
5847
uses: shivammathur/setup-php@v2
5948
with:
6049
php-version: ${{ matrix.php-version }}
6150
coverage: pcov
6251
ini-values: zend.assertions=1
63-
64-
- name: Get composer cache directory
65-
id: composer-cache
66-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
52+
tools: composer
6753

6854
- name: Cache dependencies
69-
uses: actions/cache@v2
55+
uses: actions/cache@v4
7056
with:
71-
path: ${{ steps.composer-cache.outputs.dir }}
72-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
73-
restore-keys: ${{ runner.os }}-composer-
74-
75-
- name: Handle lowest dependencies update
76-
if: contains(matrix.dependencies, 'lowest')
77-
run: echo COMPOSER_UPDATE_FLAGS=$COMPOSER_UPDATE_FLAGS --prefer-lowest >> $GITHUB_ENV
78-
79-
- name: Handle ignore-platform-reqs dependencies update
80-
if: contains(matrix.dependencies, 'ignore')
81-
run: echo COMPOSER_FLAGS=$COMPOSER_FLAGS --ignore-platform-req=php >> $GITHUB_ENV
57+
path: ~/.composer/cache
58+
key: ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
59+
restore-keys: |
60+
${{ runner.os }}-php-${{ matrix.php-version }}-composer-
8261
83-
- name: Remove platform config to get latest dependencies for current PHP version
84-
if: contains(matrix.dependencies, 'highest') || contains(matrix.dependencies, 'lowest')
85-
run: composer config platform --unset
86-
87-
- name: Allow alpha releases for latest-deps builds to catch problems earlier
88-
if: contains(matrix.dependencies, 'ignore')
89-
run: composer config minimum-stability alpha
62+
- name: Configure dependency resolution
63+
run: |
64+
composer config platform --unset
9065
9166
- name: Update dependencies
92-
run: composer update ${{ env.COMPOSER_UPDATE_FLAGS }} ${{ env.COMPOSER_FLAGS }}
67+
run: composer update ${{ matrix.dependencies == 'lowest' && '--prefer-lowest' || '' }} ${{ env.COMPOSER_FLAGS }}
9368

94-
- name: Run test suite
69+
- name: Run PHPUnit tests
9570
run: ./vendor/bin/phpunit --coverage-clover=coverage.xml
9671

9772
- name: Upload coverage report
9873
uses: codecov/codecov-action@v3
9974
with:
100-
file: ./coverage.xml
101-
102-
- name: Update dependencies for demo
103-
run: composer require doctrine/cache ^1 ${{ env.COMPOSER_UPDATE_FLAGS }} ${{ env.COMPOSER_FLAGS }}
75+
files: coverage.xml
76+
fail_ci_if_error: true
10477

105-
- name: Run additional script
106-
if: ${{ env.script }}
107-
run: php ${{ env.script }}
78+
- name: Prepare and run demo
79+
if: ${{ env.SCRIPT != '' && matrix.os == 'ubuntu-latest' }}
80+
run: |
81+
composer require doctrine/cache:"^1.12" --no-update
82+
composer update ${{ env.COMPOSER_FLAGS }}
83+
php ${{ env.SCRIPT }}

0 commit comments

Comments
 (0)