-
Notifications
You must be signed in to change notification settings - Fork 29
214 lines (183 loc) · 5.91 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
name: Continuous Integration
on:
pull_request:
types: [opened, synchronize, labeled]
concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true
jobs:
# JOB to run change detection
changes:
runs-on: ubuntu-22.04
outputs:
# Expose matched filters as job 'charts' output variable
charts: ${{ steps.changes.outputs.charts }}
# flag of file changes
changed: ${{ steps.changes.outputs.changed }}
steps:
- name: Checkout
uses: actions/checkout@v2
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
# Match all, excluding README.md and README.md.gotmpl (micromatch syntax)
rasa:
- '!(charts/rasa/README*)charts/rasa/**'
rasa-action-server:
- '!(charts/rasa-action-server/README*)charts/rasa-action-server/**'
duckling:
- '!(charts/duckling/README*)charts/duckling/**'
rasa-common:
- '!(charts/rasa-common/README*)charts/rasa-common/**'
- name: Print output
id: changes
run: |
CHANGED=${{ fromJSON(steps.filter.outputs.changes)[0] != null }}
echo "::set-output name=changed::${CHANGED}"
if [[ "${CHANGED}" == "true" ]]; then
echo "::set-output name=charts::${{ toJSON(steps.filter.outputs.changes) }}"
else
echo "::set-output name=charts::[\"rasa\"]"
fi
lint-chart:
runs-on: ubuntu-22.04
needs: changes
steps:
- name: Checkout
if: needs.changes.outputs.changed == 'true'
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Helm
if: needs.changes.outputs.changed == 'true'
uses: azure/setup-helm@v3
with:
version: v3.11.2
# helm/chart-testing-action requires python version >= 3.7
# see: https://github.com/helm/chart-testing-action/issues/65
- uses: actions/setup-python@v2
if: needs.changes.outputs.changed == 'true'
with:
python-version: 3.7
- name: Set up chart-testing
if: needs.changes.outputs.changed == 'true'
uses: helm/chart-testing-action@v2.1.0
- name: Run chart-testing (lint)
if: needs.changes.outputs.changed == 'true'
run: ct lint --config .github/.ct.yaml
unit-tests:
runs-on: ubuntu-22.04
needs: changes
strategy:
matrix:
test:
- ./test/common
- ./charts/rasa/test
- ./charts/rasa-action-server/test
- ./charts/duckling/test
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.20.2'
- name: Download dependencies
working-directory: ${{ matrix.test }}
run: go mod download -x all
- name: Helm dependency update
run: |
cd ./charts
for x in `ls`; do helm dependency update ./${x}; done
- name: Run tests
working-directory: ${{ matrix.test }}
run: |
helm repo add rasa https://helm.rasa.com
go mod tidy
go test -v
kubeval-chart:
runs-on: ubuntu-22.04
needs: changes
strategy:
matrix:
# When changing versions here, check that the version exists at: https://github.com/instrumenta/kubernetes-json-schema
k8s:
- v1.14.10
- v1.16.4
- v1.18.1
chart: ${{ fromJSON(needs.changes.outputs.charts) }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.11.2
- name: Render template
run: |
helm dep up charts/${{ matrix.chart }}
helm template -f .github/kubeval.values.yaml charts/${{ matrix.chart }} > ${{ matrix.chart }}.yaml
- name: Run kubeval
uses: instrumenta/kubeval-action@5915e4adba5adccac07cb156b82e54c3fed74921
env:
KUBEVAL_SCHEMA_LOCATION: https://kubernetesjsonschema.dev/
with:
files: ${{ matrix.chart }}.yaml
ignore_missing_schemas: true
install-chart:
name: Install chart
runs-on: ubuntu-20.04
needs:
- lint-chart
- kubeval-chart
- changes
strategy:
matrix:
k8s:
- v1.14.10
- v1.16.9
- v1.18.4
chart: ${{ fromJSON(needs.changes.outputs.charts) }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Create kind ${{ matrix.k8s }} cluster
uses: helm/kind-action@94729529f85113b88f4f819c17ce61382e6d8478 # v1.2.0
with:
node_image: kindest/node:${{ matrix.k8s }}
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.11.2
- name: Install chart
run: |
helm dep up charts/${{ matrix.chart }}
helm install ${{ matrix.chart }} charts/${{ matrix.chart }}
- name: Test Rasa
timeout-minutes: 10
if: matrix.chart == 'rasa'
run: |
until kubectl wait --timeout=10s --for=condition=Ready --selector app.kubernetes.io/name=rasa pod; do
kubectl get pods
sleep 1
done
kubectl logs -c rasa-oss -l app.kubernetes.io/name=rasa
kubectl get svc
export SERVICE_PORT=$(kubectl get -o jsonpath="{.spec.ports[0].port}" services rasa)
kubectl port-forward svc/rasa ${SERVICE_PORT}:${SERVICE_PORT} &
until `nc -w 2 -z 127.0.0.1 ${SERVICE_PORT}`; do
echo "Waiting for ${SERVICE_PORT} port to be available."
sleep 1
done
curl -s http://127.0.0.1:${SERVICE_PORT}/
validate:
name: Validate the PR
runs-on: ubuntu-22.04
needs:
- unit-tests
- kubeval-chart
- install-chart
steps:
- name: Validate the PR
run: echo "All good!"