Skip to content

Commit

Permalink
Updated regression tests to run on PR to develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-aravind committed Dec 2, 2024
1 parent d3518aa commit cebe7ec
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 73 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/build-production-deploy-s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ jobs:
environment: 'production'
grep: ''
grepTags: '@essential'
CYPRESS_ADMIN_EN_EMAIL: ${{ vars.CYPRESS_ADMIN_EN_EMAIL }}
CYPRESS_ADMIN_FR_EMAIL: ${{ vars.CYPRESS_ADMIN_FR_EMAIL }}
CYPRESS_GUEST_EN_EMAIL: ${{ vars.CYPRESS_GUEST_EN_EMAIL }}
CYPRESS_GUEST_FR_EMAIL: ${{ vars.CYPRESS_GUEST_FR_EMAIL }}
secrets:
DOCKER_PAT: ${{ secrets.DOCKER_PAT }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
Expand Down
17 changes: 0 additions & 17 deletions .github/workflows/build-staging-deploy-s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,7 @@ on:
branches:
- develop
jobs:
trigger-cypress-tests:
uses: ./.github/workflows/run-cypress-tests.yml
with:
environment: 'staging'
grep: ''
grepTags: '@general'
CYPRESS_ADMIN_EN_EMAIL: ${{ vars.CYPRESS_ADMIN_EN_EMAIL }}
CYPRESS_ADMIN_FR_EMAIL: ${{ vars.CYPRESS_ADMIN_FR_EMAIL }}
CYPRESS_GUEST_EN_EMAIL: ${{ vars.CYPRESS_GUEST_EN_EMAIL }}
CYPRESS_GUEST_FR_EMAIL: ${{ vars.CYPRESS_GUEST_FR_EMAIL }}
secrets:
DOCKER_PAT: ${{ secrets.DOCKER_PAT }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}

build-and-deploy:
needs: trigger-cypress-tests
env:
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
Expand Down
76 changes: 24 additions & 52 deletions .github/workflows/run-cypress-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,6 @@ on:
description: 'Grep tags for selecting tests'
required: false
default: '@essential'
CYPRESS_ADMIN_EN_EMAIL:
description: 'Admin email for English tests'
required: true
type: string
CYPRESS_ADMIN_FR_EMAIL:
description: 'Admin email for French tests'
required: true
type: string
CYPRESS_GUEST_EN_EMAIL:
description: 'Guest email for English tests'
required: true
type: string
CYPRESS_GUEST_FR_EMAIL:
description: 'Guest email for French tests'
required: true
type: string

workflow_call:
inputs:
Expand All @@ -47,22 +31,6 @@ on:
required: false
type: string
default: '@essential'
CYPRESS_ADMIN_EN_EMAIL:
description: 'Admin email for English tests'
required: true
type: string
CYPRESS_ADMIN_FR_EMAIL:
description: 'Admin email for French tests'
required: true
type: string
CYPRESS_GUEST_EN_EMAIL:
description: 'Guest email for English tests'
required: true
type: string
CYPRESS_GUEST_FR_EMAIL:
description: 'Guest email for French tests'
required: true
type: string

secrets:
DOCKER_PAT:
Expand Down Expand Up @@ -163,23 +131,31 @@ jobs:
- name: Pull cypress docker image
run: docker pull ghcr.io/kmdvs/cms-cypress_regression_tests:main

- name: Write grep and grepTags to cypress.env.json
- name: Run Cypress tests
run: |
mkdir -p cypress
cd cypress
mkdir -p logs screenshots videos
echo '{
"grep": "${{ inputs.grep }}",
"grepTags": "${{ inputs.grepTags }}"
}' > cypress.env.json
- name: Verify contents of cypress.env.json
run: |
cat cypress/cypress.env.json
grep_value="${{ inputs.grep }}"
echo "Original grep_value: '$grep_value'"
grep_value_clean=$(echo "$grep_value" | tr -d '\n\r')
echo "Cleaned grep_value: '$grep_value_clean'"
- name: Run Cypress tests
run: |
if [ -z "$grep_value_clean" ]; then
grep_value_json='""'
else
grep_value_json=$(printf '%s' "$grep_value_clean" | sed 's/"/\\"/g; s/.*/"&"/')
fi
echo "JSON grep_value: '$grep_value_json'"
# Properly format the --env argument for Cypress
env_json="{\"grepTags\":\"${{ inputs.grepTags }}\",\"grep\":${grep_value_json}}"
echo "Formatted env JSON: $env_json"
# Simulate the Cypress --env argument
env_arg=$(printf '%s' "$env_json")
echo "Simulated --env argument for Cypress: $env_arg"
# Validate JSON formatting
echo "$env_json" | jq . # Validate JSON formatting
base_url="http://test.footlight.app:3000/"
Expand All @@ -189,10 +165,7 @@ jobs:
-e DEBUG="" \
-e XDG_RUNTIME_DIR=/tmp/runtime \
-e CYPRESS_BASE_URL=$base_url \
-e CYPRESS_ADMIN_EN_EMAIL="${{ inputs.CYPRESS_ADMIN_EN_EMAIL }}" \
-e CYPRESS_ADMIN_FR_EMAIL="${{ inputs.CYPRESS_ADMIN_FR_EMAIL }}" \
-e CYPRESS_GUEST_EN_EMAIL="${{ inputs.CYPRESS_GUEST_EN_EMAIL }}" \
-e CYPRESS_GUEST_FR_EMAIL="${{ inputs.CYPRESS_GUEST_FR_EMAIL }}" \
-e CYPRESS_PRINT_LOGS_TO_CONSOLE="never" \
-e CYPRESS_ADMIN_EN_PASSWORD=${{ secrets.CYPRESS_PASSWORD }} \
-e CYPRESS_ADMIN_FR_PASSWORD=${{ secrets.CYPRESS_PASSWORD }} \
-e CYPRESS_GUEST_EN_PASSWORD=${{ secrets.CYPRESS_PASSWORD }} \
Expand All @@ -201,9 +174,8 @@ jobs:
-v ${GITHUB_WORKSPACE}/cypress/screenshots:/e2e/cypress/screenshots \
-v ${GITHUB_WORKSPACE}/cypress/videos:/e2e/cypress/videos \
-v ${GITHUB_WORKSPACE}/cypress/logs:/e2e/cypress/logs \
-v ${GITHUB_WORKSPACE}/cypress/cypress.env.json:/e2e/cypress/cypress.env.json \
ghcr.io/kmdvs/cms-cypress_regression_tests:main \
npx cypress run --browser firefox > ${GITHUB_WORKSPACE}/cypress/logs/debug-firefox.log 2>&1
npx cypress run --browser firefox --env "$env_arg"
- name: Upload Cypress Debug Logs
uses: actions/upload-artifact@v3
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/trigger-cypress-tests-on-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Run regression tests on pull request to Develop

on:
pull_request:
branches:
- develop

jobs:
trigger-cypress-tests:
uses: ./.github/workflows/run-cypress-tests.yml
with:
environment: 'staging'
grep: ''
grepTags: '@general'
secrets:
DOCKER_PAT: ${{ secrets.DOCKER_PAT }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}

0 comments on commit cebe7ec

Please sign in to comment.