-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
72 lines (64 loc) · 1.8 KB
/
.gitlab-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
image: registry.secoder.net/tool/deployer
stages:
- build
- test
- deploy
build:
stage: build
script:
- export BUILD_IMAGE_NAME=$CI_REGISTRY_IMAGE
- export BUILD_IMAGE_TAG=$CI_COMMIT_REF_SLUG
- export BUILD_IMAGE_USERNAME=$CI_REGISTRY_USER
- export BUILD_IMAGE_PASSWORD=$CI_REGISTRY_PASSWORD
- deployer build
# Job template for test stage
.test:
image: nikolaik/python-nodejs:python3.8-nodejs12
stage: test
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- frontend/node_modules/
before_script:
- pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
- cd frontend/
- npm config set registry https://registry.npm.taobao.org
- npm install
- npm run build
- cd ..
unit-test:
extends: .test
script:
- coverage run -m pytest --junit-xml=xunit-reports/xunit-result.xml
- BACKEND_RET=$?
- coverage xml -o coverage-reports/coverage.xml
- coverage report
- cd frontend/
- npm run test:unit
- FRONTEND_RET=$?
- if [ $FRONTEND_RET \> 0 ]; then exit $FRONTEND_RET; fi;
- exit $BACKEND_RET
after_script:
- SUFFIX=$RANDOM
- curl "http://10.0.0.11/sonar-scanner.tar.gz" -s -o "/tmp/sonar-$SUFFIX.tar.gz"
- tar -xf "/tmp/sonar-$SUFFIX.tar.gz" -C /opt
- /opt/sonar-scanner/bin/sonar-scanner
style-test:
extends: .test
# allow_failure: true
script:
- pylint --load-plugins=pylint_django backend NewsSearchSystem crawler/crawler
- BACKEND_RET=$?
- cd frontend/
- npm run lint
- FRONTEND_RET=$?
- if [ $FRONTEND_RET \> 0 ]; then exit $FRONTEND_RET; fi;
- exit $BACKEND_RET
deploy:
stage: deploy
script:
- deployer dyno replace $CI_PROJECT_NAME "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" "$REGISTRY_USER" "$REGISTRY_PWD"
only:
- master
- dev
- database