-
Notifications
You must be signed in to change notification settings - Fork 0
183 lines (178 loc) · 5.52 KB
/
php.yml
File metadata and controls
183 lines (178 loc) · 5.52 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
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: "PHP Workflow"
on:
workflow_dispatch:
pull_request:
paths: [ "**.php" ]
branches: ["main"]
push:
paths: ["**.php"]
branches: ["main"]
env:
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --no-suggest --ignore-platform-req=php"
jobs:
php-code-checks:
name: "PHP Code Quality Checks"
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
dependencies:
- "locked"
- "highest"
- "lowest"
php-version:
- "8.0"
- "8.1"
operating-system:
- "ubuntu-latest"
steps:
- name: "Checkout Code"
uses: "actions/checkout@v2"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
tools: composer:v2
- name: "Cache Dependencies"
uses: "actions/cache@v2"
with:
path: |
~/.composer/cache
vendor
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
# Our code should work with the highest possible dependencies
- name: "Install Highest Dependencies"
if: ${{ matrix.dependencies == 'highest' }}
run: "composer update ${{ env.COMPOSER_FLAGS }}"
# Our code should work with the lowest possible dependencies
- name: "Install Lowest Dependencies"
if: ${{ matrix.dependencies == 'lowest' }}
run: "composer update --prefer-lowest ${{ env.COMPOSER_FLAGS }}"
# Our code should work with the locked dependencies
- name: "Install Locked Dependencies"
if: ${{ matrix.dependencies == 'locked' }}
run: "composer install ${{ env.COMPOSER_FLAGS }}"
# We only run code style checker on locked
- name: "Run Code Style Checker"
run: "vendor/bin/php-cs-fixer fix --dry-run -v"
if: ${{ matrix.dependencies == 'locked' }}
# We only run static analysis on locked
- name: "Run Static Analysis"
if: ${{ matrix.dependencies == 'locked' }}
run: "vendor/bin/psalm --shepherd --stats"
- name: "Run Test Suite"
run: "vendor/bin/phpunit --exclude-group=postgres"
postgres-tests:
name: "Postgres Test Suite"
runs-on: ${{ matrix.operating-system }}
needs: php-code-checks
env:
PGSQL_HOST: localhost
PGSQL_PORT: 5432
PGSQL_USER: sqlx
PGSQL_PASS: sqlx
PGSQL_DBNM: sqlx
strategy:
matrix:
postgres-version:
- "10-alpine"
- "11-alpine"
- "12-alpine"
- "13-alpine"
- "14-alpine"
- "15-alpine"
php-version:
- "8.0"
operating-system:
- "ubuntu-latest"
services:
postgres:
image: postgres:${{ matrix.postgres-version }}
env:
POSTGRES_USER: sqlx
POSTGRES_PASSWORD: sqlx
POSTGRES_DB: sqlx
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: "Checkout Code"
uses: "actions/checkout@v2"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "8.0"
ini-values: memory_limit=-1
tools: composer:v2
- name: "Cache Dependencies"
uses: "actions/cache@v2"
with:
path: |
~/.composer/cache
vendor
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
- name: "Install Locked Dependencies"
run: "composer install ${{ env.COMPOSER_FLAGS }}"
- name: "Run Postgres Test Suite"
run: "vendor/bin/phpunit --group=postgres"
mysql-tests:
name: "MySQL Test Suite"
runs-on: ${{ matrix.operating-system }}
needs: php-code-checks
env:
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: 3306
MYSQL_USER: sqlx
MYSQL_PASS: sqlx
MYSQL_DBNM: sqlx
strategy:
matrix:
mysql-version:
- "5.6"
- "5.7-debian"
php-version:
- "8.0"
operating-system:
- "ubuntu-latest"
services:
mysql:
image: mysql:${{ matrix.mysql-version }}
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_ROOT_HOST: '%'
MYSQL_DATABASE: sqlx
MYSQL_USER: sqlx
MYSQL_PASSWORD: sqlx
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
ports:
- 3306:3306
steps:
- name: "Checkout Code"
uses: "actions/checkout@v2"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "8.0"
ini-values: memory_limit=-1
tools: composer:v2
- name: "Cache Dependencies"
uses: "actions/cache@v2"
with:
path: |
~/.composer/cache
vendor
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
- name: "Install Locked Dependencies"
run: "composer install ${{ env.COMPOSER_FLAGS }}"
- name: "Run MySQL Test Suite"
run: "vendor/bin/phpunit --group=mysql"