-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
192 lines (173 loc) · 6.12 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
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
# This file is a template, and might need editing before it works on your project.
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/plone/tags/
image: git.starzel.de:5050/bfs/dokpool:latest
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache"
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/reference/pip_install/#caching
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
key: "${CI_COMMIT_REF_SLUG}"
paths:
- .cache
- venv/
- Plone/downloads/
- Plone/eggs/
# Set execution order: first run jobs on 'test' stage on parallel
# then run jobs on 'report' stage
stages:
- test
- build
- deploy
before_script:
# Git for 3rd party source packages
# - sudo apt-get update && sudo apt-get install -y --no-install-recommends git
- git --version
## Install ssh-agent if not already installed, it is required by Docker.
- 'command -v ssh-agent >/dev/null || ( sudo apt-get update -y && sudo apt-get install openssh-client -y )'
## Run ssh-agent (inside the build environment)
- eval $(ssh-agent -s)
## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
## We're using tr to fix line endings which makes ed25519 keys work
## without extra base64 encoding.
## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
## Create the SSH directory and give it the right permissions
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
## Assuming you created the SSH_KNOWN_HOSTS variable, uncomment the
## following two lines.
- echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
# LDAP client dependencies
# - sudo apt-get install -y --no-install-recommends libsasl2-dev libldap2-dev libssl-dev
# Check Python version
- python -V
# Update Python virtual environment to latest version
- pip install -U virtualenv
# Not ready - replace with pre-commit
#code-analysis:
# tags:
# - docker
# stage: test
# # still not available, see: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5004
# # success_with_warnings: True
# script:
# - bin/code-analysis
build:
tags:
- shell
stage: build
script:
# build docker
- echo "$CI_JOB_TOKEN" | docker login -u gitlab-ci-token --password-stdin git.starzel.de:5050
- docker build -t bfs/dokpool -f ./Docker/ubuntu16/Dockerfile.standalone .
- docker tag bfs/dokpool:latest git.starzel.de:5050/bfs/dokpool:$CI_COMMIT_REF_NAME
- docker push git.starzel.de:5050/bfs/dokpool:$CI_COMMIT_REF_NAME
only:
- review
deploy_dev:
tags:
- shell
stage: deploy
variables:
GIT_STRATEGY: none
script:
# Remove all unused images
- docker system prune -a -f
- docker pull git.starzel.de:5050/bfs/dokpool:$CI_COMMIT_REF_NAME
# Stop if it is running
- docker stop dokpool-review || true
- docker rm dokpool-review || true
# Start instance and build demo data
- docker run --detach --publish 8081:8081 --name dokpool-review git.starzel.de:5050/bfs/dokpool:review
# Create the vanilla plone site
- /usr/bin/wget -O- --user=admin --password=istrator --post-data='site_id=dokpool&form.submitted=True&title=dokpool&default_language=de&portal_timezone=Europe/Berlin&extension_ids=plonetheme.barceloneta:default&extension_ids=plone.app.contenttypes:plone-content' http://127.0.0.1:8081/@@plone-addsite
# Log in to the server. This only needs to be done once.
- /usr/bin/wget --save-cookies cookies.txt --keep-session-cookies --post-data '__ac_name=admin&__ac_password=istrator&form.submitted=True' --delete-after http://127.0.0.1:8081/dokpool/login
- /usr/bin/wget -O- --load-cookies cookies.txt --post-data='form.submitted=True&submit=True' http://127.0.0.1:8081/dokpool/docpool_setup
environment:
name: dev
url: https://review-one-bfs.starzel.de/
only:
- review
undeploy_dev:
tags:
- shell
stage: deploy
variables:
GIT_STRATEGY: none
script:
- echo "Remove review app from dev.loc"
- docker stop dokpool-review || true
- docker rm dokpool-review || true
when: manual
environment:
name: dev
action: stop
unittests:
tags:
- docker
stage: test
# still not available, see: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5004
# success_with_warnings: True
script:
# build
- cd Plone
# Buildout configuration
- cp config-template.cfg.tmpl config.cfg
- echo -e "[buildout]\nlogin = admin\npassword = admin" > secret.cfg
- pip install -r requirements.txt
- buildout bootstrap
- buildout -N -t 3 -c test_ci_server.cfg
# Run tests
- ./bin/coverage erase
- ./bin/coverage run ./bin/test || exit 1
## Tests only docpool_setup (without robot)
- ./bin/coverage run ./bin/test -t test_demo_setup --all || exit 1
## Combines the previous two runs as parallel run is set
- ./bin/coverage combine
- ./bin/coverage html
- ./bin/coverage report
coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+\%)/'
artifacts:
paths:
- parts/test/htmlreport
# No robot tests yet
#robot:
# tags:
# - docker
# stage: test
# script:
# - export DISPLAY=:99.0
# - xvfb-run bin/test --all
# Old config
#before_script:
# - cd Plone
# - mkdir -p buildout-cache/eggs
# - mkdir -p buildout-cache/downloads
# - /usr/bin/virtualenv .
# - cp config-template.cfg.tmpl config.cfg
# - ./bin/pip install -r requirements.txt
# - ./bin/buildout bootstrap
# - ./bin/buildout -N -t 3 -c test_ci_server.cfg
##check:
## script:
## - pre-commit install
## - pre-commit run --all-files
#test:
# script:
# - ./bin/coverage erase
# - ./bin/coverage run ./bin/test || exit 1
## Tests only docpool_setup (without robot)
# - ./bin/coverage run ./bin/test -t test_demo_setup --all || exit 1
## Combines the previous two runs as parallel run is set
# - ./bin/coverage combine
# - ./bin/coverage html
# - ./bin/coverage report
# coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+\%)/'