Skip to content

Test webapps

Test webapps #410

Workflow file for this run

name: Test webapps
on:
push:
branches:
- 2023.3.x
schedule:
- cron: "30 9 * * *"
jobs:
cypress-run:
name: Cypress run
runs-on: ubuntu-latest
env:
CORTEZA_VERSION: 2023.3.6
CYPRESS_VERSION: 9.5.1
CYPRESS_HOST: http://corteza
CYPRESS_BASE_URL: http://corteza
CYPRESS_ADMIN_URL: http://corteza/admin
CYPRESS_COMPOSE_URL: http://corteza/compose
CYPRESS_WORKFLOW_URL: http://corteza/workflow
CYPRESS_REPORTER_URL: http://corteza/reporter
CYPRESS_ONE_URL: http://corteza/one
CYPRESS_PRIVACY_URL: http://corteza/privacy
CYPRESS_USER_EMAIL: [email protected]
CYPRESS_USER_EMAIL_NEW: [email protected]
CYPRESS_USER_PASSWORD: cypress123
CYPRESS_USER_PASSWORD_NEW: newcypress123
CYPRESS_USER_DPO: [email protected]
CYPRESS_USER_DPO_PASSWORD: [email protected]
AUTH_REQUEST_RATE_LIMIT: 0
FEDERATION_ENABLED: 'true'
FEDERATION_HOST: http://corteza
FEDERATION_LABEL: 'Corteza e2e federation host'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Pull docker images
run: docker-compose -f .github/docker-compose.yaml pull
- name: Run mailhog
run: docker-compose -f .github/docker-compose.yaml --project-directory cypress up -d mailhog
- name: Prepare npm packages
run: yarn
- name: Setup environment
env:
RELEASE_CRUST_SFTP_KEY: ${{ secrets.RELEASE_CRUST_SFTP_KEY }}
RELEASE_CRUST_SFTP_URI: ${{ secrets.RELEASE_CRUST_SFTP_URI }}
run: |
echo "SCREENSHOTS_GEN_FOLDER=$(date +"%Y%m%d%H%M%S")" >> $GITHUB_ENV && \
echo "TMP_KEY=$(mktemp)" >> $GITHUB_ENV
- name: Create crust key
env:
RELEASE_CRUST_SFTP_KEY: ${{ secrets.RELEASE_CRUST_SFTP_KEY }}
RELEASE_CRUST_KEY_FILE: ${{ env.TMP_KEY }}
run: |
echo ${RELEASE_CRUST_SFTP_KEY} | base64 -d > ${RELEASE_CRUST_KEY_FILE}
- name: Make folder for uploaded screenshots
env:
RELEASE_CRUST_SFTP_URI: ${{ secrets.RELEASE_CRUST_SFTP_URI }}
RELEASE_CRUST_KEY_FILE: ${{ env.TMP_KEY }}
SCREENSHOTS_GEN_FOLDER: ${{ env.SCREENSHOTS_GEN_FOLDER }}
run: |
printf '%s\n' 'cd screenshots' "mkdir ${SCREENSHOTS_GEN_FOLDER}" | sftp -q -o "StrictHostKeyChecking no" -i ${RELEASE_CRUST_KEY_FILE} ${RELEASE_CRUST_SFTP_URI}
- name: Run Admin tests
# specs cannot be inserted as --spec=file1.js,file2.js because cypress randomizes the list
run: |
docker-compose -f .github/docker-compose.yaml up -d corteza && \
docker-compose -f .github/docker-compose.yaml --project-directory . run \
--entrypoint='cypress run
--spec cypress/integration/basic-functionalities/server/Create_user.spec.js
--reporter mochawesome
--browser chrome' \
cypress && \
docker-compose -f .github/docker-compose.yaml --project-directory . run \
--entrypoint='cypress run
--spec cypress/integration/basic-functionalities/admin/index.js
--reporter mochawesome
--browser chrome' \
cypress
# Cypress overwrites the screenshots folder, we need to do this after
# each failed run
- name: Upload screenshots
if: failure()
env:
RELEASE_CRUST_SFTP_URI: ${{ secrets.RELEASE_CRUST_SFTP_URI }}
RELEASE_CRUST_KEY_FILE: ${{ env.TMP_KEY }}
SCREENSHOTS_GEN_FOLDER: ${{ env.SCREENSHOTS_GEN_FOLDER }}
run: |
printf '%s\n' "cd screenshots/${SCREENSHOTS_GEN_FOLDER}" 'put -r cypress/screenshots/*' | sftp -q -o "StrictHostKeyChecking no" -i ${RELEASE_CRUST_KEY_FILE} ${RELEASE_CRUST_SFTP_URI}
- name: Run Compose tests
if: success() || failure()
run: |
docker-compose -f .github/docker-compose.yaml restart corteza && \
docker-compose -f .github/docker-compose.yaml --project-directory . run \
--entrypoint='cypress run
--spec cypress/integration/basic-functionalities/server/Create_user.spec.js
--reporter mochawesome
--browser chrome' \
cypress
docker-compose -f .github/docker-compose.yaml --project-directory . run \
--entrypoint='cypress run
--spec cypress/integration/basic-functionalities/compose/index.js
--reporter mochawesome
--browser chrome' \
cypress
- name: Upload screenshots
if: failure()
env:
RELEASE_CRUST_SFTP_URI: ${{ secrets.RELEASE_CRUST_SFTP_URI }}
RELEASE_CRUST_KEY_FILE: ${{ env.TMP_KEY }}
SCREENSHOTS_GEN_FOLDER: ${{ env.SCREENSHOTS_GEN_FOLDER }}
run: |
printf '%s\n' "cd screenshots/${SCREENSHOTS_GEN_FOLDER}" 'put -r cypress/screenshots/*' | sftp -q -o "StrictHostKeyChecking no" -i ${RELEASE_CRUST_KEY_FILE} ${RELEASE_CRUST_SFTP_URI}
- name: Run Server tests
if: success() || failure()
run: |
docker-compose -f .github/docker-compose.yaml restart corteza && \
docker-compose -f .github/docker-compose.yaml --project-directory . run \
--entrypoint='cypress run
--spec cypress/integration/basic-functionalities/server/Create_user.spec.js
--reporter mochawesome
--browser chrome' \
cypress
docker-compose -f .github/docker-compose.yaml --project-directory . run \
--entrypoint='cypress run
--spec cypress/integration/basic-functionalities/one/index.js
--reporter mochawesome
--browser chrome'\
cypress
- name: Upload screenshots
if: failure()
env:
RELEASE_CRUST_SFTP_URI: ${{ secrets.RELEASE_CRUST_SFTP_URI }}
RELEASE_CRUST_KEY_FILE: ${{ env.TMP_KEY }}
SCREENSHOTS_GEN_FOLDER: ${{ env.SCREENSHOTS_GEN_FOLDER }}
run: |
printf '%s\n' "cd screenshots/${SCREENSHOTS_GEN_FOLDER}" 'put -r cypress/screenshots/*' | sftp -q -o "StrictHostKeyChecking no" -i ${RELEASE_CRUST_KEY_FILE} ${RELEASE_CRUST_SFTP_URI}
- name: Run Reporter, topbar, Workflows tests
if: success() || failure()
run: |
docker-compose -f .github/docker-compose.yaml restart corteza && \
docker-compose -f .github/docker-compose.yaml --project-directory . run \
--entrypoint='cypress run
--spec cypress/integration/basic-functionalities/reporter/index.js,cypress/integration/basic-functionalities/topbar/index.js,cypress/integration/basic-functionalities/workflow/index.js
--reporter mochawesome
--browser chrome' \
cypress
- name: Upload screenshots
if: failure()
env:
RELEASE_CRUST_SFTP_URI: ${{ secrets.RELEASE_CRUST_SFTP_URI }}
RELEASE_CRUST_KEY_FILE: ${{ env.TMP_KEY }}
SCREENSHOTS_GEN_FOLDER: ${{ env.SCREENSHOTS_GEN_FOLDER }}
run: |
printf '%s\n' "cd screenshots/${SCREENSHOTS_GEN_FOLDER}" 'put -r cypress/screenshots/*' | sftp -q -o "StrictHostKeyChecking no" -i ${RELEASE_CRUST_KEY_FILE} ${RELEASE_CRUST_SFTP_URI}
- name: Run Server tests
if: success() || failure()
run: |
docker-compose -f .github/docker-compose.yaml restart corteza && \
docker-compose -f .github/docker-compose.yaml --project-directory . run \
--entrypoint='cypress run
--spec cypress/integration/basic-functionalities/server/index.js
--reporter mochawesome
--browser chrome' \
cypress
- name: Upload screenshots
if: failure()
env:
RELEASE_CRUST_SFTP_URI: ${{ secrets.RELEASE_CRUST_SFTP_URI }}
RELEASE_CRUST_KEY_FILE: ${{ env.TMP_KEY }}
SCREENSHOTS_GEN_FOLDER: ${{ env.SCREENSHOTS_GEN_FOLDER }}
run: |
printf '%s\n' "cd screenshots/${SCREENSHOTS_GEN_FOLDER}" 'put -r cypress/screenshots/*' | sftp -q -o "StrictHostKeyChecking no" -i ${RELEASE_CRUST_KEY_FILE} ${RELEASE_CRUST_SFTP_URI}
- name: Publish results
# always() runs the step even when canceled manually
if: success() || failure()
env:
RELEASE_CRUST_SFTP_URI: ${{ secrets.RELEASE_CRUST_SFTP_URI }}
RELEASE_CRUST_KEY_FILE: ${{ env.TMP_KEY }}
run: |
npx mochawesome-merge "cypress/reports/*.json" > cypress/report.json && \
npx marge -o cypress/reports-build -f index.html -i cypress/report.json && \
echo "put cypress/reports-build/index.html" | sftp -q -o "StrictHostKeyChecking no" -i ${RELEASE_CRUST_KEY_FILE} ${RELEASE_CRUST_SFTP_URI}
- name: Send message on successful testing results
if: success()
uses: fadenb/[email protected]
env:
E2E_REPORTS_USER: ${{ secrets.E2E_REPORTS_USER }}
E2E_REPORTS_PASS: ${{ secrets.E2E_REPORTS_PASS }}
with:
homeserver: ${{ secrets.MATRIX_HOME_SERVER }}
token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
channel: ${{ secrets.MATRIX_ROOM_ID }}
message: |
✅ E2e tests passed 🙌 🎉
🔗 https://${{ secrets.E2E_REPORTS_USER }}:${{ secrets.E2E_REPORTS_PASS }}@releases.cortezaproject.org/e2e-reports/
- name: Send message on failed testing results
if: failure()
uses: fadenb/[email protected]
env:
E2E_REPORTS_USER: ${{ secrets.E2E_REPORTS_USER }}
E2E_REPORTS_PASS: ${{ secrets.E2E_REPORTS_PASS }}
with:
homeserver: ${{ secrets.MATRIX_HOME_SERVER }}
token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
channel: ${{ secrets.MATRIX_ROOM_ID }}
message: |
❌ E2e tests did not pass, screenshots provided
🔗 https://${{ secrets.E2E_REPORTS_USER }}:${{ secrets.E2E_REPORTS_PASS }}@releases.cortezaproject.org/e2e-reports/
📷 https://${{ secrets.E2E_REPORTS_USER }}:${{ secrets.E2E_REPORTS_PASS }}@releases.cortezaproject.org/e2e-reports/screenshots/${{ env.SCREENSHOTS_GEN_FOLDER }}/