-
Notifications
You must be signed in to change notification settings - Fork 27
169 lines (158 loc) · 5.7 KB
/
tests.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
# GitHub Actions docs
# https://help.github.com/en/articles/about-github-actions
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
name: CI
on:
push:
branches:
- master
- develop
tags:
- '*'
pull_request:
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.4', '8.2', '8.3-rc']
name: lint (${{ matrix.php-versions }})
env:
extensions: zip
key: cache-v1
steps:
- name: Change dir owner to working user
run: sudo chown -R $USER:$USER $GITHUB_WORKSPACE
- uses: actions/checkout@v4
- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: Cache extensions
uses: actions/cache@v3
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
env:
runner: ubuntu-latest
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
- name: Install dependencies
run: composer install
- name: Check for coding standards violations
run: |
vendor/bin/phpcs
phpunit:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- {php-versions: "7.4", db-image: "mysql:5.7"}
- {php-versions: "8.1", db-image: "mysql:8.0"}
- {php-versions: "8.1", db-image: "mariadb:10.6"}
- {php-versions: "8.1", db-image: "mariadb:11"}
- {php-versions: "8.2", db-image: "mysql:8.0"}
- {php-versions: "8.2", db-image: "mysql:8.1"}
- {php-versions: "8.2", db-image: "mariadb:10.6"}
- {php-versions: "8.2", db-image: "mariadb:11"}
- {php-versions: "8.3-rc", db-image: "mariadb:11"}
name: Unit tests ${{ matrix.php-versions }} ${{ matrix.db-image }}
env:
extensions: zip, hash, fileinfo, mysqli, gd, bz2, xdebug
key: cache-v1
DB: ${{ matrix.db-image }}
services:
# Label used to access the service container
db:
# Docker Hub image
image: ${{ matrix.db-image }}
# Provide env variables for both mysql and pgsql
env:
MYSQL_USER: glpiinventory
MYSQL_PASSWORD: glpi1iventory
MYSQL_ROOT_PASSWORD: glpi1iventory
MYSQL_DATABASE: glpi
# Open network ports
ports:
- 3306:3306
# Set health checks to wait until postgres has started
options: >-
--health-cmd="bash -c 'if [[ -n $(command -v mysqladmin) ]]; then mysqladmin ping; else mariadb-admin ping; fi'"
--health-interval=10s
--health-timeout=5s
--health-retries=10
steps:
- name: Install gettext and mysql-client
run: sudo apt-get install --assume-yes --no-install-recommends --quiet gettext
- name: Change dir owner to working user
run: sudo chown -R $USER:$USER $GITHUB_WORKSPACE
- uses: actions/checkout@v4
- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: Cache extensions
uses: actions/cache@v3
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
env:
runner: ubuntu-latest
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
- name: Install dependencies
run: composer install
- name: Checkout GLPI
uses: actions/checkout@v4
with:
repository: glpi-project/glpi
path: glpi
fetch-depth: 1
ref: 10.0/bugfixes
- name: Copy plugin
run: rsync -avr --exclude='glpi' ./* glpi/plugins/glpiinventory/
- name: Install dependencies
run: |
cd glpi
composer install --ansi --no-interaction
php -r "file_put_contents('.package.hash', sha1_file('package-lock.json'));"
mkdir --parents public/lib
php bin/console locales:compile
- name: Init database
run: |
mysql -e 'create database IF NOT EXISTS glpi;' -u root --password=glpi1iventory -h 127.0.0.1 -P 3306
- name: Install GLPI
run: cd glpi && php bin/console glpi:database:install -n --ansi --config-dir=tests/config --db-host=127.0.0.1 --db-name=glpi --db-user=root --db-password=glpi1iventory --db-port=3306 --strict-configuration
- name: Install plugin
run: cd glpi && php bin/console glpi:plugin:install -vvv -n --ansi --config-dir=tests/config --username=glpi glpiinventory
- name: Activate plugin
run: cd glpi && php bin/console glpi:plugin:activate -n --ansi --config-dir=tests/config glpiinventory
- name: run tests
run: cd glpi/plugins/glpiinventory/ && php vendor/bin/phpunit --testdox --colors=always tests/
- name: PHPStan checks
run: cd glpi/plugins/glpiinventory && php vendor/bin/phpstan analyze --ansi --memory-limit=1G --no-interaction --no-progress