-
Notifications
You must be signed in to change notification settings - Fork 20
139 lines (116 loc) · 4.82 KB
/
ci.yaml
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
name: Create namespace and deploy on new branch
on:
push:
branches:
- 'feature-**'
concurrency:
group: ${{ github.ref }}
cancel-in-progress: false
jobs:
create:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v1
- name: Authenticate and set context
uses: redhat-actions/oc-login@v1
with:
# URL to your OpenShift cluster.
# Refer to Step 2.
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER_FIWARE }}
# Authentication Token. Can use username and password instead.
# Refer to Step 3.
openshift_token: ${{ secrets.OPENSHIFT_TOKEN_FIWARE }}
# Disables SSL cert checking. Use this if you don't have the certificate authority data.
insecure_skip_tls_verify: true
# extract the current branch name and provide it as a var for easier integration into sed-commands
- name: Get branch name
id: branch-name
uses: tj-actions/[email protected]
- name: Log the branch name
run: |
echo ${{ steps.branch-name.outputs.current_branch }}
- name: Create namespace
run: |
oc new-project ${{ steps.branch-name.outputs.current_branch }} || oc project ${{ steps.branch-name.outputs.current_branch }}
oc adm policy add-role-to-group cluster-admin lodestar-developers -n ${{ steps.branch-name.outputs.current_branch }}
- name: Rename target branch
run: |
cd fiware-platform/
# replace the default destination namespace(demo) with the branch namespace
sed -i'' -e 's/destination_namespace: \&destination demo/destination_namespace: \&destination ${{ steps.branch-name.outputs.current_branch }}/g' values.yaml
# prefix the application name with the branch name to avoid collisions
sed -i'' -e 's/release: demo/release: ${{ steps.branch-name.outputs.current_branch }}/g' values.yaml
# set the target revision to the current branch
sed -i'' -e 's/branch: \&branch main/branch: \&branch ${{ steps.branch-name.outputs.current_branch }}/g' values.yaml
# See https://github.com/helm/chart-releaser-action/issues/6
- name: Install Helm
run: |
curl -fsSLo get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
- name: Deploy applications
run: |
cd fiware-platform/
# render app of apps and apply it
helm template . | oc -n argocd apply -f -
cd ..
- name: Check if all apps are healthy
run: |
# wait for the changes to take place and potentially crash the applications
sleep 30
# bool to check if the apps are healthy
healthy=0
# counter to set a number of tries
try=0
tries=30
# get the list of apps in the namespace
componentsInstalled=$(grep "enabled: true" fiware-platform/values.yaml -c)
# check if the condition is met
while [ $healthy == 0 ] && [ $try -lt $tries ]
do
apps=$(oc get applications.argoproj.io --no-headers -n argocd -l destination-namespace=${{ steps.branch-name.outputs.current_branch }} | awk '{ print $3 }')
healthyapps=0
for app in $apps
do
if [ $app != "Healthy" ]
then
echo "Trying again in 10 seconds"
sleep 10
try=$(( try + 1 ))
break
elif [ $app == "Healthy" ]
then
healthyapps=$(( healthyapps + 1 ))
fi
if [ $healthyapps == $componentsInstalled ]
then
healthy=1
fi
done
done
if [ $try -eq $tries ]
then
echo "ERROR: Tried too many times"
exit 1
fi
- name: Deploy the helm charts for the e2e
run: |
# go to selenium-grid directory
cd tests/selenium-grid
# install selenium-grid
helm install --wait selenium . -n ${{ steps.branch-name.outputs.current_branch }}
# go to the e2e-test directory
cd ../e2e-test
# install the helm chart
helm install e2e . -n ${{ steps.branch-name.outputs.current_branch }}
- name: Uninstall marinera-e2e helm chart
if: always()
run: |
# uninstall the e2e helm chart
helm uninstall e2e -n ${{ steps.branch-name.outputs.current_branch }}
- name: Uninstall selenium-grid helm chart
if: always()
run: |
# uninstall the selenium-grid helm chart
helm uninstall selenium -n ${{ steps.branch-name.outputs.current_branch }}