forked from filesender/filesender
-
Notifications
You must be signed in to change notification settings - Fork 0
261 lines (207 loc) · 7.53 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
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
name: CI
on:
push:
branches:
- '2021/jan/ghatest*'
- 'savage-*'
pull_request:
branches: [ development ]
jobs:
metadata:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
steps:
- name: generate matrix
id: generate-matrix
run: |
echo "repo $GITHUB_REPOSITORY "
MATRIX_INCLUDE_JSON+="["
if [ x"$GITHUB_REPOSITORY" = "xfilesenderuici/filesender" ]; then
MATRIX_INCLUDE_JSON+="{\"testsuite\": \"selenium\", \"db\": \"mysql\", \"travis_sauce_connect\": \"true\"}"
else
MATRIX_INCLUDE_JSON+="{\"testsuite\": \"cron\", \"db\": \"pgsql\", \"travis_sauce_connect\": \"false\",\"sauce_username\": \"\"}"
MATRIX_INCLUDE_JSON+="{\"testsuite\": \"core\", \"db\": \"pgsql\", \"travis_sauce_connect\": \"false\",\"sauce_username\": \"\"}"
MATRIX_INCLUDE_JSON+="{\"testsuite\": \"core\", \"db\": \"mysql\", \"travis_sauce_connect\": \"false\",\"sauce_username\": \"\"}"
MATRIX_INCLUDE_JSON+="{\"testsuite\": \"dataset\", \"db\": \"pgsql\", \"travis_sauce_connect\": \"false\",\"sauce_username\": \"\"}"
fi
MATRIX_INCLUDE_JSON="${MATRIX_INCLUDE_JSON//\}\{/\}, \{}"
MATRIX_INCLUDE_JSON+="]"
MATRIX_JSON="{\"include\": ${MATRIX_INCLUDE_JSON}}"
echo "${MATRIX_JSON}"
echo "::set-output name=matrix::${MATRIX_JSON}"
build:
if: github.repository == 'filesender/filesender'
name: ${{ matrix.testsuite }}-${{ matrix.db }}
runs-on: Ubuntu-20.04
needs: metadata
env:
DB: ${{ matrix.db }}
TESTSUITE: ${{ matrix.testsuite }}
SAUCE_TUNNEL_IDENTIFIER: cisel${{ matrix.db }}
SAUCE_DONT_VERIFY_CERTS: 1
php_extensions: mbstring, pdo_mysql, pdo_pgsql, pgsql, mysqlnd
php_cache_key: cache_setup_php_key_v8
php_version: '8.1'
TESTINGUI: 0
strategy:
matrix: ${{ fromJson(needs.metadata.outputs.matrix) }}
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: postgres
POSTGRES_HOST: localhost
POSTGRES_PASSWORD: password
POSTGRES_USER: postgres
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
mariadb:
image: mariadb:10.2
ports:
- 3306:3306
env:
MYSQL_USER: filesender
MYSQL_PASSWORD: password
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: password
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
steps:
- name: Checkout code from github
uses: actions/checkout@v2
- name: Make dummy artifact file
run: |
mkdir -p output/test
date > output/test/output1.txt
BASEDIR=$(pwd)
export BASEDIR
- name: Setup setup-php cache environment
id: cachesetupphp
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ env.php_version }}
extensions: ${{ env.php_extensions }}
key: ${{ env.php_cache_key }}
# this fails for mysql jobs when using the cache (jan 2021)
# - name: Cache extensions
# uses: actions/cache@v2
# with:
# path: ${{ steps.cachesetupphp.outputs.dir }}
# key: ${{ steps.cachesetupphp.outputs.key }}
# restore-keys: ${{ steps.cachesetupphp.outputs.key }}
- name: Setup PHP with selected extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php_version }}
extensions: ${{ env.php_extensions }}
ini-values: max_input_time=3600,upload_max_filesize=2047M,post_max_size=2146445312,session.cookie_secure=On,session.cookie_httponly=On
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install composer.json packages
run: |
composer self-update --1
composer update --no-interaction
- name: Cache SimpleSAML
uses: actions/cache@v2
id: cache-simplesaml
with:
path: "simplesaml"
key: cache-simplesaml
- name: Install SimpleSAML
env:
CACHE_HIT: ${{steps.cache-simplesaml.outputs.cache-hit}}
run: |
if [[ "$CACHE_HIT" == 'true' ]]; then
echo "cache hit has setup simplesaml directory"
else
echo "no cache hit, downloading and extracting simplesaml"
./ci/scripts/simplesamlphp-download-and-extract.sh
fi
- name: Setup SimpleSAML
run: |
./ci/scripts/simplesamlphp-setup.sh
- name: Setup machine for FileSender
run: ci/setup-machine.sh
env:
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
- uses: saucelabs/[email protected]
if: ${{ env.TESTSUITE == 'selenium' }}
with:
username: ${{ secrets.SAUCE_USERNAME }}
accessKey: ${{ secrets.SAUCE_ACCESS_KEY }}
tunnelIdentifier: cisel${{ matrix.db }}
noSSLBumpDomains: file_sender.app
- name: Run Primary Tests (MAIN JOB)
if: ${{ env.TESTSUITE != 'selenium' }}
run: |
if [ "$TESTSUITE" = "cron" ]; then
echo "testing task/cron job"
echo "BASEDIR $BASEDIR"
pwd
sudo -u www-data php scripts/task/cron.php --testing-mode
echo "cron job complete"
fi
echo "testing $TESTSUITE on database $DB "
if [ "$TESTSUITE" != "selenium" ]; then
sudo -u www-data id
sudo -u www-data ./vendor/bin/phpunit --configuration ./unittests/config_tests_filesender.xml --testsuite=$TESTSUITE
fi
- name: Run Primary Selenium Tests (MAIN JOB)
if: ${{ env.TESTSUITE == 'selenium' }}
env:
TEST_SECRET: ${{ secrets.TestSecret }}
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
SAUCE_DONT_VERIFY_CERTS: 1
run: |
echo "testing $TESTSUITE on database $DB "
sudo -u www-data --preserve-env=SAUCE_USERNAME,SAUCE_ACCESS_KEY,SAUCE_TUNNEL_IDENTIFIER,SAUCE_DONT_VERIFY_CERTS ./vendor/bin/phpunit --configuration ./unittests/config_tests_filesender.xml --testsuite=$TESTSUITE
- name: Debug Information
if: ${{ always() }}
run: |
ls -l log
echo "-------------------"
echo "FileSender logs...."
echo "-------------------"
sudo cat log/*.log
echo "--------------------"
echo "Apache logs.... "
echo "--------------------"
cat /var/log/apache2/access.log
cat /var/log/apache2/error.log
echo "--------------------"
# - name: date-artifact
# uses: actions/upload-artifact@v2
# with:
# name: Log-file-report
# path: output/test/output1.txt
#
# - name: FileSender Log files
# uses: actions/upload-artifact@v2
# with:
# name: Log-files
# path: log
#
# - name: log files open to read
# run: sudo chmod +r /var/log/apache2/error.log /var/log/apache2/access.log
#
# - name: Apache Log files
# uses: actions/upload-artifact@v2
# with:
# name: apache-logs
# path: |
# /var/log/apache2/error.log
# /var/log/apache2/access.log