-
Notifications
You must be signed in to change notification settings - Fork 267
/
Copy pathwercker.yml
126 lines (112 loc) · 4.3 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
box: node:6.10
build:
steps:
- script:
name: A step that executes `npm install` command
code: npm install
# pipeline to store container on Oracle registry
push-to-releases:
steps:
# Push to public docker repo Container Registry (CR)
- internal/docker-push:
tag: $WERCKER_GIT_BRANCH-$WERCKER_GIT_COMMIT
cmd: node /pipeline/source/app.js
# pipeline to store container on Docker Hub
push-to-dockerhub:
steps:
# Push to public docker repo
- internal/docker-push:
username: $DOCKER_USERNAME
password: $DOCKER_PASSWORD
tag: $WERCKER_GIT_BRANCH-$WERCKER_GIT_COMMIT
repository: $DOCKER_USERNAME/$WERCKER_APPLICATION_NAME
registry: https://index.docker.io/v2/
cmd: node /pipeline/source/app.js
# pipeline to deploy application on kubernetes
deploy-to-oke:
box:
id: alpine
cmd: /bin/sh
steps:
- bash-template
- script:
name: "Visualise Kubernetes config"
code: cat kubernetes-deployment.yml
- kubectl:
name: create namespace
server: $KUBERNETES_MASTER
token: $KUBERNETES_TOKEN
insecure-skip-tls-verify: true
command: apply -f $WERCKER_ROOT/kubernetes-namespace.yml
- script:
name: wait to create namespace
code: sleep 10
- kubectl:
name: create OCR secret
server: $KUBERNETES_MASTER
token: $KUBERNETES_TOKEN
insecure-skip-tls-verify: true
command: create secret docker-registry wrelease --docker-server=wcr.io --docker-username=$WERCKER_APPLICATION_OWNER_NAME --docker-password=$KUBERNETES_TOKEN --docker-email=${WERCKER_APPLICATION_OWNER_NAME}@mail.com --namespace=$WERCKER_APPLICATION_OWNER_NAME; echo 'secret step'
- kubectl:
name: create deplyoment
server: $KUBERNETES_MASTER
token: $KUBERNETES_TOKEN
insecure-skip-tls-verify: true
command: apply -f $WERCKER_ROOT/kubernetes-deployment.yml --namespace=$WERCKER_APPLICATION_OWNER_NAME
- script:
name: "Visualise Ingress config"
code: cat ingress.yml
- kubectl:
name: create Ingress configuration
server: $KUBERNETES_MASTER
token: $KUBERNETES_TOKEN
insecure-skip-tls-verify: true
command: apply -f $WERCKER_ROOT/ingress.yml --namespace=$WERCKER_APPLICATION_OWNER_NAME
- kubectl:
name: get LoadBalancer public IP address
server: $KUBERNETES_MASTER
token: $KUBERNETES_TOKEN
insecure-skip-tls-verify: true
command: get svc -o jsonpath='{.items[*].status.loadBalancer.ingress[*].ip}' --all-namespaces
# pipeline to execute functional test on application's microservice endpoint
# single curl invocation
rest-functional-test:
steps:
- script:
name: Test Microservice
code: |
mkdir -p "/pipeline"
node $WERCKER_ROOT/app.js &
sleep 2
CREDITSCORE_URL=http://localhost:3000/creditscore
echo 'Microservice URL=' $CREDITSCORE_URL
if curl -X POST -H "Content-Type: application/json" -X POST -d '{"firstname":"John","lastname":"Doe","dateofbirth":"01/01/2015","ssn":"111223333"}' $CREDITSCORE_URL | grep "firstname"
then
# if the keyword is in the conent
echo "Test passed"
else
echo "Test failed"
exit -1
fi
# pipeline to execute functional test
# the test box prepared using headless chrome to execute ui test
ui-functional-test:
box:
id: peternagy/chrome-protractor-headless-test:node9.2-chrome62
steps:
- script:
name: Run UI test
code: |
nohup node $WERCKER_ROOT/app.js > creditscoreapp.log &
echo 'Application URL to test: http://localhost:3000/creditscore'
protractor $WERCKER_ROOT/test/protractor.conf.js
exit_status=$?
echo 'CreditScore app server log :::START'
cat creditscoreapp.log
echo 'CreditScore app server log :::END'
if [ $exit_status -eq 0 ]; then
echo "UI test passed"
else
echo "UI test failed"
exit -1
fi