-
Notifications
You must be signed in to change notification settings - Fork 8
153 lines (136 loc) · 6.14 KB
/
Copy pathcontinuous-integration.yml
File metadata and controls
153 lines (136 loc) · 6.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# GitHub Actions workflow specifically designed for running PHPUnit tests
# This workflow is optimized to install only the necessary dependencies for PHPUnit
# and explicitly avoids installing development tools to prevent latest PHP compatibility issues
name: Continuous Integration
on:
push:
paths-ignore:
- '**.md' # Skip workflow on documentation changes only
pull_request:
workflow_dispatch: # Enable manual trigger (inputs can be provided manually here)
workflow_call: # Enable calling from other workflows
inputs:
old_stable:
required: false
type: string
default: '[]' # Default for workflow_call if 'old_stable' input is not provided by the caller.
# Example, if caller wants specific old stables: '["8.0", "8.1"]'
# If caller wants NO old stables, they can pass '[]' or omit it to use this default.
current_stable:
required: true # Required for workflow_call. Example from caller: "8.4" or "8.5"
type: string
script:
required: false
type: string
env: # This env block is for steps and job-level environment settings.
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist --no-plugins"
COMPOSER_UPDATE_FLAGS: ""
# Matrix defaults are defined in the jobs section due to GitHub Actions limitations
# DEFAULT_OLD_STABLE and DEFAULT_CURRENT_STABLE cannot be used in matrix context
jobs:
phpunit:
name: PHPUnit
runs-on: ${{ matrix.os }}
env:
# Define defaults here where they can be used in steps
DEFAULT_OLD_STABLE: '["8.2", "8.3", "8.4"]'
DEFAULT_CURRENT_STABLE: '8.5'
strategy:
fail-fast: false
matrix:
# For workflow_call:
# - If inputs.old_stable is provided by the caller, that value is used.
# - If inputs.old_stable is NOT provided by the caller, its `default: '[]'` in the `inputs` definition is used.
# For push/pull_request/workflow_dispatch (where inputs.old_stable is an empty string "" if not set via dispatch UI):
# - The default is hardcoded here due to GitHub Actions matrix limitations with env variables
php-version: ${{ fromJson(inputs.old_stable || '["8.2", "8.3", "8.4"]') }}
dependencies: [highest, lowest]
os: [ubuntu-latest]
experimental: [false]
include:
# For workflow_call: inputs.current_stable is required and its value is used.
# For push/pull_request/workflow_dispatch (where inputs.current_stable is an empty string "" if not set via dispatch UI):
# - The default is hardcoded here due to GitHub Actions matrix limitations with env variables
- php-version: ${{ inputs.current_stable || '8.5' }}
os: windows-latest
dependencies: highest
experimental: false
- php-version: ${{ inputs.current_stable || '8.5' }}
os: ubuntu-latest
dependencies: highest
experimental: false
# Note: Current stable PHP version with lowest dependencies is intentionally excluded
# to avoid aura/sql compatibility issues with the latest PHP versions
exclude:
# Skip lowest dependencies test for PHP 8.4+ where aura/sql v4 (lowest) is incompatible
- php-version: '8.4'
dependencies: lowest
- php-version: ${{ inputs.current_stable || '8.5' }}
dependencies: lowest
continue-on-error: ${{ matrix.experimental }}
steps:
- name: Disable autocrlf on Windows
if: ${{ contains(matrix.os, 'windows') }}
run: git config --global core.autocrlf false
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: pcov
ini-values: |
zend.assertions=1
memory_limit=512M
opcache.jit=0
opcache.jit_buffer_size=0
opcache.enable=0
opcache.enable_cli=0
extensions: pdo,pdo_mysql,pdo_sqlite
- name: Get composer cache directory
id: composer-cache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json', '**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
${{ runner.os }}-php${{ matrix.php-version }}-composer-
${{ runner.os }}-composer-
- name: Set platform requirements
shell: bash
run: |
composer config platform.php ${{ matrix.php-version }}
- name: Handle lowest dependencies update
if: ${{ matrix.dependencies == 'lowest' }}
shell: bash
run: echo COMPOSER_UPDATE_FLAGS="$COMPOSER_UPDATE_FLAGS --prefer-lowest" >> $GITHUB_ENV
- name: Remove platform config for dependency resolution
if: ${{ matrix.dependencies == 'highest' }}
shell: bash
run: composer config platform --unset
- name: Update dependencies
shell: bash
run: |
composer validate --no-check-all --strict
composer update ${{ env.COMPOSER_UPDATE_FLAGS }} ${{ env.COMPOSER_FLAGS }}
- name: Run test suite
shell: bash
run: vendor/bin/phpunit --coverage-clover=coverage.xml
env:
XDEBUG_MODE: coverage # pcov uses XDEBUG_MODE=coverage for activation
- name: Upload coverage report
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
- name: Run additional script
# Run if inputs.script is not an empty string and also not null (which it can be if not provided in workflow_call)
if: ${{ inputs.script != '' && inputs.script != null }}
shell: bash
run: php ${{ inputs.script }}