forked from LimeSurvey/LimeSurvey
-
Notifications
You must be signed in to change notification settings - Fork 0
299 lines (255 loc) · 11.2 KB
/
main.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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
name: LimeSurvey - CI pipeline
# Triggers the workflow on push or pull request events on all branches
on:
pull_request:
push:
branches:
- '*'
- '**'
- 'dev/**'
- 'bug/**'
- 'feature/**'
- 'zoho/**'
jobs:
CI-pipeline:
runs-on: ubuntu-20.04 # ubuntu runner hosted by Github
strategy:
matrix:
# Specify what versions of php you want to test
php-versions: ['7.4', '8.2']
# Env vars for this job
env:
DBENGINE: INNODB
name: PHP ${{ matrix.php-versions }} # Check each version of php specified in matrix
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# This will change the php version for every version specified in matrix https://github.com/marketplace/actions/setup-php-action
- name: Install specified PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
# Start the MySQL service - https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu1804-README.md#mysql
- name: Start the MySQL service
run: |
sudo systemctl start mysql.service
- name: Initilize and check all dependencies
run: |
# Before running composer install, check that the autoloader is up-to-date and all classes can be loaded.
php tests/check_autoloader.php
# Test
echo $archive_url
php -r 'var_dump(PHP_INT_SIZE);'
# Install LimeSurvey.
php -m # Spit out all loaded PHP modules
mysql --version
touch enabletests
# NB: PHPUnit 6.5.* is installed with composer.
composer install -vvv
./vendor/bin/phpunit --version
- name: Set up Apache+PHP
run: |
# Set up the Apache and PHP
sudo apt-get update > /dev/null
sudo apt --fix-broken install php php-mysql php8.0-mysql php7.4-mysql libapache2-mod-php8.0 -y
sudo cp -f ./tests/CI-pipeline/github-actions-apache /etc/apache2/sites-available/000-default.conf
sudo sed -e "s?%CI_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf
sudo service apache2 restart
# Give permision to access files for Apache
setfacl -dR -m u:www-data:rwX -m u:$(whoami):rwx ./tmp
setfacl -dR -m u:www-data:rwX -m u:$(whoami):rwx ./upload
setfacl -dR -m u:www-data:rwX -m u:$(whoami):rwx ./themes
setfacl -dR -m u:www-data:rwX -m u:$(whoami):rwx ./tests/tmp
setfacl -dR -m u:www-data:rwX -m u:$(whoami):rwx ./application/config
chmod -R 777 ./tmp
sudo chown -R www-data:docker ./tmp
chmod -R 777 ./upload
chmod -R 777 ./themes # Need 777 so both console and web server can cd into the folder.
chmod -R 777 ./tests/tmp
chmod -R 777 ./application/config
chmod +x ./tests/bin/lint-*
- name: Check MySQL service
run: |
# InnoDB needs large_file_prefix & Barracuda file format
# https://discuss.gogs.io/t/solved-mysql-error-1064-while-running-first-install/1604
# InnoDB variables ARE already set to desired values in Github runner (ubuntu-18.04)
sudo systemctl start mysql
sudo service mysql status
mysql -uroot -proot -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';" || true
mysql -uroot -proot -e "Show variables like '%large%';"
mysql -uroot -proot -e "Show variables like '%innodb_file%';"
mysql -uroot -proot -e "Show variables like '%innodb_default%';"
mysql -uroot -proot -e "CREATE DATABASE limesurvey;"
- name: Load custom console and start the Application
run: |
cp application/config/config-sample-mysql.php application/config/config.php
php application/commands/console.php install admin password TravisLS [email protected] verbose
# Enable debug=2 in config file. OBS: This assumes debug is on line 61.
# TODO: Disable, a lines was added to config file and some tests started to fail.
# NB: EmCache is always disabled when debug => 2
# NB: There can be a difference in assets used when debug = 0 or 2 (minified version or not)
# sed -i '60s/.*/ "debug"=>2,/' application/config/config.php
# cat application/config/config.php
- name: Test the server
run: |
# Test server.
wget -O - localhost
#sudo tail -n 500 /var/log/apache2/error.log || true
#sudo tail -n 500 /var/log/nginx/error.log || true
#sudo tail -n 500 /var/log/php7.4-fpm.log || true
#sudo tail -n 500 /var/log/php8.0-fpm.log || true
# NOTE: php --version might not be the same as setup in apache. Use fwrite(STDERR, phpversion()); in index.php to be sure.
#which php
#php --version
#php -r 'phpinfo();' | grep log
#php --info | grep log
#find /var/log
# Chromedriver setup.
# Note: Keep getting timeout problems on Travis with chromedriver.
# wget https://chromedriver.storage.googleapis.com/2.33/chromedriver_linux64.zip
# unzip chromedriver_linux64.zip
- name: Set up Selenium with firefox (needed for integrity tests)
run: |
echo `which firefox`
echo `firefox -v`
echo `geckodriver --version`
# Setup Selenium with Firefox headless mode, Gecko driver already installed
wget "https://selenium-release.storage.googleapis.com/3.9/selenium-server-standalone-3.9.1.jar"
export MOZ_HEADLESS=1
export MOZ_HEADLESS_WIDTH=1280
export MOZ_HEADLESS_HEIGHT=1024
java -jar selenium-server-standalone-3.9.1.jar &
sleep 1
- name: Run functional tests
env:
DOMAIN: localhost
run: php vendor/bin/phpunit --testdox --stop-on-failure tests/functional
- name: Upload Screenshots
uses: actions/upload-artifact@v3
if: failure()
with:
name: screenshots
path: tests/tmp/screenshots/
retention-days: 5
unit-tests:
runs-on: ubuntu-20.04
strategy:
matrix:
# Specify what versions of php you want to test
php-versions: ['7.4', '8.2']
env:
DBENGINE: INNODB
steps:
- uses: actions/checkout@v2
- name: Install specified PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Setup
run: |
touch enabletests
composer install -vvv
sudo apt-get update > /dev/null
sudo apt --fix-broken install php php-mysql php8.0-mysql php7.4-mysql -y
chmod -R 777 ./tmp
chmod -R 777 ./upload
chmod -R 777 ./themes
chmod -R 777 ./tests/tmp
chmod -R 777 ./application/config
- name: Check MySQL service
run: |
# InnoDB needs large_file_prefix & Barracuda file format
# https://discuss.gogs.io/t/solved-mysql-error-1064-while-running-first-install/1604
# InnoDB variables ARE already set to desired values in Github runner (ubuntu-18.04)
sudo systemctl start mysql
sudo service mysql status
mysql -uroot -proot -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';" || true
mysql -uroot -proot -e "Show variables like '%large%';"
mysql -uroot -proot -e "Show variables like '%innodb_file%';"
mysql -uroot -proot -e "Show variables like '%innodb_default%';"
mysql -uroot -proot -e "CREATE DATABASE limesurvey;"
- name: Load custom console and start the Application
run: |
cp application/config/config-sample-mysql.php application/config/config.php
php application/commands/console.php install admin password TravisLS [email protected] verbose
- name: Run unit tests
env:
XDEBUG_MODE: coverage
run: php vendor/bin/phpunit --testdox --stop-on-failure tests/unit
- name: Upload cov.xml
uses: actions/upload-artifact@v3
with:
name: cov-file-${{ matrix.php-versions }}
path: cov.xml
test-coverage:
runs-on: ubuntu-20.04
needs: unit-tests
strategy:
matrix:
# Specify what versions of php you want to test
php-versions: ['7.4', '8.2']
steps:
- uses: actions/checkout@v2
- name: Install specified PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Check if cov.xml artefact exists
uses: xSAVIKx/artifact-exists-action@v0
id: check_coverage_artifact
with:
name: cov-file-${{ matrix.php-versions }}
- name: Download cov.xml
if: steps.check_coverage_artifact.outputs.exists == 'true'
uses: actions/download-artifact@v3
with:
name: cov-file-${{ matrix.php-versions }}
- name: Check test coverage if cov.xml exists (won't work on PHP 8 with current phpunit version)
run: php tests/bin/check_coverage.php cov.xml 37
code-check:
runs-on: ubuntu-20.04
env:
DBENGINE: INNODB
strategy:
matrix:
# Specify what versions of php you want to test
php-versions: ['7.4', '8.2']
steps:
- uses: actions/checkout@v2
- name: Install specified PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Setup
run: |
touch enabletests
composer install -vvv
sudo apt-get update > /dev/null
sudo apt --fix-broken install php php-mysql php8.0-mysql php7.4-mysql -y
chmod -R 777 ./tmp
chmod -R 777 ./upload
chmod -R 777 ./themes
chmod -R 777 ./tests/tmp
chmod -R 777 ./application/config
chmod +x ./tests/bin/lint-*
- name: Check MySQL service
run: |
# InnoDB needs large_file_prefix & Barracuda file format
# https://discuss.gogs.io/t/solved-mysql-error-1064-while-running-first-install/1604
# InnoDB variables ARE already set to desired values in Github runner (ubuntu-18.04)
sudo systemctl start mysql
sudo service mysql status
mysql -uroot -proot -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';" || true
mysql -uroot -proot -e "Show variables like '%large%';"
mysql -uroot -proot -e "Show variables like '%innodb_file%';"
mysql -uroot -proot -e "Show variables like '%innodb_default%';"
mysql -uroot -proot -e "CREATE DATABASE limesurvey;"
- name: Load custom console and start the Application
run: |
cp application/config/config-sample-mysql.php application/config/config.php
php application/commands/console.php install admin password TravisLS [email protected] verbose
- name: Run syntax check, CodeSniffer, MessDetector, ...
run: composer test
- name: Run Psalm on application/ folder with low strictness
run: |
./vendor/bin/psalm -c psalm-all.xml