Skip to content

Commit 26bf53f

Browse files
authored
Issue 100: fix e2e tests in CI (#124)
* Issue 100: fix e2e tests in CI * envsubst
1 parent c47cf05 commit 26bf53f

File tree

7 files changed

+56
-106
lines changed

7 files changed

+56
-106
lines changed

.github/workflows/lint-test.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ jobs:
1111
with:
1212
fetch-depth: 0
1313

14+
- name: Envsubst
15+
uses: danielr1996/[email protected]
16+
env:
17+
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
18+
with:
19+
input: charts/flagsmith/ci/e2e-test-values.yaml
20+
output: charts/flagsmith/ci/e2e-test-values.yaml
21+
1422
- name: Set up Helm
1523
uses: azure/setup-helm@v1
1624
with:

charts/flagsmith/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ apiVersion: v2
22
name: flagsmith
33
description: Flagsmith
44
type: application
5-
version: 0.15.0
6-
appVersion: 2.34.0
5+
version: 0.16.0
6+
appVersion: 2.42.1
77
dependencies:
88
- name: postgresql
99
repository: https://charts.helm.sh/stable

charts/flagsmith/ci/e2e-test-values.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
_destructiveTests:
22
enabled: true
3-
e2eMonster:
4-
useFirefox: true
3+
4+
frontend:
5+
extraEnv:
6+
SLACK_TOKEN: "${SLACK_TOKEN}"
7+
58
api:
69
extraEnv:
710
EMAIL_BACKEND: 'django.core.mail.backends.console.EmailBackend'
11+
FE_E2E_TEST_USER_EMAIL: [email protected]
812
influxdb2:
913
# Needed to set this for the tests to not fail. Possibly related to
1014
# https://github.com/Flagsmith/flagsmith/issues/340

charts/flagsmith/templates/_helpers.tpl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,21 @@ Frontend environment
225225
{{- define "flagsmith.frontend.environment" -}}
226226
- name: ASSET_URL
227227
value: '/'
228-
{{- if .Values.frontend.apiProxy.enabled }}
228+
{{- if and .Values.frontend.apiProxy.enabled false }}
229229
- name: PROXY_API_URL
230230
value: http://{{ include "flagsmith.fullname" . }}-api.{{ .Release.Namespace }}:{{ .Values.service.api.port }}
231231
- name: FLAGSMITH_PROXY_API_URL
232232
value: http://{{ include "flagsmith.fullname" . }}-api.{{ .Release.Namespace }}:{{ .Values.service.api.port }}
233233
{{- end }}
234234
{{- if and .Values._destructiveTests.enabled .Values._destructiveTests.testToken }}
235-
- name: E2E_TEST_TOKEN_PROD
235+
- name: E2E_TEST_TOKEN_E2E
236236
value: {{ .Values._destructiveTests.testToken | quote }}
237+
- name: E2E_TEST_TOKEN
238+
value: {{ .Values._destructiveTests.testToken | quote }}
239+
- name: FLAGSMITH_API
240+
value: {{ include "flagsmith.fullname" . }}-api.{{ .Release.Namespace }}:{{ .Values.service.api.port }}/api/v1/
241+
- name: ENABLE_INFLUXDB_FEATURES
242+
value: {{ .Values.influxdb2.enabled | ternary "true" "false" | squote }}
237243
{{- end }}
238244
{{- range $envName, $envValue := .Values.frontend.extraEnv }}
239245
- name: {{ $envName }}

charts/flagsmith/templates/tests/test-e2e-monster.yaml

Lines changed: 0 additions & 91 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{- if .Values.frontend.enabled }}
2+
{{- if and .Values._destructiveTests.enabled .Values._destructiveTests.e2e.enabled }}
3+
apiVersion: v1
4+
kind: Pod
5+
metadata:
6+
name: {{ template "flagsmith.fullname" . }}-test-e2e
7+
labels:
8+
{{- include "flagsmith.labels" . | nindent 4 }}
9+
app.kubernetes.io/component: test-e2e
10+
annotations:
11+
"helm.sh/hook": test
12+
spec:
13+
{{- if .Values.api.image.imagePullSecrets }}
14+
imagePullSecrets:
15+
{{ toYaml .Values.api.image.imagePullSecrets | indent 4 }}
16+
{{- end }}
17+
containers:
18+
- name: e2e
19+
image: {{ .Values._destructiveTests.e2e.image.repository }}:{{ .Values._destructiveTests.e2e.image.tag | default .Values.api.image.tag | default (printf "%s" .Chart.AppVersion) }}
20+
imagePullPolicy: {{ .Values.frontend.image.imagePullPolicy }}
21+
env: {{ include "flagsmith.frontend.environment" . | nindent 8 }}
22+
resources: {{ .Values._destructiveTests.e2e.resources | toYaml | nindent 8 }}
23+
command:
24+
- bash
25+
- -c
26+
- "sed -i 's|http://flagsmith-api:8000.*/|http://'$FLAGSMITH_API'|' ./env/project_e2e.js ./common/project.js && cat ./env/project_e2e.js ./common/project.js && npm run test"
27+
restartPolicy: Never
28+
{{- end }}
29+
{{- end }}

charts/flagsmith/values.yaml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,18 +317,12 @@ _destructiveTests:
317317
# A test is enabled if both this and the specific test is enabled
318318
enabled: false
319319
testToken: test-e2e-token
320-
# This "monster" is in lieu of a specially constructed Docker image
321-
# that contains the code and dependencies for running the e2e
322-
# tests. It works by starting from a plain Ubuntu container,
323-
# retrieving the commit SHA from the API container, then cloning the
324-
# code from Github, installing dependencies, then running the tests.
325-
e2eMonster:
320+
e2e:
326321
enabled: true
327322
image:
328-
repository: ubuntu
329-
tag: jammy
323+
repository: flagsmith/flagsmith-e2e-tests
324+
tag: null
330325
imagePullPolicy: IfNotPresent
331-
useFirefox: false
332326
resources:
333327
requests:
334328
memory: 1Gi

0 commit comments

Comments
 (0)