|
1 image: python:3.5 |
|
2 |
|
3 stages: |
|
4 - test |
|
5 - dist |
|
6 - quality |
|
7 |
|
8 cache: |
|
9 paths: |
|
10 - bin/ |
|
11 - eggs/ |
|
12 - parts/ |
|
13 |
|
14 before_script: |
|
15 - export http_proxy=http://172.17.0.1:3128/ |
|
16 - export HTTP_PROXY=http://172.17.0.1:3128/ |
|
17 - export https_proxy=http://172.17.0.1:3128/ |
|
18 - export HTTPS_PROXY=http://172.17.0.1:3128/ |
|
19 |
|
20 bootstrap: |
|
21 stage: .pre |
|
22 script: |
|
23 - python3.5 bootstrap.py --buildout-version=2.12.0 |
|
24 - ./bin/buildout |
|
25 |
|
26 test: |
|
27 stage: test |
|
28 script: |
|
29 - pip install anybadge |
|
30 - mkdir ./coverage |
|
31 - ./bin/test --coverage coverage | tee ./coverage/coverage.log |
|
32 - GLOBAL_COVER=$(grep -e '^[[:space:]]*[[:digit:]]\+[[:space:]]\+[[:digit:]]\+\%' ./coverage/coverage.log | |
|
33 awk 'BEGIN { lines=0; cov=0 } |
|
34 { lines = lines + $1; cov = cov + $1 * $2 / 100 } |
|
35 END { printf "%.2f", cov / lines * 100 }') |
|
36 - anybadge --label=Coverage --file=./coverage/coverage.svg --value=$GLOBAL_COVER 20=red 40=orange 60=yellow 90=green |
|
37 - echo "Global tests coverage is $GLOBAL_COVER %" |
|
38 artifacts: |
|
39 paths: |
|
40 - ./coverage/ |
|
41 |
|
42 dist: |
|
43 stage: dist |
|
44 script: |
|
45 - ./bin/buildout setup setup.py clean --all sdist bdist_egg bdist_wheel |
|
46 artifacts: |
|
47 paths: |
|
48 - ./dist |
|
49 |
|
50 pylint: |
|
51 stage: quality |
|
52 allow_failure: true |
|
53 script: |
|
54 - pip install pylint-exit anybadge |
|
55 - mkdir ./pylint |
|
56 - ./bin/pylint src/pyams_form/ | tee ./pylint/pylint.log || pylint-exit $? |
|
57 - PYLINT_SCORE=$(sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p' ./pylint/pylint.log) |
|
58 - anybadge --label=Pylint --file=./pylint/pylint.svg --value=$PYLINT_SCORE 2=red 4=orange 8=yellow 10=green |
|
59 - echo "Pylint score is $PYLINT_SCORE" |
|
60 artifacts: |
|
61 paths: |
|
62 - ./pylint/ |
|
63 |
|
64 quality: |
|
65 stage: quality |
|
66 allow_failure: true |
|
67 image: docker:stable |
|
68 services: |
|
69 - docker:stable-dind |
|
70 variables: |
|
71 DOCKER_DRIVER: overlay2 |
|
72 DOCKER_TLS_CERTDIR: "" |
|
73 script: |
|
74 - | |
|
75 if ! docker info &>/dev/null; then |
|
76 if [ -z "$DOCKER_HOST" -a "$KUBERNETES_PORT" ]; then |
|
77 export DOCKER_HOST='tcp://localhost:2375' |
|
78 fi |
|
79 fi |
|
80 - docker run |
|
81 --env SOURCE_CODE="$PWD" |
|
82 --volume "$PWD":/code |
|
83 --volume /var/run/docker.sock:/var/run/docker.sock |
|
84 "registry.gitlab.com/gitlab-org/security-products/codequality:12-0-stable" /code |
|
85 artifacts: |
|
86 reports: |
|
87 codequality: gl-code-quality-report.json |
|
88 expire_in: 1 week |
|
89 dependencies: [] |
|
90 only: |
|
91 refs: |
|
92 - branches |
|
93 - tags |
|
94 except: |
|
95 variables: |
|
96 - $CODE_QUALITY_DISABLED |