forked from glpi-project/glpi
-
Notifications
You must be signed in to change notification settings - Fork 0
272 lines (267 loc) · 10.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
name: "GLPI CI"
on:
# Runs test suite when a new commit is pushed on "main" and "*/bugfixes" branches
# and when a new tag is created
push:
branches:
- main
- '*/bugfixes'
- 'feature/*'
- 'fix/*'
- 'security/*'
tags:
- '*'
# Runs test suite when a PR is opened or synchronyzed
pull_request:
# Runs test suite every night
schedule:
- cron: '0 0 * * *'
# Enable manual run
workflow_dispatch:
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
lint:
# Do not run scheduled lint on tier repositories
if: github.repository == 'glpi-project/glpi' || github.event_name != 'schedule'
name: "Lint on PHP ${{ matrix.php-version }}"
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
include:
- {php-version: "8.2"} # Lint on lower PHP version to detected too early usage of new syntaxes
- {php-version: "8.3"} # Lint on higher PHP version to detected deprecated elements usage
env:
COMPOSE_FILE: ".github/actions/docker-compose-app.yml"
APPLICATION_ROOT: "${{ github.workspace }}"
PHP_IMAGE: "githubactions-php-apache:${{ matrix.php-version }}"
UPDATE_FILES_ACL: true
steps:
- name: "Set env"
run: |
echo "APP_CONTAINER_HOME=${{ runner.temp }}/app_home" >> $GITHUB_ENV
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Restore dependencies cache"
uses: actions/cache@v4
with:
path: |
${{ env.APP_CONTAINER_HOME }}/.composer/cache/
${{ env.APP_CONTAINER_HOME }}/.npm/_cacache/
key: "app_home_deps-${{ matrix.php-version }}-${{ hashFiles('composer.lock', 'package-lock.json') }}"
restore-keys: |
app_home_deps-${{ matrix.php-version }}-
app_home_deps-
- name: "Restore lint cache"
uses: actions/cache@v4
with:
path: |
${{ env.APP_CONTAINER_HOME }}/phpcs.cache
key: "app_home_lint-${{ matrix.php-version }}-${{ github.base_ref || github.ref }}"
restore-keys: |
app_home_lint-${{ matrix.php-version }}
app_home_lint-
- name: "Initialize containers"
run: |
.github/actions/init_containers-start.sh
- name: "Show versions"
run: |
.github/actions/init_show-versions.sh
- name: "Force used PHP version"
run: |
docker compose exec -T app composer config --unset platform.php
docker compose exec -T app composer require "php:>=${{ matrix.php-version }}" --ignore-platform-req=php+ --no-install --no-scripts
- name: "Build dependencies / translations"
run: |
docker compose exec -T app .github/actions/init_build.sh
- name: "PHP lint"
if: "${{ success() || failure() }}"
run: |
docker compose exec -T app .github/actions/lint_php-lint.sh
- name: "Twig lint"
if: "${{ success() || failure() }}"
run: |
docker compose exec -T app .github/actions/lint_twig-lint.sh
- name: "JS lint"
if: "${{ success() || failure() }}"
run: |
docker compose exec -T app .github/actions/lint_js-lint.sh
- name: "SCSS lint"
if: "${{ success() || failure() }}"
run: |
docker compose exec -T app .github/actions/lint_scss-lint.sh
- name: "Misc lint"
if: "${{ success() || failure() }}"
run: |
docker compose exec -T app .github/actions/lint_misc-lint.sh
generate-tests-matrix:
# Do not run scheduled tests on tier repositories
if: github.repository == 'glpi-project/glpi' || github.event_name != 'schedule'
name: "Generate tests matrix"
runs-on: "ubuntu-latest"
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
steps:
- name: "Generate matrix"
id: "generate-matrix"
run: |
if [[ "${{ github.event_name }}" = "workflow_dispatch" || ( "${{ github.ref_type }}" = "branch" && "${{ github.ref_name }}" =~ ^(main|.*/bugfixes)$ ) || "${{ github.ref_type }}" = "tag" ]]; then
MATRIX='
{
"include": [
{"php-version": "8.3", "db-image": "mariadb:11.4"},
{"php-version": "8.3", "db-image": "mysql:8.4"},
{"php-version": "8.2", "db-image": "mariadb:11.4"},
{"php-version": "8.3", "db-image": "mariadb:10.5"},
{"php-version": "8.3", "db-image": "percona:8.0"}
]
}
'
else
MATRIX='
{
"include": [
{"php-version": "8.3", "db-image": "mariadb:11.4"},
{"php-version": "8.3", "db-image": "mysql:8.4"}
]
}
'
fi
echo "matrix=$(echo $MATRIX | jq -c .)" >> $GITHUB_OUTPUT
tests:
# Do not run scheduled tests on tier repositories
if: github.repository == 'glpi-project/glpi' || github.event_name != 'schedule'
name: "Test on PHP ${{ matrix.php-version }} using ${{ matrix.db-image }}"
needs: "generate-tests-matrix"
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-tests-matrix.outputs.matrix) }}
env:
COMPOSE_FILE: ".github/actions/docker-compose-app.yml:.github/actions/docker-compose-services.yml"
APPLICATION_ROOT: "${{ github.workspace }}"
DB_IMAGE: "githubactions-${{ matrix.db-image }}"
PHP_IMAGE: "githubactions-php-apache:${{ matrix.php-version }}"
UPDATE_FILES_ACL: true
steps:
- name: "Set env"
run: |
echo "APP_CONTAINER_HOME=${{ runner.temp }}/app_home" >> $GITHUB_ENV
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Restore dependencies cache"
uses: actions/cache@v4
with:
path: |
${{ env.APP_CONTAINER_HOME }}/.composer/cache/
${{ env.APP_CONTAINER_HOME }}/.npm/_cacache/
key: "app_home_deps-${{ matrix.php-version }}-${{ hashFiles('composer.lock', 'package-lock.json') }}"
restore-keys: |
app_home_deps-${{ matrix.php-version }}-
app_home_deps-
- name: "Initialize containers"
run: |
.github/actions/init_containers-start.sh
- name: "Show versions"
run: |
.github/actions/init_show-versions.sh
- name: "Build dependencies / translations"
run: |
docker compose exec -T app .github/actions/init_build.sh
- name: "Install DB tests"
if: "${{ success() || failure() }}"
run: |
docker compose exec -T app .github/actions/test_install.sh
- name: "Update DB tests (from 0.85.5, not using utf8mb4)"
if: "${{ success() || failure() }}"
run: |
.github/actions/init_initialize-0.85.5-db.sh
docker compose exec -T app .github/actions/test_update-from-older-version.sh
- name: "Update DB tests (from 9.5, using utf8mb4)"
if: "${{ success() || failure() }}"
run: |
.github/actions/init_initialize-9.5-db.sh
docker compose exec -T app .github/actions/test_update-from-9.5.sh
- name: "PHPUnit tests"
if: "${{ success() || failure() }}"
run: |
docker compose exec -T app .github/actions/test_tests-phpunit.sh
- name: "Functional tests"
if: "${{ success() || failure() }}"
run: |
docker compose exec -T app .github/actions/test_tests-functional.sh
- name: "Cache tests"
if: "${{ success() || failure() }}"
run: |
docker compose exec -T app .github/actions/test_tests-cache.sh
- name: "LDAP tests"
if: "${{ success() || failure() }}"
run: |
.github/actions/init_initialize-ldap-fixtures.sh
docker compose exec -T app .github/actions/test_tests-ldap.sh
- name: "IMAP tests"
if: "${{ success() || failure() }}"
run: |
.github/actions/init_initialize-imap-fixtures.sh
docker compose exec -T app .github/actions/test_tests-imap.sh
- name: "Javascript tests"
if: "${{ success() || failure() }}"
run: |
docker compose exec -T app .github/actions/test_javascript.sh
e2e:
# Do not run scheduled tests on tier repositories
if: github.repository == 'glpi-project/glpi' || github.event_name != 'schedule'
name: "E2E and web tests using latest PHP and MariaDB versions"
runs-on: "ubuntu-latest"
env:
COMPOSE_FILE: ".github/actions/docker-compose-app.yml:.github/actions/docker-compose-services.yml"
APPLICATION_ROOT: "${{ github.workspace }}"
DB_IMAGE: "githubactions-mariadb:10.11"
PHP_IMAGE: "githubactions-php-apache:8.3"
UPDATE_FILES_ACL: true
steps:
- name: "Set env"
run: |
echo "APP_CONTAINER_HOME=${{ runner.temp }}/app_home" >> $GITHUB_ENV
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Restore dependencies cache"
uses: actions/cache@v4
with:
path: |
${{ env.APP_CONTAINER_HOME }}/.composer/cache/
${{ env.APP_CONTAINER_HOME }}/.npm/_cacache/
key: "app_home_deps-8.3-${{ hashFiles('composer.lock', 'package-lock.json') }}"
restore-keys: |
app_home_deps-8.3-
app_home_deps-
- name: "Initialize containers"
run: |
.github/actions/init_containers-start.sh
- name: "Show versions"
run: |
.github/actions/init_show-versions.sh
- name: "Build dependencies / translations"
run: |
docker compose exec -T app .github/actions/init_build.sh
- name: "Install DB tests"
if: "${{ success() || failure() }}"
run: |
docker compose exec -T app .github/actions/test_install.sh
- name: "WEB tests"
if: "${{ success() || failure() }}"
run: |
docker compose exec -T app .github/actions/test_tests-web.sh
- name: "E2E tests"
if: "${{ success() || failure() }}"
id: "e2e"
run: |
docker compose exec -T app .github/actions/test_tests-e2e.sh
- name: "Upload Cypress screenshots"
if: "${{ failure() && steps.e2e.conclusion == 'failure' }}"
uses: actions/upload-artifact@v4
with:
name: cypress-screenshots
path: tests/cypress/screenshots