-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcircle.yml
166 lines (166 loc) · 6.28 KB
/
circle.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
version: 2
jobs:
build:
docker:
- image: ubuntu:16.04
environment:
TZ: "/usr/share/zoneinfo/Europe/paris"
hosts:
local-magento.hipay.com: 127.0.0.1
steps:
- checkout
- setup_remote_docker
- run:
name: Install dependencies
command: apt-get update && apt-get install -y curl wget bzip2 npm docker-compose sshpass
- run:
name: Install Docker client
command: |
set -x
VER="17.03.0-ce"
curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
mv /tmp/docker/* /usr/bin
- run:
name: Install PhantomJS
command: |
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2
mv phantomjs-2.1.1-linux-x86_64 /bin/
chmod a+x /bin/phantomjs-2.1.1-linux-x86_64
ln -s --force /bin/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
- run:
name: Install CasperJS & JUnit-Viewer
command: |
npm install -g [email protected]
npm install -g junit-viewer
- run:
name: Configure Environment
command: |
sed -i -e "s/{HIPAY_API_USER_TEST\}/$HIPAY_API_USER_TEST/" ./bin/conf/stage/hipay.env.sample
sed -i -e "s/{HIPAY_API_PASSWORD_TEST\}/$HIPAY_API_PASSWORD_TEST/" ./bin/conf/stage/hipay.env.sample
sed -i -e "s/{HIPAY_TOKENJS_PUBLICKEY_TEST\}/$HIPAY_TOKENJS_PUBLICKEY_TEST/" ./bin/conf/stage/hipay.env.sample
sed -i -e "s/{HIPAY_TOKENJS_USERNAME_TEST\}/$HIPAY_TOKENJS_USERNAME_TEST/" ./bin/conf/stage/hipay.env.sample
sed -i -e "s/{HIPAY_SECRET_PASSPHRASE_TEST\}/$HIPAY_SECRET_PASSPHRASE_TEST/" ./bin/conf/stage/hipay.env.sample
sed -i -e "s/{LOGIN_BACKEND\}/$LOGIN_BACKEND/" ./bin/conf/stage/test.env.sample
sed -i -e "s/{PASS_BACKEND\}/$PASS_BACKEND/" ./bin/conf/stage/test.env.sample
sed -i -e "s/{LOGIN_PAYPAL\}/$LOGIN_PAYPAL/" ./bin/conf/stage/test.env.sample
sed -i -e "s/{PASS_PAYPAL\}/$PASS_PAYPAL/" ./bin/conf/stage/test.env.sample
- run:
name: Add vhost
command: echo 127.0.0.1 local-magento.hipay.com | tee -a /etc/hosts
- run:
name: Create Artefacts directories & Generate DockerFile
command: |
mkdir $CIRCLE_ARTIFACTS/casper_report
mkdir $CIRCLE_ARTIFACTS/screenshots
sh bin/docker/generate_dockerfile.sh
test:
docker:
- image: ubuntu:16.04
steps:
- restore_cache:
keys:
- v1-{{ .Branch }}
paths:
- /caches/php5-6.tar
- /caches/php7-0.tar
- run:
name: Load Docker image PHP 5.6 layer cache
command: |
set +o pipefail
docker load -i /caches/php5-6.tar | true
- run:
name: Build application Docker image PHP 5.6
command: |
docker-compose -f docker-compose.yml -f docker-compose.stage.yml \
build --cache-from=php5-6 -t php5-6 .
- run:
name: Save Docker image PHP 5.6 layer cache
command: |
mkdir -p /caches
docker save -o /caches/php5-6.tar php5-6
- save_cache:
key: v1-{{ .Branch }}-{{ epoch }}
paths:
- /caches/php5-6.tar
- run:
name: Up PHP 5.6 container
command: |
docker-compose -f docker-compose.yml -f docker-compose.stage.yml up -d
sleep 60
curl --retry 30 --retry-delay 3 -v $MAGENTO_URL:$PORT_WEB
curl --retry 30 --retry-delay 3 -v $URL_MAILCATCHER
- run:
name: Launch Tests PHP 5.6
command: |
sh bin/tests/casper_run_circle.sh
junit-viewer --results=bin/tests/result.xml \
--save=bin/tests/report-php5-6.html --minify=false --contracted
if [ -d bin/tests/errors/ ]; then
mkdir $CIRCLE_ARTIFACTS/screenshots/php5-6
cp bin/tests/errors/* $CIRCLE_ARTIFACTS/screenshots/php5-6
rm -rf bin/tests/errors/
fi
- run:
name: Stop PHP 5.6 container
command: |
docker-compose stop
docker-compose rm -fv
- run:
name: Load Docker image PHP 7.0 layer cache
command: |
set +o pipefail
docker load -i /caches/php7-0.tar | true
- run:
name: Build application Docker image PHP 7.0
command: |
docker-compose -f docker-compose.yml -f docker-compose.stage-php7-0.yml \
build --cache-from=php7-0 -t php7-0 .
- run:
name: Save Docker image PHP 7.0 layer cache
command: |
mkdir -p /caches
docker save -o /caches/php7-0.tar php7-0
- save_cache:
key: v1-{{ .Branch }}-{{ epoch }}
paths:
- /caches/php7-0.tar
- run:
name: Up PHP 7.0 container
command: |
docker-compose -f docker-compose.yml -f docker-compose.stage-php7-0.yml up -d
sleep 60
curl --retry 30 --retry-delay 3 -v $MAGENTO_URL:$PORT_WEB
- run:
name: Run tests
command: |
sh bin/tests/casper_run_circle.sh
junit-viewer --results=bin/tests/result.xml \
--save=bin/tests/report-php7-0.html --minify=false --contracted
if [ -d bin/tests/errors/ ]; then
mkdir $CIRCLE_ARTIFACTS/screenshots/php7-0
cp bin/tests/errors/* $CIRCLE_ARTIFACTS/screenshots/php7-0
fi
- run:
name: Get reports as artefacts
command: |
cp bin/tests/report-php5-6.html $CIRCLE_ARTIFACTS/casper_report/
cp bin/tests/report-php7-0.html $CIRCLE_ARTIFACTS/casper_report/
- deploy:
name: Push module Magento1 to Docker-Machine
command: |
if [ "${CIRCLE_BRANCH}" == "develop" ]; then
sh ./bin/deployment/deploy_staging.sh
fi
workflows:
version: 2
build_and_test:
jobs:
- build
- test:
requires:
- build
- deploy:
requires:
- test