-
Notifications
You must be signed in to change notification settings - Fork 306
173 lines (155 loc) · 6.03 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
name: CI Tests
on:
pull_request:
push:
jobs:
test:
name: ${{ matrix.name }} (PHP ${{ matrix.php-version }})
runs-on: ubuntu-20.04
strategy:
matrix:
php-version: ["7.4", "8.0", "8.1", "8.2", "8.3"]
experimental: [false]
name: ["CI Test"]
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: gibbon_test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: gettext, gd, zip, pdo-mysql, intl
tools: composer:v2
ini-values: date.timezone="Etc/UTC", xdebug.max_nesting_level=-1, opcache.jit="off"
- name: Checkout source code
uses: actions/checkout@v4
with:
submodules: "recursive"
fetch-depth: 0
- name: Setup System Locale
run: |
cat <<- EOF |
en_US.UTF-8 UTF-8
en_GB.UTF-8 UTF-8
es_ES.UTF-8 UTF-8
fr_FR.UTF-8 UTF-8
zh_TW.UTF-8 UTF-8
EOF
sudo tee -a /etc/locale.gen >/dev/null
sudo locale-gen
- name: Run PHP server for tests to run
run: |
# Start a PHP test server for codeception to run against
[ -d ./tests/_logs ] || mkdir ./tests/_logs
php --server 127.0.0.1:8888 \
--docroot ${{ github.workspace }} \
--define display_startup_errors=1 \
--define display_errors=1 \
--define error_reporting=E_ALL \
>/dev/null 2>./tests/_logs/server_log &
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-php${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php${{ matrix.php-version }}-
- name: Install PHP vendor libraries
run: composer install --prefer-dist --no-interaction
- name: Run composer test
run: composer test
continue-on-error: ${{ matrix.experimental }}
env:
TEST_ENV: codeception
ABSOLUTE_URL: http://127.0.0.1:8888
DB_HOST: 127.0.0.1
DB_NAME: gibbon_test
DB_USERNAME: root
DB_PASSWORD: ""
- name: Run phpstan static analysis
run: composer test:phpstan
- name: Check PHP warning and deprecated messages in server_log
if: success() || failure()
run: |
# Check number of uncaught exceptions.
export NUM_EXCEPTION=$(grep --perl-regexp 'Uncaught Exception: ' ./tests/_logs/server_log | wc -l)
if [ "$NUM_EXCEPTION" -eq 0 ]; then
echo -e '\e[32mNo Uncaught exception.\e[0m'
echo
else
echo -e "\e[1m\e[33mGot $NUM_EXCEPTION uncaught exceptions:\e[0m"
grep --line-number --color=always --perl-regexp 'Uncaught Exception: ' ./tests/_logs/server_log
echo
(exit 1)
fi
# Check number of warning messages.
export NUM_WARNING=$(grep --perl-regexp '(?<!PHP )Warning: ' ./tests/_logs/server_log | wc -l)
if [ "$NUM_WARNING" -eq 0 ]; then
echo -e '\e[32mNo warning message.\e[0m'
echo
else
echo -e "\e[1m\e[33mGot $NUM_WARNING warning messages:\e[0m"
grep --line-number --color=always --perl-regexp '(?<!PHP )Warning: ' ./tests/_logs/server_log || echo -e '\e[32mNo Warning message found in log.\e[0m'
echo
(exit 1)
fi
# Check number of PHP warning messages.
export NUM_PHP_WARNING=$(grep 'PHP Warning: ' ./tests/_logs/server_log | wc -l)
if [ "$NUM_PHP_WARNING" -eq 0 ]; then
echo -e '\e[32mNo PHP warning message.\e[0m'
echo
else
echo -e "\e[1m\e[31mGot $NUM_PHP_WARNING PHP warning messages:\e[0m"
grep --line-number --color=always 'PHP Warning: ' ./tests/_logs/server_log || echo -e '\e[32mNo PHP Warning message found in log.\e[0m'
echo
(exit 1)
fi
# Check number of deprecated messages. Cause error if found.
export NUM_DEPRECATED=$(grep 'Deprecated: ' ./tests/_logs/server_log | wc -l)
if [ "$NUM_DEPRECATED" -eq 0 ]; then
echo -e '\e[32mNo deprecated message.\e[0m'
else
echo -e "\e[1m\e[31mGot $NUM_DEPRECATED deprecated messages:\e[0m"
grep --line-number --color=always 'Deprecated: ' ./tests/_logs/server_log || echo -e '\e[32mNo Deprecated message found in log.\e[0m'
echo
(exit 1)
fi
continue-on-error: true
- name: Check PHP notice in server_log
if: success() || failure()
run: |
# Check number of notice.
export NUM_NOTICE=$(grep --perl-regexp 'Notice: ' ./tests/_logs/server_log | wc -l)
if [ "$NUM_NOTICE" -eq 0 ]; then
echo -e '\e[32mNo Notice.\e[0m'
echo
else
echo -e "\e[1m\e[33mGot $NUM_NOTICE notice(s):\e[0m"
grep --line-number --color=always --perl-regexp 'Notice: ' ./tests/_logs/server_log
echo
(exit 1)
fi
continue-on-error: true
- name: Export Database if Test Failed
if: ${{ failure() }}
run: |
mkdir -p ./tests/_dump
mysqldump -u root --protocol=tcp --column-statistics=0 gibbon_test > ./tests/_dump/mysqldump.sql
- name: Save Test Artifacts
uses: actions/upload-artifact@v3
if: ${{ failure() || matrix.experimental }}
with:
name: Test Artifacts (PHP ${{ matrix.php-version }})
path: |
tests/_logs
tests/_dump
tests/_output
uploads/cache/templates
retention-days: 5