forked from Submitty/Submitty
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.travis.yml
359 lines (347 loc) · 13.3 KB
/
.travis.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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
language: php
sudo: true
dist: xenial
cache:
pip: true
directories:
- ${TRAVIS_BUILD_DIR}/site/vendor
- ${HOME}/.composer/cache
- ${HOME}/.cache/pip
# We use build stages (https://docs.travis-ci.com/user/build-stages/) to allow us to
# create a matrix of firstly building and testing various PHP targets in several ways
# (lint, unit test, e2e test) and then test out various C++ compilers to ensure our
# best compatibility.
jobs:
fast_finish: true
include:
# Test if the name of the PR starts with [WIP] and fail at this stage if it does
- if: type = pull_request
stage: pr test for wip
language: python
python: 3.6
install:
- pip3 install requests
script:
- echo "Checking title for ${TRAVIS_REPO_SLUG}/pulls/${TRAVIS_PULL_REQUEST}"
- python3 ${TRAVIS_BUILD_DIR}/.setup/travis/check_wip.py ${TRAVIS_REPO_SLUG} ${TRAVIS_PULL_REQUEST}
# Warm up the pip and composer caches to use it for the rest of the build stages
- &00-cache
stage: 00 warm up cache
php: 7.2
before_install: source ${TRAVIS_BUILD_DIR}/.setup/travis/before_install.sh
install:
- pushd site
- travis_retry composer install --prefer-dist --no-interaction
- popd
- pip3 install -U pip
- pip3 install python-pam
- pip3 install PyYAML
- pip3 install psycopg2-binary
- pip3 install sqlalchemy
- pip3 install pylint_runner
- pip3 install python-dateutil
- pip3 install selenium
- pip3 install pause
- pip3 install tzlocal
- pip3 install paramiko
- pip3 install psutil
- pip3 install jsonschema
- pip3 install jsonref
- pip3 install docker
script: skip
- <<: *00-cache
php: 7.3
if: branch = master OR type = pull_request
- &00-python-cache
language: python
python: 3.6
install:
- pip3 install flake8 flake8-bugbear sqlalchemy psycopg2-binary
script: skip
- <<: *00-python-cache
python: 3.7
if: branch = master OR type = pull_request
# Lint the codebase to ensure that the code is compliant to our system
- &01-php-lint
stage: 01 lint
php: 7.2
install:
- pushd site
- composer install --prefer-dist --no-interaction
- popd
script:
- pushd site
- find -L . -path ./vendor -prune -o -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l
- vendor/bin/phpcs --standard=tests/ruleset.xml
- vendor/bin/phpstan analyze app
- popd
- <<: *01-php-lint
php: 7.3
if: branch = master OR type = pull_request
- &01-python-lint
language: python
python: 3.6
install:
- pip3 install flake8 flake8-bugbear
script:
- flake8
- <<: *01-python-lint
python: 3.7
if: branch = master OR type = pull_request
- &02-php-unit
stage: 02 unit test
php: 7.2
before_install:
- phpenv config-rm xdebug.ini
install:
- pecl install ds
- pecl install pcov
- pushd site
- travis_retry composer install --prefer-dist --no-interaction
- popd
script:
- pushd site
- vendor/bin/phpunit --version
- vendor/bin/phpunit -c tests/phpunit.xml
- popd
after_success:
# must run from root folder or else coveralls.io shows messed up paths for files
#- travis_retry php site/vendor/bin/php-coveralls -v -c site/tests/coveralls.yml
- bash <(curl -s https://codecov.io/bash) -cF php -f site/tests/report/clover.xml
- <<: *02-php-unit
php: 7.3
if: branch = master OR type = pull_request
- &02-python-unit
language: python
python: 3.6
install:
- pip3 install -U pip
- pip3 install tzlocal
- pip3 install sqlalchemy
- pip3 install jsonschema
- pip3 install jsonref
- pip3 install docker
- pip3 install coverage
script:
- pushd python_submitty_utils
- coverage run -m unittest discover
- coverage xml
- python3 setup.py install
- popd
- pushd migration
- coverage run -m unittest discover
- coverage xml
- popd
- pushd autograder
- coverage run -m unittest discover
- coverage xml
- popd
after_success:
- bash <(curl -s https://codecov.io/bash) -cF autograder -f autograder/coverage.xml
- bash <(curl -s https://codecov.io/bash) -cF python_submitty_utils -f python_submitty_utils/coverage.xml
- bash <(curl -s https://codecov.io/bash) -cF migrator -f migration/coverage.xml
- <<: *02-python-unit
python: 3.7
if: branch = master OR type = pull_request
- &03-e2e
stage: 03 e2e test
php: 7.2
env: AUTH_METHOD=1
services:
- xvfb
- docker
addons:
chrome: stable
postgresql: "9.5"
apt:
sources:
- sourceline: "deb http://archive.ubuntu.com/ubuntu trusty multiverse"
- sourceline: "deb http://archive.ubuntu.com/ubuntu trusty-updates multiverse"
packages:
- apache2
- libapache2-mod-fastcgi
- apache2-suexec-custom
- libapache2-mod-authnz-external
- libapache2-mod-authz-unixgroup
- libapache2-mod-wsgi-py3
- build-essential
- automake
- cmake
- clang
- g++-multilib
- libseccomp2
- seccomp
- libseccomp-dev
- valgrind
- pkg-config
- flex
- bison
- poppler-utils
- libpcre3
- libpcre3-dev
- unzip
- google-chrome-stable
- libpam-passwdqc
- libboost-all-dev
before_install:
- source ${TRAVIS_BUILD_DIR}/.setup/travis/before_install.sh
- phpenv config-rm xdebug.ini
install:
- pecl install ds
- PHP_VERSION=${TRAVIS_PHP_VERSION:0:3}
- sudo add-apt-repository -y ppa:ondrej/php
- sudo apt-get -qq update
- sudo apt-get -y install libapache2-mod-php${PHP_VERSION} php${PHP_VERSION}-pgsql php${PHP_VERSION}-curl php${PHP_VERSION}-ds
- sudo a2enmod php${PHP_VERSION}
- pip3 install -U pip
- pip3 install python-pam
- pip3 install PyYAML
- pip3 install psycopg2-binary
- pip3 install sqlalchemy
- pip3 install pylint_runner
- pip3 install python-dateutil
- pip3 install jsonschema
- pip3 install jsonref
- pip3 install selenium
- pip3 install pause
- pip3 install paramiko
- pip3 install psutil
- pip3 install docker
- CHROME_VERSION=$(google-chrome --version | egrep -o -e '[0-9]+\.[0-9]+\.[0-9]+')
- CHROME_DRIVER_VERSION=$(curl -L https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION})
- wget https://chromedriver.storage.googleapis.com/${CHROME_DRIVER_VERSION}/chromedriver_linux64.zip
- unzip chromedriver_linux64.zip
- sudo chmod u+x chromedriver
- sudo mv chromedriver /usr/bin/
- pushd ${TRAVIS_BUILD_DIR}/python_submitty_utils
- pip3 install .
- popd
before_script:
# Need to make this a full repo so that we can get the tag information
# when we're installing
- git fetch --unshallow
- git fetch
# Doing this helps chromedriver from hanging for some mysterious reason
# https://github.com/SeleniumHQ/docker-selenium/issues/87
- export DBUS_SESSION_BUS_ADDRESS=/dev/null
- psql -U postgres -c "CREATE ROLE submitty_dbuser WITH SUPERUSER CREATEDB CREATEROLE LOGIN PASSWORD 'submitty_dbuser'"
- PGPASSWORD=submitty_dbuser psql -d postgres -h localhost -U submitty_dbuser -c "CREATE DATABASE submitty"
- sudo bash .setup/travis/autograder.sh
- sudo bash .setup/travis/setup.sh
- sudo python3 /usr/local/submitty/GIT_CHECKOUT/Submitty/.setup/bin/setup_sample_courses.py --no_submissions sample
- sudo bash .setup/travis/setup_test_suite.sh
- sudo a2enmod include rewrite actions cgi alias headers fastcgi suexec authnz_external headers proxy_fcgi
- echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- cp .setup/php-fpm/pool.d/submitty.conf ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
- sudo mkdir /run/php
- sudo chown www-data:www-data /run/php
- sudo chmod 755 /run/php
- sudo ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
- sudo a2dissite 000-default
- sudo rm -rf /etc/apache2/sites-available/*
- sudo rm -rf /etc/apache2/sites-enabled/*
- sudo cp -f .setup/apache/submitty.conf /etc/apache2/sites-available/submitty.conf
- sudo sed -e "s/Require host __your_domain__/Require all granted/g" --in-place /etc/apache2/sites-available/submitty.conf
# - sudo sed '54d' --in-place /etc/apache2/sites-available/submitty.conf
- sudo cp .setup/apache/www-data /etc/apache2/suexec/www-data
- sudo chmod 0640 /etc/apache2/suexec/www-data
- sudo a2ensite submitty
- sudo bash -c 'echo "export PATH=$PATH" >> /etc/apache2/envvars'
- cat /etc/apache2/sites-available/submitty.conf
- sudo apache2ctl -t
- sudo service apache2 restart
script:
- TEST_URL="http://localhost" python -m unittest discover -v --start-directory tests
- SEMESTER=$(python3 -c 'from datetime import datetime; today = datetime.today(); semester = ("s" if today.month < 7 else "f") + str(today.year)[-2:]; print(semester)')
- sudo python3 /usr/local/submitty/bin/generate_repos.py ${SEMESTER} sample open_homework
- pushd /tmp
- git clone http://instructor:instructor@localhost/git/${SEMESTER}/sample/open_homework/instructor open_homework
- cd open_homework
- touch test.txt
- git add .
- git commit -m "First commit"
- git push
- touch test2.txt
- git add .
- git commit -m "Second commit"
- git push
- git reset --hard HEAD~1
- git pull
- cd ..
- EXIT_CODE=0; git clone http://student:student@localhost/git/${SEMESTER}/sample/open_homework/instructor || EXIT_CODE=$?; test ${EXIT_CODE} -ne 0
- <<: *03-e2e
php: 7.3
if: branch = master OR type = pull_request
- <<: *03-e2e
php: 7.2
env: AUTH_METHOD=2
if: branch = master OR type = pull_request
- <<: *03-e2e
php: 7.3
env: AUTH_METHOD=2
if: branch = master OR type = pull_request
# To add additional test cases of Clang, you should choose a version that has a binary built and distributed for
# it
- &04-integration
stage: Integration test
language: cpp
addons:
postgresql: "9.5"
apt:
sources:
- sourceline: "deb http://archive.ubuntu.com/ubuntu trusty multiverse"
- sourceline: "deb http://archive.ubuntu.com/ubuntu trusty-updates multiverse"
packages:
- build-essential
- automake
- cmake
- g++-multilib
- libseccomp2
- seccomp
- libseccomp-dev
- valgrind
- pkg-config
- flex
- bison
- poppler-utils
- libpcre3
- libpcre3-dev
- unzip
- libboost-all-dev
env: CLANG_VER="5.0.1"
before_install: source ${TRAVIS_BUILD_DIR}/.setup/travis/before_install.sh
install:
- export LLVM_ARCHIVE_PATH=${HOME}/clang+llvm.tar.xz
- wget http://releases.llvm.org/${CLANG_VER}/clang+llvm-${CLANG_VER}-x86_64-linux-gnu-ubuntu-14.04.tar.xz -O ${LLVM_ARCHIVE_PATH}
- mkdir ${HOME}/clang+llvm
- tar xf ${LLVM_ARCHIVE_PATH} -C ${HOME}/clang+llvm --strip-components 1
- export PATH=${HOME}/clang+llvm/bin:${PATH}
# Create symlink so that it's in expected location for whitelist
- sudo ln -s $(which clang) /usr/bin/clang
- sudo ln -s $(which clang++) /usr/bin/clang++
- pip3 install -U pip
- pip3 install PyYAML
- pip3 install python-dateutil
- pip3 install jsonschema
- pip3 install jsonref
- pip3 install paramiko
- pip3 install psycopg2-binary
- pip3 install sqlalchemy
- pip3 install docker
- pushd ${TRAVIS_BUILD_DIR}/python_submitty_utils
- pip3 install .
- popd
- sudo bash .setup/travis/autograder.sh
- psql -U postgres -c "CREATE ROLE submitty_dbuser WITH SUPERUSER CREATEDB CREATEROLE LOGIN PASSWORD 'submitty_dbuser'"
- PGPASSWORD=submitty_dbuser psql -d postgres -h localhost -U submitty_dbuser -c "CREATE DATABASE submitty"
- sudo bash .setup/travis/setup.sh
- sudo bash .setup/travis/setup_test_suite.sh
script:
- sudo python3 /usr/local/submitty/test_suite/integrationTests/run.py
- <<: *04-integration
env: CLANG_VER="6.0.0"
if: branch = master OR type = pull_request
notifications:
email: false
slack:
secure: A/rJsHlznzryxJEvULY9C8kCB9x+9IrRSnIIOutEoptAOyxb44FP5Lenact0ipeJxJIbSL667C/5F2J+e78METDhQD1xlCTcUG3FoonSmnqTvj73edeR8YoMuRchLRsxw2bcdKA+bv0fKzS9bPzrXOJTykunprmKSDkDlNjFHaY=