-
Notifications
You must be signed in to change notification settings - Fork 0
195 lines (169 loc) · 7.4 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
name: LimeSurvey - E2E testing
on:
push:
schedule:
- cron: '0 0 * * *'
jobs:
test:
strategy:
fail-fast: false
matrix:
group: [ 'group1', 'group2' ]
runs-on: ubuntu-20.04
env:
DBENGINE: INNODB
name: Install app and run tests
steps:
- name: Checkout current repo
uses: actions/checkout@v3
with:
path: limesurvey-core-testing
- name: Checkout app
uses: actions/checkout@v3
with:
path: limesurvey
repository: LimeSurvey/LimeSurvey
ref: develop
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
- name: Start the MySQL service
run: |
sudo systemctl start mysql.service
echo -e '[mysql]\nuser="root"\npassword="root"\nhost="localhost"' > "$HOME/.my.cnf"
- name: Initilize and check all dependencies
working-directory: limesurvey
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
working-directory: limesurvey
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.2-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 -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';" || true
mysql -e "Show variables like '%large%';"
mysql -e "Show variables like '%innodb_file%';"
mysql -e "Show variables like '%innodb_default%';"
mysql -e "CREATE DATABASE limesurvey;"
- name: Load custom console and start the Application
working-directory: limesurvey
run: |
cp application/config/config-sample-mysql.php application/config/config.php
php application/commands/console.php install admin password Administrator your-email@example.net 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/php7.2-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
- name: Seed data
working-directory: limesurvey-core-testing
run: |
# truncate all tables except lime_settings_global to prevent need for upgrading database
mysql -Nse 'show tables' limesurvey | while read table; do if [ $table != "lime_settings_global" ]; then mysql -e "truncate table $table" limesurvey; fi; done
# seed data (shouldn't contain lime_settings_global)
mysql limesurvey < cypress/data/ls-ce.sql
# copy upload directory
cp -RT cypress/data/upload ../limesurvey/upload
- name: Cypress run
id: cypress
uses: cypress-io/github-action@v3
continue-on-error: true
env:
CYPRESS_BASE_URL: 'http://localhost/index.php?r='
CYPRESS_DB_HOST: 127.0.0.1
CYPRESS_DB_DATABASE: limesurvey
with:
working-directory: limesurvey-core-testing
command: yarn cypress:run --browser chrome --spec cypress/e2e/${{ matrix.group }}/*.js --parallel y
wait-on: 'http://localhost'
- name: Compress run_times.json
id: run-times-dir
if: steps.cypress.outcome == 'success'
run: zip -qq -r run-times-${{ matrix.group }}.zip limesurvey-core-testing/run_times.json
- name: Upload run-times.zip
uses: actions/upload-artifact@v3
if: steps.cypress.outcome == 'success'
with:
name: run-times-${{ matrix.group }}
path: run-times-${{ matrix.group }}.zip
retention-days: 3
# - name: Upload Screenshots
# uses: actions/upload-artifact@v3
# if: steps.cypress.outcome != 'success'
# with:
# name: screenshots
# path: limesurvey-core-testing/cypress/screenshots/
# retention-days: 5
# - name: Upload Videos
# uses: actions/upload-artifact@v3
# if: steps.cypress.outcome != 'success'
# with:
# name: videos
# path: limesurvey-core-testing/cypress/videos/
# retention-days: 3
- name: Compress html report
id: html-report-dir
if: steps.cypress.outcome != 'success'
run: zip -qq -r html-report-${{ matrix.group }}.zip limesurvey-core-testing/templates/test-result.html
- name: Upload html report
uses: actions/upload-artifact@v3
if: steps.cypress.outcome != 'success'
with:
name: html-report-${{ matrix.group }}
path: html-report-${{ matrix.group }}.zip
retention-days: 3
- name: Fail workflow if tests fail
if: steps.cypress.outcome != 'success'
run: exit 1