-
Notifications
You must be signed in to change notification settings - Fork 6
183 lines (167 loc) · 7.4 KB
/
ci.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: CI
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
unit-tests:
name: Unit tests (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-22.04
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
php-versions: ['7.4', '8.0', '8.1', '8.2','8.3']
experimental: [false]
include:
- php-versions: '8.4'
experimental: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Setup PHP, with Composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
coverage: none
extensions: gd
- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Remove unused Composer dependencies
run: composer remove humbug/php-scoper sirbrillig/phpcs-import-detection phpstan/phpstan szepeviktor/phpstan-wordpress --dev --no-interaction --no-update
- name: Get composer cache directory
id: composer-cache
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 }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer update --prefer-dist
- name: Run PHPUnit tests
run: composer run-script test
coverage:
name: Coverage & SonarCloud (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
php-versions: ['8.3']
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Setup PHP, with Composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
coverage: xdebug
extensions: gd
- name: Remove unused Composer dependencies
run: composer remove humbug/php-scoper sirbrillig/phpcs-import-detection szepeviktor/phpstan-wordpress --dev --no-interaction --no-update
- name: Get composer cache directory
id: composer-cache
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 }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer update --prefer-dist
- name: Run PHPUnit tests with coverage generation
run: |
mkdir -p build/logs
composer run-script test -- --coverage-clover build/logs/phpunit.coverage.xml --log-junit=build/logs/phpunit.test-report.xml
- name: Fix code coverage paths for SonarCloud
working-directory: ./build/logs/
run: |
sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' phpunit.coverage.xml
sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' phpunit.test-report.xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
if: env.SONAR_TOKEN != ''
phpcs:
name: Check Coding Standards
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
php-versions: ['8.3']
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup PHP, with Composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
coverage: none
extensions: gd
tools: cs2pr
- name: Remove unused Composer dependencies
run: composer remove humbug/php-scoper --dev --no-interaction --no-update
- name: Get composer cache directory
id: composer-cache
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 }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer update --prefer-dist
- name: Run PHPCS checks
run: vendor/bin/phpcs -q src/ --extensions=php --report=checkstyle | cs2pr
phpstan:
name: Static Analysis
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
php-versions: ['8.3']
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup PHP, with Composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
coverage: none
extensions: gd
- name: Remove unused Composer dependencies
run: composer remove humbug/php-scoper sirbrillig/phpcs-import-detection --dev --no-interaction --no-update
- name: Get composer cache directory
id: composer-cache
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 }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer update --prefer-dist
- name: Run PHPStan
run: composer run-script phpstan
spellchecking:
name: Spellchecking
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run typos
uses: crate-ci/typos@master