-
Notifications
You must be signed in to change notification settings - Fork 147
192 lines (167 loc) · 8.83 KB
/
ci.yaml
File metadata and controls
192 lines (167 loc) · 8.83 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
184
185
186
187
188
189
190
191
192
name: Continuous Integration
on: [push, pull_request]
jobs:
test:
runs-on: ${{ matrix.operating-system }}
strategy:
# Do not halt all tests in the matrix if one fails
fail-fast: false
# Define a list of test environments to run the test suite in
matrix:
include:
# @see https://github.com/actions/runner-images
# @todo run some tests on 'windows-latest' (no need to try testing on macs: those runners are never
# available on the github cloud, at least for free plans)
# NB: the order of options is picked to make the github page display nicer (test naming in left col)
- php: '8.5'
dbtype: mysql
dbversion: latest
operating-system: ubuntu-24.04
dbport: 3306
- php: '8.4'
dbtype: mysql
# Using 'native' version will result in the mysql service on the host to be used.
# For Ubuntu 22.04 and 24.04 runners, that is mysql 8.0.43
dbversion: native
operating-system: ubuntu-24.04
dbport: 3306
- php: '8.3'
dbtype: mariadb
dbversion: 'latest'
operating-system: ubuntu-24.04
dbport: 3306
- php: '8.2'
dbtype: mysql
dbversion: '5.7'
operating-system: ubuntu-22.04
dbport: 3307
- php: '8.1'
dbtype: mariadb
dbversion: '5.5'
operating-system: ubuntu-22.04
dbport: 3307
# NB: we do not run docker containers using the native `services` tag because we have to mount one or more files
# from the local filesystem to the containers (eg. the db config), and doing so breaks actions/checkout@v5
steps:
- run: echo 'Job was automatically triggered by a ${{ github.event_name }} event'
- run: echo 'Job is now running on a ${{ runner.os }} server'
- run: echo 'Branch is ${{ github.ref }} and Repository is ${{ github.repository }}'
- run: echo "Current directory is ${{ github.workspace }}, current user is $(id -u -n)"
# has to be run before setting up the db and webserver, as we store their config files in the codebase
# @todo this way of checking out the code somehow breaks the build script `run_composer.sh`. We should
# figure out how to fix that - or plain replace this with a `git clone` command
- name: Check out repository code
uses: actions/checkout@v5
- name: Install required packages
run: |
chmod 755 ./tests/setup/setup_packages.sh
sudo ./tests/setup/setup_packages.sh
- name: Set up the database
run: |
chmod 755 ./tests/setup/setup_db.sh
./tests/setup/setup_db.sh -t '${{ matrix.dbtype }}' -v '${{ matrix.dbversion }}' -P '${{ matrix.dbport }}'
- name: Stop php-fpm if running
run: |
if ps auxwww | fgrep -q php-fpm; then
PHPVER=$(php -r 'echo implode(".",array_slice(explode(".",PHP_VERSION),0,2));' 2>/dev/null)
sudo service "php${PHPVER}-fpm" stop || sudo pkill php-fpm
fi
- name: Set up the required php version
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
extensions: bcmath, calendar, curl, ftp, gd, gettext, iconv, mbstring, mysqli, simplexml, sqlite3, xdebug, xml, zip, zlib
ini-values: 'auto_prepend_file=${{ github.workspace }}/tests/setup/config/php/auto_prepend.php'
# Alternative version
#run: |
# chmod 755 ./tests/setup/setup_php.sh
# ./tests/setup/setup_php.sh
# This is required to make fpm take into account the php.ini settings added by shivammathur/setup-php
- name: Restart php-fpm
run: sudo service 'php${{ matrix.php }}-fpm' restart
# Composer latest is installed by shivammathur/setup-php - no need for manual install
#- name: Set up Composer
# run: |
# chmod 755 ./tests/setup/setup_composer.sh
# ./tests/setup/setup_composer.sh
- name: Set up the webserver
# @todo we should set up either nginx or apache depending on the matrix combination
run: |
chmod 755 ./tests/setup/setup_webserver.sh
./tests/setup/setup_webserver.sh
# We run the release-preparing script before messing up the vendor/ dir to run the test suite (except
# for the step of dumping the database, as the db schema has not yet been created, and for the step
# checking php syntax, as that is tested by the unit test requesting every web page)
- name: Test the release-preparing script (run it)
run: |
chmod 755 ./build/make_release.sh
./build/make_release.sh -s check_php,dump_db
- name: Install dev dependencies
run: |
chmod 755 ./tests/setup/setup_dependencies.sh
./tests/setup/setup_dependencies.sh
- name: Set up phpunit configuration
run: |
cp phpunit.dist.xml phpunit.xml
if [ -n '${{ matrix.dbtype }}' ] && [ '${{ matrix.dbtype }}' != mysql ]; then
sed -r -i -e 's|<env name="TEST_DB_TYPE" value="mysqli" />|<env name="TEST_DB_TYPE" value="${{ matrix.dbtype }}" />|' phpunit.xml
fi
if [ -n "${{ matrix.dbport }}" ]; then
sed -r -i -e 's|<env name="TEST_DB_PORT" value="3306" />|<env name="TEST_DB_PORT" value="${{ matrix.dbport }}" />|' phpunit.xml
fi
# Make sure Apache can access the installation in its current dir.
# We set the installation to be fully writeable to anyone - this is a test install anyway
# @todo the `/home/runner` path should not be hardcoded. Figure out if we can get if from some GH param
- name: Fix filesystem permissions
run: |
sudo chmod g+rx,o+rx /home/
sudo chmod -R g+rwX,o+rwX /home/runner/
#- name: Smoke testing
# run: |
# curl -L --fail-with-body http://localhost/images/default_logo.jpg
# echo
# curl -L --fail-with-body http://localhost/index.php
- name: Run the test suite
run: |
./vendor/bin/phpunit --stop-on-failure tests/install
echo
./vendor/bin/phpunit tests/run
# @todo this test always uses the mysql and mysqldump cli tools from the host computer/image. It would be
# nice to also run the dump_database.sh script using the cli tools from the db version being tested
- name: Test the db-dumping script (run it)
run: |
export MYSQL_HOST=127.0.0.1
export MYSQL_PORT='${{ matrix.dbport }}'
export MYSQL_DATABASE=weberp
chmod 755 ./build/dump_database.sh
./build/dump_database.sh -o ./install/sql demo
- name: Failure troubleshooting
if: ${{ failure() }}
run: |
#echo '### running processes'
#ps auxwww | grep -E -v '^root .+:[0-9]{2} \[' | grep -v ' grep'
#echo
#sudo systemctl status mysql.service
#echo
#sudo systemctl status apache2.service
#echo '### fpm socket(s)'
#ls -la /run/php/
#echo
#php -i
#echo
#sudo ls -la /var/log/apache2/
#echo
#sudo cat /var/log/apache2/error.log
#echo
#echo '### apache access log'
#sudo cat /var/log/apache2/access.log
#echo
# failed phpunit tests might have saved to disk the html contents of the failing pages. Show them
if [ -n "$(ls webpage_failing_*.html 2>/dev/null)" ]; then
for PAGE in webpage_failing_*.html; do
echo "### output of failed test $PAGE"
echo
cat "$PAGE"
echo
done
fi