-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (137 loc) · 5.08 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
162
163
164
165
name: 'Run tests'
on:
pull_request:
paths:
- '**/*.php'
- '.github/workflows/*'
push:
paths:
- '**/*.php'
- '.github/workflows/*'
jobs:
cs:
name: 'Check coding style'
runs-on: 'ubuntu-22.04'
steps:
- name: 'Checkout current revision'
uses: 'actions/checkout@v3'
- name: 'Setup PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '8.1'
tools: 'composer'
extensions: 'mbstring, intl'
coverage: 'none'
- name: 'Discover Composer cache directory'
id: 'cachedir'
run: 'echo "::set-output name=path::$(composer global config cache-dir)"'
- name: 'Share Composer cache across runs'
uses: 'actions/cache@v3'
with:
path: '${{ steps.cachedir.outputs.path }}'
key: "composer-${{ github.job }}-${{ hashFiles('**/composer.json') }}"
restore-keys: |
composer-${{ github.job }}-
composer-
- name: 'Install dependencies with Composer'
run: 'composer install --prefer-dist --no-interaction'
- name: 'Run PHP CodeSniffer'
run: 'composer run-script cs-check -- -n'
stan:
name: 'Static code analyzer'
runs-on: 'ubuntu-22.04'
continue-on-error: true
steps:
- name: 'Checkout current revision'
uses: 'actions/checkout@v3'
- name: 'Setup PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '8.1'
tools: 'composer, phpstan'
extensions: 'mbstring, intl'
coverage: 'none'
- name: 'Discover Composer cache directory'
id: 'cachedir'
run: 'echo "::set-output name=path::$(composer global config cache-dir)"'
- name: 'Share Composer cache across runs'
uses: 'actions/cache@v3'
with:
path: '${{ steps.cachedir.outputs.path }}'
key: "composer-${{ github.job }}-${{ hashFiles('**/composer.json') }}"
restore-keys: |
composer-${{ github.job }}-
composer-
- name: 'Install dependencies with Composer'
run: 'composer install --prefer-dist --no-interaction'
- name: 'Run PHP STAN'
run: |
phpstan analyse --no-progress src
unit:
name: 'Run unit tests'
if: "!contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]')"
runs-on: 'ubuntu-22.04'
strategy:
fail-fast: false
matrix:
php:
- '8.1'
- '8.2'
db:
- '{"vendor": "MySQL 8.0", "pdo": "mysql", "dsn": "mysql://bedita:[email protected]:3306/bedita", "image": "mysql:8.0", "options": "--health-cmd \"mysqladmin ping -h localhost\" --health-interval 10s --health-timeout 5s --health-retries 5"}'
- '{"vendor": "MySQL 5.7", "pdo": "mysql", "dsn": "mysql://bedita:[email protected]:3306/bedita?realVendor=mysql5.7", "image": "mysql:5.7", "options": "--health-cmd \"mysqladmin ping -h localhost\" --health-interval 10s --health-timeout 5s --health-retries 5"}'
env:
PHP_VERSION: '${{ matrix.php }}'
DB_VENDOR: '${{ fromJson(matrix.db).vendor }}'
db_dsn: '${{ fromJson(matrix.db).dsn }}'
services:
db:
image: '${{ fromJson(matrix.db).image }}'
env:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_USER: 'bedita'
MYSQL_PASSWORD: 'bedita'
MYSQL_DATABASE: 'bedita'
POSTGRES_USER: 'bedita'
POSTGRES_PASSWORD: 'bedita'
POSTGRES_DB: 'bedita'
ports:
- '3306:3306'
- '5432:5432'
options: '${{ fromJson(matrix.db).options }}'
steps:
- name: 'Checkout current revision'
uses: 'actions/checkout@v3'
- name: 'Setup PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '${{ matrix.php }}'
tools: 'composer'
extensions: 'mbstring, intl, pdo_${{ fromJson(matrix.db).pdo }}'
coverage: 'pcov'
ini-values: 'pcov.directory=., pcov.exclude="~vendor~"'
- name: 'Discover Composer cache directory'
id: 'cachedir'
run: 'echo "::set-output name=path::$(composer global config cache-dir)"'
- name: 'Share Composer cache across runs'
uses: 'actions/cache@v3'
with:
path: '${{ steps.cachedir.outputs.path }}'
key: "composer-${{ matrix.php }}-${{ hashFiles('**/composer.json') }}"
restore-keys: |
composer-${{ matrix.php }}-
composer-
- name: 'Install dependencies with Composer'
run: 'composer install --prefer-dist --no-interaction'
- name: 'Run PHPUnit'
run: 'vendor/bin/phpunit --coverage-clover=clover.xml'
- name: 'Export coverage results'
uses: 'codecov/codecov-action@v3'
with:
file: './clover.xml'
env_vars: PHP_VERSION,DB_VENDOR
- name: 'Archive code coverage results'
uses: 'actions/upload-artifact@v3'
with:
name: 'PHP ${{ matrix.php }} with ${{ fromJson(matrix.db).vendor }}'
path: 'clover.xml'