-
Notifications
You must be signed in to change notification settings - Fork 104
168 lines (140 loc) · 4.85 KB
/
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
name: Lint and Test Charts
on:
push:
branches:
- 'main'
- '[0-9]+.[0-9]+.x'
- 'bump-rasa-x-version*'
pull_request:
types:
- opened
- synchronize
env:
CHART: charts/rasa-x
INSTALL_K3S_VERSION: v1.21.4+k3s1
jobs:
lint-test:
name: Lint the chart
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install Helm
run: |
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- name: Lint chart using Helm CLI
run: |
helm dependency update ${CHART}
helm lint --strict ${CHART}
# helm/chart-testing-action requires python version >= 3.7
# see: https://github.com/helm/chart-testing-action/issues/65
- uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Run chart-testing (lint)
id: lint
uses: helm/chart-testing-action@b0d4458c71155b54fcf33e11dd465dc923550009
with:
command: lint
config: ct.yaml
test:
name: Unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install dependencies
run: |
helm dependency update ${CHART}
cd ./tests && go get -t || true
- name: Run tests
working-directory: ./tests
run: go test -v
deploy_chart:
name: Test the deployment of the chart
runs-on: ubuntu-latest
env:
RELEASE_NAME: test-release
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Setup k3s
run: |
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server --no-deploy traefik" sh
sudo chmod 744 /etc/rancher/k3s/k3s.yaml
echo "KUBECONFIG=/etc/rancher/k3s/k3s.yaml" >> $GITHUB_ENV
- name: Install Helm and helmfile ⛑
run: |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
sudo curl -fsSL https://github.com/roboll/helmfile/releases/download/v0.130.0/helmfile_linux_amd64 --output /usr/local/bin/helmfile
sudo chmod +x /usr/local/bin/helmfile
- name: Generate credentials 🔐
run: |
USER_PASSWORD=$(openssl rand -base64 32)
echo "INITIAL_USER_PASSWORD=${USER_PASSWORD}" >> $GITHUB_ENV
- name: Free disk space 🧹
# tries to make sure we do not run out of disk space, see
# https://github.community/t5/GitHub-Actions/BUG-Strange-quot-No-space-left-on-device-quot-IOExceptions-on/td-p/46101
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
docker rmi $(docker image ls -aq)
df -h
- name: Deploy ingress-nginx chart ☕️
run: |
helmfile -f .github/deployments/ingress-nginx-helmfile.yaml sync
- name: Wait for nginx deployment to be ready ⏱
run: |
kubectl wait \
--for=condition=Ready \
--timeout=90s \
-l "app.kubernetes.io/component=controller" pod
ADDRESS=$(kubectl get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
if [[ -z "$ADDRESS" ]]; then
echo "External IP address is empty" & exit 1
else
echo "External IP Address: ${ADDRESS}"
fi
- name: Deploy Rasa X chart ☕️
run: |
helmfile -f .github/deployments/rasa-x-helmfile.yaml sync
- name: Set host name and address env variables 🖌
run: |
ADDRESS=$(kubectl get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
HOST=$(kubectl get ingress -o jsonpath='{.items[0].spec.rules[0].host}')
if [[ -z "${ADDRESS}" ]]; then
echo "External IP address is empty" && exit 1
fi
if [[ -z "${HOST}" ]]; then
echo "No host found." && exit 1
fi
echo "ADDRESS=${ADDRESS}" >> $GITHUB_ENV
echo "HOST=${HOST}" >> $GITHUB_ENV
- name: Wait for deployment to be ready ⏱
run: |
kubectl wait \
--for=condition=available \
--timeout=20m \
-l "app.kubernetes.io/component=rasa-x" deployment
# add external IP address and host name to /etc/hosts
echo "${ADDRESS} ${HOST}" | sudo tee -a /etc/hosts
until [[ "$(curl -s http://${HOST}/api/health | tee /tmp/output_status.txt | jq -r .database_migration.status)" == "completed" ]]
do
cat /tmp/output_status.txt || true
sleep 5
done
- name: Log pod status for debugging 🖥
if: failure()
run: |
kubectl get pods
kubectl get svc
kubectl logs rasa-x-postgresql-0
df -h