-
Notifications
You must be signed in to change notification settings - Fork 7
161 lines (137 loc) · 5.14 KB
/
test.yml
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
154
155
156
157
158
159
160
161
name: Test
on:
pull_request:
push:
# Allow manually triggering the workflow.
workflow_dispatch:
# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php:
# PHP 5.3 is tested in coverage section
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- '7.4'
- '8.0'
- '8.1'
# PHP 8.2 is tested in coverage section
experimental: [false]
include:
- php: '8.3'
experimental: true
name: "Test on PHP ${{ matrix.php }}"
continue-on-error: ${{ matrix.experimental }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: 'zend.assertions=1, error_reporting=-1, display_errors=On'
coverage: none
tools: cs2pr
# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
- name: Install Composer dependencies - normal
if: ${{ matrix.experimental == false }}
uses: "ramsey/composer-install@v2"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")
# For the PHP "nightly", we need to install with ignore platform reqs as not all dependencies allow it.
- name: Install Composer dependencies - with ignore platform
if: ${{ matrix.experimental == true }}
uses: "ramsey/composer-install@v2"
with:
composer-options: --ignore-platform-reqs
custom-cache-suffix: $(date -u "+%Y-%m")
- name: Lint
run: composer phplint -- --checkstyle | cs2pr
- name: Run unit tests
run: composer phpunit
coverage:
needs: test
# Don't run on forks.
if: github.repository_owner == 'php-parallel-lint' && needs.test.result == 'success'
runs-on: ubuntu-latest
strategy:
matrix:
include:
- php: 5.3
- php: 8.2
name: "Coverage on PHP ${{ matrix.php }}"
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup ini config
id: set_ini
run: |
# On PHP 5.3, short_open_tag needs to be turned on for short open echo tags to be recognized
# a PHP tags. As this only affects PHP 5.3, this is not something of serious concern.
if [ ${{ matrix.php }} == "5.3" ]; then
echo 'PHP_INI=zend.assertions=1, error_reporting=-1, display_errors=On, short_open_tag=On' >> $GITHUB_OUTPUT
else
echo 'PHP_INI=zend.assertions=1, error_reporting=-1, display_errors=On' >> $GITHUB_OUTPUT
fi
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
coverage: xdebug
tools: cs2pr
# Remove the PHPCS standard as it has a minimum PHP requirements of PHP 5.4 and would block install on PHP 5.3.
- name: 'Composer: remove PHPCS'
if: ${{ matrix.php < 5.4 }}
run: composer remove --dev php-parallel-lint/php-code-style --no-update --no-interaction
- name: Install Composer dependencies - normal
uses: "ramsey/composer-install@v2"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")
- name: Lint
run: composer phplint -- --checkstyle | cs2pr
- name: Run the unit tests with code coverage
run: composer coverage
# PHP Coveralls v2 (which supports GH Actions) has a PHP 5.5 minimum, so switch the PHP version.
- name: Switch to PHP latest
if: ${{ success() && matrix.php == '5.3' }}
uses: shivammathur/setup-php@v2
with:
php-version: 'latest'
coverage: none
# Global install is used to prevent a conflict with the local composer.lock.
- name: Install Coveralls
if: ${{ success() }}
run: composer global require php-coveralls/php-coveralls:"^2.6.0" --no-interaction
- name: Upload coverage results to Coveralls
if: ${{ success() }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: php-${{ matrix.php }}
run: php-coveralls -v -x build/logs/clover.xml
coveralls-finish:
needs: coverage
# Don't run on forks.
if: github.repository_owner == 'php-parallel-lint' && needs.coverage.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true