Skip to content

Cypress/e2e tests

Cypress/e2e tests #131

name: End to End Cypress Test
on:
push:
branches:
- cypress/e2e-tests
paths:
- "e2e-tests/**"
- "frontend/**"
- "!backend/src/zango/assets/app_panel/js/**"
pull_request:
types:
- opened
- reopened
- synchronize
branches:
- main
paths:
- "frontend/**"
- "e2e-tests/**"
- "!backend/src/zango/assets/app_panel/js/**"
# workflow_run:
# workflows: ["Push build to Main"]
# branches:
# - cypress/e2e-tests
# types:
# - completed
jobs:
cypress-run:
runs-on: ubuntu-latest
name: E2E on Chrome
steps:
# Step 1: Checkout repo
- name: Checkout
uses: actions/checkout@v3
- name: Remove old build files
run: |
find backend/src/zango/assets/app_panel/js -name "build.*.min.js" -type f -delete
find backend/src/zango/assets/app_panel/js -name "build.*.min.js.LICENSE.txt" -type f -delete
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: "16"
- name: Install dependencies
run: |
cd frontend
yarn install
- name: Building app
run: |
cd frontend
CI=false yarn build
- name: Remove old build files
run: |
find backend/src/zango/assets/app_panel/js -name "build.*.min.js.LICENSE.txt" -type f -delete
# Step 2: Confirm build completion
- name: Confirm build completion
run: echo "First workflow (Push build to Main) completed"
# Step 3: Set up zango project with latest zango build
- name: Setup latest zango project
uses: ./.github/actions/zango-project-setup-action
with:
platform_username: [email protected]
platform_user_password: Zango@123
project_name: zango_project
postgres_user: zango_admin
postgres_password: zangopass
postgres_db: zango
platform_domain_url: localhost
domain_config_path: ./e2e-tests/local_domains.txt
# Step 5: Capturing start time
- name: Capture Start Time
id: start-time
run: echo "START_TIME=$(date +%s)" >> $GITHUB_ENV
# Step 6: Install dependencies
- name: Install cypress dependencies
run: npm install
working-directory: e2e-tests
# Step 7: Run Cypress tests and record results
- name: Run Cypress tests
uses: cypress-io/github-action@v6
with:
browser: chrome
working-directory: e2e-tests
continue-on-error: true
#Step 8: Capturing end time
- name: Capture End Time
id: end-time
run: echo "END_TIME=$(date +%s)" >> $GITHUB_ENV
#Step 9: Calculating total duration of cypress tests
- name: Calculate Duration
id: duration
run: |
DURATION_SECONDS=$((END_TIME - START_TIME))
DURATION_MINUTES=$((DURATION_SECONDS / 60))
DURATION_REMAINDER_SECONDS=$((DURATION_SECONDS % 60))
DURATION="${DURATION_MINUTES}m ${DURATION_REMAINDER_SECONDS}s"
echo "DURATION=${DURATION}" >> $GITHUB_ENV
- name: Extract Version
id: extract_version
run: |
ZANGO_VERSION=$(grep '__version__' backend/src/zango/__init__.py | sed 's/.*__version__ = "\(.*\)"/\1/' | tail -1)
echo "ZANGO_VERSION=${ZANGO_VERSION}" >> $GITHUB_ENV
# Step 10: Generate Cucumber HTML Report
- name: Generate Cucumber HTML Report
run: |
echo "Running cucumber-html-report.js"
ls -la
node cucumber-html-report.js
working-directory: e2e-tests
env:
BROWSER_NAME: chrome
BROWSER_VERSION: "127"
DEVICE_NAME: "Remote Device"
PLATFORM_NAME: "Ubuntu"
PLATFORM_VERSION: "22.04.4"
CI_ENVIRONMENT: "GitHub Actions"
# Step 11: Upload Cypress screenshots
- name: Upload Cypress screenshots
uses: actions/upload-artifact@v3
with:
name: cypress-screenshots
path: e2e-tests/cypress/screenshots
if-no-files-found: ignore
# Step 12: Upload Cypress videos
- name: Upload Cypress videos
uses: actions/upload-artifact@v3
with:
name: cypress-videos
path: e2e-tests/cypress/videos
if-no-files-found: ignore
# Step 13: Upload Cucumber HTML Report
- name: Upload Cucumber HTML Report
uses: actions/upload-artifact@v3
with:
name: cucumber-html-report
path: e2e-tests/reports/cucumber-html-report.html
if-no-files-found: ignore