-
Notifications
You must be signed in to change notification settings - Fork 4
/
wercker.yml
134 lines (120 loc) · 4.49 KB
/
wercker.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
# Read more about containers on our dev center
# http://devcenter.wercker.com/docs/containers/index.html
box:
id: python:3.6-alpine
cmd: /bin/sh
# You can also use services such as databases. Read more on our dev center:
# http://devcenter.wercker.com/docs/services/index.html
# services:
# - postgres
# http://devcenter.wercker.com/docs/services/postgresql.html
# - mongo
# http://devcenter.wercker.com/docs/services/mongodb.html
# This is the build pipeline. Pipelines are the core of wercker
# Read more about pipelines on our dev center
# http://devcenter.wercker.com/docs/pipelines/index.html
build:
# The steps that will be executed on build
# Steps make up the actions in your pipeline
# Read more about steps on our dev center:
# http://devcenter.wercker.com/docs/steps/index.html
steps:
- script:
name: alpine cache
code: |
echo "Trying to create cache"
mkdir -p $WERCKER_CACHE_DIR/apk-cache
ln -s $WERCKER_CACHE_DIR/apk-cache /etc/apk/cache
echo "Cache at $WERCKER_CACHE_DIR/apk-cache"
apk cache clean
echo "Cleaned the cache"
# There are a lot of packages that we depend on
- script:
name: alpine pre-requisites
code: |
apk update
apk add gettext gcc linux-headers jpeg-dev postgresql-dev musl-dev zlib-dev
# Once done, install virtualenv so we're ready to use it
- script:
name: virtualenv-install
code: |
export PIP_CACHE_DIR=$WERCKER_CACHE_DIR/pip-download-cache
export PIP_FIND_LINKS=$WERCKER_CACHE_DIR/pip-wheels
pip install virtualenv
# A step that sets up the python virtual environment
- script:
name: setup virtual environment
code: |
virtualenv /root/venv
export WERCKER_WHEEL_DIR=/pipeline/cache/pip-wheels
export PIP_FIND_LINKS=$WERCKER_CACHE_DIR/pip-wheels
export PIP_USE_WHEEL=true
# Installing the CI requirements, incl. coveralls and coverage
- script:
name: install coverage/coveralls outside of requirements.txt w/wheel
code: |
apk add git
pip install coverage coveralls codecov
# A step that executes `pip install` command.
- pip-install:
name: pip install spbm requirements w/wheel
auto_run_wheel: True
# Yield some python information
- script:
name: python and pip version information
code: |
echo "python version $(python --version) running"
echo "pip version $(pip --version) running"
# Then we run the tests of our Django instance
- script:
name: run tests with coverage
code: |
python -m coverage run ./manage.py test -v 3
# Once that's done, let's compile the current translation
- script:
name: compile translation messages
code: |
python ./manage.py compilemessages
# We're done with our building now: seeing as the build has successfully been completed,
# we now report the coverage for our tests.
- script:
name: reporting to coveralls
code: |
info "Setting up environment variables for correct coveralls reporting"
export CI_NAME='wercker'
export CI_BRANCH=$WERCKER_GIT_BRANCH
export CI_BUILD_URL=$WERCKER_BUILD_URL
info "Report to coveralls"
COVERALLS_REPO_TOKEN=$COVERALLS_TOKEN coveralls
codecov
################################################################################
# Deployment pipeline
# - Takes care of putting the bits and bytes in the right place.
production:
steps:
- script: install prerequisites
code: |
apk update
apk add bash openssh
- wercker/[email protected]:
keyname: SPF
user: $SPF_USERNAME
- wercker/[email protected]:
hostname: spf.cyb.no
fingerprint: SHA256:z1n0z2+/B6JFYsET70Lg9AAIUTmvnDKblG7cz6AOOLA
- script: execute deployment script
code: |
ssh [email protected] /bin/bash << EOF
set -ex
if ! [ -d ~/src ]; then
git clone [email protected]:SPF-UiO/spbm.git src
cd ~/src
git checkout master
virtualenv -p python3 --prompt "(spbm)" .virtualenv
./scripts/update.sh && ./scripts/run_production.sh
else
cd ~/src
(./scripts/backup.sh && git fetch && git reset --hard origin/master)
./scripts/update.sh
fi
EOF