152896: updated to use cypress for automation #8
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Cypress UI tests on isolated environment | |
on: | |
pull_request: | |
branches: [ main, '**-feature' ] | |
types: [ opened, synchronize, reopened] | |
push: | |
branches: [ main ] | |
env: | |
NODE_VERSION: 18.13.0 | |
LAST_COMMIT_SHA: default | |
BRANCH_NAME: main | |
jobs: | |
cypress: | |
name: Set up container and run tests | |
runs-on: ubuntu-22.04 | |
environment: development | |
defaults: | |
run: | |
working-directory: tests/DFE.FindInformationAcademiesTrusts.CypressTests | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- if: github.event_name == 'pull_request' | |
name: Get source branch for pull request | |
run: | | |
GIT_REF=${{ github.head_ref }} | |
echo "BRANCH_NAME=${GIT_REF}" >> $GITHUB_ENV | |
- name: Set SHA environment variable | |
run: | | |
echo "LAST_COMMIT_SHA=${GITHUB_SHA:(-7)}" >> $GITHUB_ENV | |
- name: Install dependencies | |
run: npm install | |
- name: Start services | |
working-directory: ./docker | |
run: docker compose -f docker-compose.ci.yml up -d | |
- name: Run the cypress tests | |
run: npm run cy:run -- --env url=http://localhost,authKey=TestSuperSecret | |
- name: Stop services | |
if: always() | |
working-directory: ./docker | |
run: docker compose -f docker-compose.ci.yml stop | |