Skip to content
Snippets Groups Projects
cypress-test-nc-oo.yaml 3.9 KiB
Newer Older
apiVersion: v1
kind: Pod
metadata:
  name: "{{ include "onlyoffice-documentserver.fullname" . }}-cypress-test"
  labels:
    helm.sh/chart: {{ include "onlyoffice-documentserver.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
  annotations:
    "helm.sh/hook": test
spec:
  containers:
    - name: "{{ include "onlyoffice-documentserver.fullname" . }}-cypress-test"
      image: {{ .Values.tests.image.repository }}:{{ .Values.tests.image.tag }}
      imagePullPolicy: {{ .Values.tests.image.pullPolicy }}
      # [Cypress in docker fails to run with read-only project dir](https://github.com/cypress-io/cypress/issues/22502)
      # That's why we need to copy the project dir from the readonly /e2e configmap mount to /tmp/e2e
      - sh
      - -c
      - |
        cp -a /e2e /tmp
        cd /tmp/e2e
        npm install cypress-iframe
        if [ -n "$CYPRESS_RECORD_KEY" ]; then cypress run -P /tmp/e2e --record --key "$CYPRESS_RECORD_KEY" ; else cypress run -P /tmp/e2e; fi
        - name: CYPRESS_BASE_URL
          value: https://{{ .Values.nextcloud.nextcloud.host }}
        {{- if .Values.tests.ssoLogin.enabled }}
        - name: CYPRESS_USE_SSO_LOGIN
          value: "true"
        - name: CYPRESS_SSO_USER
          value: {{ .Values.tests.ssoLogin.username }}
        - name: CYPRESS_SSO_PW
          valueFrom:
            secretKeyRef:
Maarten de Waard's avatar
Maarten de Waard committed
              name: "{{ .Release.Name }}-sso-password"
              key: password
        - name: CYPRESS_NEXTCLOUD_ADMIN_USER
          value: admin
        - name: CYPRESS_NEXTCLOUD_ADMIN_PW
          valueFrom:
            secretKeyRef:
              name: {{ .Values.nextcloud.nextcloud.existingSecret.secretName | default (include "nextcloudname" .) }}
              key: {{ .Values.nextcloud.nextcloud.existingSecret.passwordKey | default "nextcloud-password" }}
        {{- end }}
        - name: CYPRESS_ONLYOFFICE_URL
          value: "{{ .Values.onlyoffice.server_name }}"
        {{- if .Values.tests.cypress.projectId }}
        - name: CYPRESS_PROJECT_ID
          value: "{{ .Values.tests.cypress.projectId }}"
        {{- end }}
        {{- if .Values.tests.cypress.recordKey }}
        - name: CYPRESS_RECORD_KEY
          value: {{ .Values.tests.cypress.recordKey }}
        {{- if .Values.tests.cypress.commitInfo }}
        {{- if .Values.tests.cypress.commitInfo.branch }}
        - name: COMMIT_INFO_BRANCH
          value: "{{ .Values.tests.cypress.commitInfo.branch }}"
        {{- end }}
        {{- if .Values.tests.cypress.commitInfo.message }}
        - name: COMMIT_INFO_MESSAGE
          # Use yaml literal style, so we can have quotes in the string.
          # Newlines might not be safe to include, but unlike the name suggests
          # in Stackspin we set this value to only the commit title.
          value: |
            {{ .Values.tests.cypress.commitInfo.message }}
        {{- end }}
        {{- if .Values.tests.cypress.commitInfo.author }}
        - name: COMMIT_INFO_AUTHOR
          # Use yaml literal style, so we can have quotes in the string.
          value: |
            {{ .Values.tests.cypress.commitInfo.author }}
        {{- end }}
        {{- if .Values.tests.cypress.commitInfo.sha }}
        - name: COMMIT_INFO_SHA
          value: "{{ .Values.tests.cypress.commitInfo.sha }}"
        - name: INSTALLED_APPS
          value: "{{ range .Values.apps }}{{ .name }},{{ end }}"
      volumeMounts:
        - name: cypress-config
          mountPath: /e2e
    - name: cypress-config
        name: {{ .Release.Name }}-cypress-config
        items:
        - key: cypress.config.js
          path: cypress.config.js
        - key: e2e.js
          path: cypress/support/e2e.js
        - key: test-nextcloud.cy.js
          path: cypress/e2e/test-nextcloud.cy.js
  restartPolicy: Never