Skip to content

Commit

Permalink
Cypress E2E Workflow (#43)
Browse files Browse the repository at this point in the history
- Adds E2E testing, using Cypress, to deployment pipeline
  • Loading branch information
jimwashbrook authored Jun 9, 2023
1 parent 1ade24d commit aea1c5f
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 15 deletions.
36 changes: 36 additions & 0 deletions .github/actions/run-e2e-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Run Cypress E2E tests
description: Run E2E tests using Cypress

inputs:
url:
required: true
type: string

runs:
using: composite

steps:
- name: Create Cypress config
shell: bash
run: echo "{ \"URL\" :\"${{ inputs.url }}\" }" > cypress.env.json
working-directory: ./tests/Dfe.PlanTech.Web.E2ETests/

- name: Build and test project
uses: cypress-io/github-action@v5
with:
working-directory: ./tests/Dfe.PlanTech.Web.E2ETests/
browser: chrome

- name: Store screenshots on test failure
uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots
path: ./tests/Dfe.PlanTech.Web.E2ETests/cypress/screenshots

- name: Store videos
uses: actions/upload-artifact@v3
if: always()
with:
name: cypress-videos
path: ./tests/Dfe.PlanTech.Web.E2ETests/cypress/videos
15 changes: 13 additions & 2 deletions .github/workflows/build-and-push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build & deploy to environment
on:
push:
branches: [ "main" ]

workflow_dispatch:
inputs:
environment:
Expand Down Expand Up @@ -134,4 +134,15 @@ jobs:
--set-env-vars Contentful__DeliveryApiKey=secretref:contentful--deliveryapikey \
Contentful__PreviewApiKey=secretref:contentful--previewapikey \
Contentful__SpaceId=secretref:contentful--spaceid \
Contentful__Environment=secretref:contentful--environment
Contentful__Environment=secretref:contentful--environment
run-tests:
name: Run E2E Tests
needs: [ set-env, deploy-image ]
runs-on: ubuntu-22.04
if: ${{ needs.set-env.outputs.environment }} == 'dev'
steps:
- name: Cypress tests
uses: ./.github/actions/run-e2e-tests
with:
url: ${{ secrets.AZ_FRONTDOOR_URL }}
16 changes: 3 additions & 13 deletions .github/workflows/code-pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ on:

env:
DOTNET_VERSION: ${{ vars.DOTNET_VERSION }}

jobs:
build-test-app:
name: Build and test
name: Build and run unit tests
runs-on: ubuntu-latest

steps:
Expand All @@ -30,14 +30,4 @@ jobs:
dotnet_version: ${{ env.DOTNET_VERSION }}

- name: Run unit tests
uses: ./.github/actions/run-unit-tests

build-docker-image:
name: Build docker image
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v3

- name: Build docker image
uses: ./.github/actions/build-docker-image
uses: ./.github/actions/run-unit-tests

0 comments on commit aea1c5f

Please sign in to comment.