forked from aces/Loris
-
Notifications
You must be signed in to change notification settings - Fork 0
283 lines (231 loc) · 9.95 KB
/
loristest.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
name: LORIS Test Suite
on:
- push
- pull_request
jobs:
buildjs:
env:
EEG_VIS_ENABLED: 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install EEG package dependencies
# We only need to install protobuf-compiler
# Other deps were added to fix an apt dependency issue introduced by a new github Ubuntu image
# (see https://github.com/actions/runner-images/blob/releases/ubuntu22/20230305/images/linux/Ubuntu2204-Readme.md)
# that updated the list of installed apt packages/apt repositories. That issue may disappear in future Ubuntu images.
run: |
sudo apt install -y imagemagick-6-common libmagickcore-6.q16-6 libmagickwand-6.q16-6 \
libprotobuf-dev libprotobuf23 libprotoc23 protobuf-compiler
cd modules/electrophysiology_browser/jsx/react-series-data-viewer/
protoc protocol-buffers/chunk.proto --js_out=import_style=commonjs,binary:./src/
- name: Install npm modules
run: npm ci
- name: Compile LORIS javascript
run: npm run compile
- name: Create LORIS JS tarball
run: tar cfvz lorisjs.tar.gz htdocs/js/components/ modules/*/js/*
- name: Create node_modules tarball
run: tar cfvz node_modules.tar.gz node_modules
- uses: actions/upload-artifact@v3
name: Upload node_modules artifact
with:
name: node_modules
path: node_modules.tar.gz
- uses: actions/upload-artifact@v3
name: Upload lorisjs.tar.gz artifact
with:
name: lorisjs
path: lorisjs.tar.gz
buildphp:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.1', '8.2']
steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: zip, php-ast
- name: Validate composer.json and composer.lock
run: composer validate
- name: Cache Composer packages
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Composer cache
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install composer dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest
- name: Create vendor tarball
run: tar cfvz vendor-php${{matrix.php}}.tar.gz vendor
- uses: actions/upload-artifact@v3
name: Upload vendor-php${{matrix.php}}.tar.gz artifact
with:
name: vendor-php${{matrix.php}}
path: vendor-php${{matrix.php}}.tar.gz
api:
runs-on: ubuntu-latest
needs:
- buildjs
- buildphp
env:
DB_DATABASE: LorisTest
DB_USER: SQLTestUser
DB_PASSWORD: TestPassword
LORIS_DB_CONFIG: project/config.xml
DOCKER_WEB_SERVER: http://localhost:8000/
strategy:
fail-fast: false
matrix:
php: ['8.1', '8.2']
apiversion: ['v0.0.3', 'v0.0.4-dev']
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v3
name: Download node_modules artifact
with:
name: node_modules
path: .
- uses: actions/download-artifact@v3
name: Download compiled LORIS javascript artifact
with:
name: lorisjs
path: .
- uses: actions/download-artifact@v3
name: Download PHP dependencies artifact
with:
name: vendor-php${{matrix.php}}
path: .
- name: Extract node_modules
run: tar xfvz node_modules.tar.gz
- name: Extract compiled JS
run: tar xfvz lorisjs.tar.gz
- name: Extract composer vendor directory
run: tar xfvz vendor-php${{matrix.php}}.tar.gz
- name: Generate VERSION file
run: make VERSION
- name: Setup project/ directory
run: |
mkdir -p project/instruments
cp test/config.xml project/config.xml
cp test/test_instrument/NDB_BVL_Instrument_testtest.class.inc project/instruments/
cp -r raisinbread/instruments/* project/instruments/
sed -i 's/<sandbox>1<\/sandbox>/<sandbox>0<\/sandbox>/g' project/config.xml
sed -i 's/<adminUser>SQLTestUser<\/adminUser>/<adminUser>root<\/adminUser>/g' project/config.xml
sed -i 's/<adminPassword>TestPassword<\/adminPassword>/<adminPassword>root<\/adminPassword>/g' project/config.xml
sed -i 's/<host>db<\/host>/<host>localhost<\/host>/g' project/config.xml
cat project/config.xml
- name: Set up MySQL
run: |
sudo /etc/init.d/mysql start
mysql -e 'CREATE DATABASE ${{ env.DB_DATABASE }};' -uroot -proot
mysql -e "CREATE USER '${{env.DB_USER}}'@'localhost' IDENTIFIED BY '${{env.DB_PASSWORD}}'" -uroot -proot
mysql -e "GRANT UPDATE,INSERT,SELECT,DELETE,CREATE TEMPORARY TABLES ON ${{env.DB_DATABASE}}.* TO '${{env.DB_USER}}'@'localhost'" -uroot -proot
- name: Source default schema and Raisinbread
run: |
mysql ${{ env.DB_DATABASE}} -uroot -proot < SQL/0000-00-00-schema.sql
mysql ${{ env.DB_DATABASE}} -uroot -proot < SQL/0000-00-01-Modules.sql
mysql ${{ env.DB_DATABASE}} -uroot -proot < SQL/0000-00-02-Permission.sql
mysql ${{ env.DB_DATABASE}} -uroot -proot < SQL/0000-00-03-ConfigTables.sql
mysql ${{ env.DB_DATABASE}} -uroot -proot < SQL/0000-00-04-Help.sql
mysql ${{ env.DB_DATABASE}} -uroot -proot < SQL/0000-00-05-ElectrophysiologyTables.sql
find raisinbread/instruments/instrument_sql -name *.sql -exec sh -c "echo Sourcing {}; mysql ${{ env.DB_DATABASE}} -uroot -proot < {}" \;
find raisinbread/RB_files/ -name *.sql -exec sh -c "echo Sourcing {}; mysql ${{ env.DB_DATABASE}} -uroot -proot < {}" \;
- name: Source instrument schemas
run: |
find raisinbread/instruments/instrument_sql -name 0000-*.sql -exec sh -c "echo Sourcing {}; mysql ${{ env.DB_DATABASE}} -uroot -proot < {}" \;
echo Sourcing test/test_instrument/testtest.sql
mysql ${{ env.DB_DATABASE}} -uroot -proot < test/test_instrument/testtest.sql
- name: Set LORIS base path
run: |
echo UPDATE Config SET VALUE=\'`pwd`/\' WHERE ConfigID IN \(SELECT ID FROM ConfigSettings WHERE Name=\'base\'\)
echo UPDATE Config SET VALUE=\'`pwd`/\' WHERE ConfigID IN \(SELECT ID FROM ConfigSettings WHERE Name=\'base\'\) | mysql ${{env.DB_DATABASE}} -uroot -proot
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: zip, php-ast
- name: Start PHP Web Server
run: php -S localhost:8000 -t htdocs/ htdocs/router.php 2>error_log &
- name: Test server
run: |
sleep 1
curl -v http://localhost:8000
- name: Run Test Suite
run: |
vendor/bin/phpunit --configuration test/phpunit.xml --testsuite LorisAPITests --group api-${{ matrix.apiversion }}
- name: Print Error Logs
if: always()
run: cat error_log
docker:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
testsuite: ['integration']
php: ['8.1','8.2']
ci_node_index: [0,1,2,3]
include:
# add a variable but do not display it in the job's name
- ci_node_total: 4
- testsuite: 'static'
php: '8.1'
- testsuite: 'static'
php: '8.2'
- testsuite: 'unit'
php: '8.1'
- testsuite: 'unit'
php: '8.2'
steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: zip, php-ast
- name: Validate composer.json and composer.lock
run: composer validate
- name: Cache Composer packages
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Composer cache
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Change PHP Version in Dockerfile
run: sed -i "s/8.0/${{ matrix.php }}/g" Dockerfile.test.php8
- name: Install package dependencies
# We only need to install protobuf-compiler
# Other deps were added to fix an apt dependency issue introduced by a new github Ubuntu image
# (see https://github.com/actions/runner-images/blob/releases/ubuntu22/20230305/images/linux/Ubuntu2204-Readme.md)
# that updated the list of installed apt packages/apt repositories. That issue may disappear in future Ubuntu images.
run: |
sudo apt install -y imagemagick-6-common libmagickcore-6.q16-6 libmagickwand-6.q16-6 \
libprotobuf-dev libprotobuf23 libprotoc23 protobuf-compiler
cd modules/electrophysiology_browser/jsx/react-series-data-viewer/
protoc protocol-buffers/chunk.proto --js_out=import_style=commonjs,binary:./src/
- name: Install composer dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest
- name: Build LORIS
run: make dev
- name: Run Test Suite
run: |
# set sandbox to 1 before running the tests
# since some tests only run in sandbox environments
sed -i 's/<sandbox>0<\/sandbox>/<sandbox>1<\/sandbox>/g' test/config.xml
npm run tests:${{ matrix.testsuite }}
env:
# Specifies how many jobs you would like to run in parallel,
CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
# Use the index from matrix as an environment variable
CI_NODE_INDEX: ${{ matrix.ci_node_index }}