Skip to content

Commit

Permalink
Merge pull request #570 from yeatmanlab/fix/test-concurrency
Browse files Browse the repository at this point in the history
Fix Cypress Test Concurrency
  • Loading branch information
richford committed May 16, 2024
2 parents 5ad9cb4 + e625fb9 commit 4462d5b
Show file tree
Hide file tree
Showing 46 changed files with 1,101 additions and 264 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cypress-network-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Cypress Network Tests
name: Cypress Pre-Release Tests
on:
workflow_run:
workflows: ['Deploy to Firebase Hosting (production)']
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,22 @@
name: Firebase Deploy to Staging and Cypress e2e Tests
name: Run Cypress Participant Tests
on:
pull_request:
types: [opened, reopened, synchronize]

concurrency:
group: ci-preview-tests-${{ github.ref }}-1
group: ci-preview-tests-${{ github.ref }}-3
cancel-in-progress: true

jobs:
build-and-preview:
name: Deploy preview
if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: 'vite build'
run: npm ci && npm run build
- name: Deploy to Firebase Hosting Channel
id: firebase-deploy
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_GSE_ROAR_ADMIN }}'
projectId: gse-roar-admin
target: staging
- run: echo ${{ fromJson(steps.firebase-deploy.outputs.urls)[0] }}
outputs:
deployUrl: ${{ fromJson(steps.firebase-deploy.outputs.urls)[0] }}

cypress-run:
name: Run Cypress Tests
needs: [build-and-preview]
name: Run Cypress Participant Tests
runs-on: ubuntu-latest
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
browser: [chromium, edge]
containers: [1, 2, 3, 4]
containers: [1, 2]
env:
NODE_OPTIONS: '--max_old_space_size=8192'
NODE_ENV: 'test'
Expand Down Expand Up @@ -69,5 +45,5 @@ jobs:
wait-on-timeout: 120
record: true
parallel: true
spec: 'cypress/e2e/participant/default-tests/**/*,cypress/e2e/partner-admin/default-tests/**/*'
spec: 'cypress/e2e/participant/default-tests/**/*'
ci-build-id: ${{ github.run_id }}-${{ matrix.browser }}
49 changes: 49 additions & 0 deletions .github/workflows/cypress-partner-admin-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Run Cypress Partner Admin Tests
on:
pull_request:
types: [opened, reopened, synchronize]

concurrency:
group: ci-preview-tests-${{ github.ref }}-2
cancel-in-progress: true

jobs:
cypress-run:
name: Run Cypress Partner Admin Tests
runs-on: ubuntu-latest
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
browser: [chromium, edge]
containers: [1, 2]
env:
NODE_OPTIONS: '--max_old_space_size=8192'
NODE_ENV: 'test'
CYPRESS_BASE_URL: 'http://localhost:5173'
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
COMMIT_INFO_MESSAGE: Tests for PR ${{ github.event.number }} "${{ github.event.pull_request.title }}" from commit "${{ github.event.pull_request.head.sha }}"
COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }}
PARTNER_ADMIN_USERNAME: ${{ secrets.PARTNER_ADMIN_USERNAME }}
PARTNER_ADMIN_PASSWORD: ${{ secrets.PARTNER_ADMIN_PASSWORD }}
PARTNER_ADMIN_ID: ${{ secrets.PARTNER_ADMIN_ID }}
PARTICIPANT_USERNAME: ${{ secrets.PARTICIPANT_USERNAME}}
PARTICIPANT_PASSWORD: ${{ secrets.PARTICIPANT_PASSWORD }}
PARTICIPANT_EMAIL: ${{ secrets.PARTICIPANT_EMAIL }}
PARTICIPANT_EMAIL_PASSWORD: ${{ secrets.PARTICIPANT_EMAIL_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cypress run
uses: cypress-io/github-action@v6
with:
browser: ${{ matrix.browser }}
build: npm ci && npm run build
start: npm run dev
wait-on: ${{ env.CYPRESS_BASE_URL }}
wait-on-timeout: 120
record: true
parallel: true
spec: 'cypress/e2e/partner-admin/default-tests/**/*'
ci-build-id: ${{ github.run_id }}-${{ matrix.browser }}
32 changes: 32 additions & 0 deletions .github/workflows/firebase-hosting-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build and Deploy
on:
pull_request:
types: [opened, reopened, synchronize]

concurrency:
group: ci-preview-tests-${{ github.ref }}-1
cancel-in-progress: true

jobs:
build-and-preview:
name: Deploy Preview
if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: 'vite build'
run: npm ci && npm run build
- name: Deploy to Firebase Hosting Channel
id: firebase-deploy
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_GSE_ROAR_ADMIN }}'
projectId: gse-roar-admin
target: staging
- run: echo ${{ fromJson(steps.firebase-deploy.outputs.urls)[0] }}
outputs:
deployUrl: ${{ fromJson(steps.firebase-deploy.outputs.urls)[0] }}
44 changes: 40 additions & 4 deletions .github/workflows/firebase-hosting-production.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,52 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting (production)
name: Deploy to Firebase Hosting (production) with Pre-Release Tests
'on':
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+'
jobs:
build_and_deploy:
name: Deploy
# pre-release-tests:
# name: Run Cypress Pre-Release Tests
# needs: [build-and-preview]
# runs-on: ubuntu-latest
# timeout-minutes: 180
# strategy:
# fail-fast: false
# matrix:
# browser: [chromium, edge]
# containers: [1, 2]
# env:
# NODE_ENV: 'test'
# CYPRESS_BASE_URL: 'http://localhost:5173'
# CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# COMMIT_INFO_MESSAGE: Pre release tests for ROAR Dashboard release ${{ github.event.release.tag_name }} "${{ github.event.release.name }}"
# COMMIT_INFO_SHA: ${{ github.event.release.release_id }}
# PARTICIPANT_USERNAME: ${{ secrets.PARTICIPANT_USERNAME}}
# PARTICIPANT_PASSWORD: ${{ secrets.PARTICIPANT_PASSWORD }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Cypress run
# uses: cypress-io/github-action@v6
# with:
# browser: ${{ matrix.browser }}
# build: npm ci && npm run build
# start: npm run dev
# wait-on: ${{ env.CYPRESS_BASE_URL }}
# wait-on-timeout: 120
# record: true
# parallel: true
# spec: 'cypress/e2e/pre-release-tests/**/*'
# ci-build-id: ${{ github.run_id }}-${{ matrix.browser }}

build-and-deploy:
name: Deploy to Firebase Production Hosting Channel
needs: [pre-release-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -37,7 +73,7 @@ jobs:
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
environment: production
sourcemap: ./dist/assets/*.js.map
sourcemaps: ./dist/assets/*.js.map
version: ${{ github.ref }}

- name: Notify on failure
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
import { playFluency } from '../../../../support/helper-functions/roam-fluency/fluencyHelpers';
import { playFluencyARF } from '../../../../support/helper-functions/roam-fluency/fluencyHelpers';
import { isCurrentVersion } from '../../../../support/utils';

const timeout = Cypress.env('timeout');
const administration = Cypress.env('testSpanishRoarAppsAdministration');
const language = 'es';
const task = 'fluency-arf-es';
const endText = 'Has terminado.';

const app = '@bdelab/roam-fluency';

describe('Test playthrough of Fluency ARF ES as a participant', () => {
it('Fluency Playthrough Test', () => {
Cypress.on('uncaught:exception', () => {
return false;
cy.wrap(isCurrentVersion(app)).then((isCurrentVersion) => {
if (isCurrentVersion) {
cy.log(`Did not detect a new version of ${app}, skipping test.`);
} else {
cy.log(`Detected a new version of ${app}, running test.`);
playFluencyARF({
administration: administration,
language: language,
task: task,
endText: endText,
});
}
});

cy.login(Cypress.env('participantUsername'), Cypress.env('participantPassword'));
cy.visit('/');

cy.selectAdministration(administration);

cy.get('.p-tabview').contains('ROAM - Un Dígito');
cy.visit(`/game/fluency-arf-es`);

// Click jspsych button to begin
cy.get('.jspsych-btn', { timeout: 5 * timeout })
.should('be.visible')
.click();

playFluency(endText);

// Check if game is marked as complete on the dashboard
cy.visit('/');
cy.wait(0.2 * timeout);
cy.selectAdministration(administration);
cy.get('.tabview-nav-link-label').contains('ROAM - Un Dígito').should('exist');
});
});
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
import { playFluency } from '../../../../support/helper-functions/roam-fluency/fluencyHelpers';
import { playFluencyCALF } from '../../../../support/helper-functions/roam-fluency/fluencyHelpers';
import { isCurrentVersion } from '../../../../support/utils';

const timeout = Cypress.env('timeout');
const administration = Cypress.env('testSpanishRoarAppsAdministration');
const language = 'es';
const task = 'fluency-calf-es';
const endText = 'Has terminado.';
const continueText = 'continuar';

const app = '@bdelab/roam-fluency';

describe('Test playthrough of Fluency ARF ES as a participant', () => {
it('Fluency Playthrough Test', () => {
Cypress.on('uncaught:exception', () => {
return false;
cy.wrap(isCurrentVersion(app)).then((isCurrentVersion) => {
if (isCurrentVersion) {
cy.log(`Did not detect a new version of ${app}, skipping test.`);
} else {
cy.log(`Detected a new version of ${app}, running test.`);
playFluencyCALF({
administration: administration,
language: language,
task: task,
endText: endText,
continueText: continueText,
});
}
});

cy.login(Cypress.env('participantUsername'), Cypress.env('participantPassword'));
cy.visit('/');

cy.selectAdministration(administration);

cy.get('.p-tabview').contains('ROAM - Varios Dígitos');
cy.visit(`/game/fluency-calf-es`);

// Click jspsych button to begin
cy.get('.jspsych-btn', { timeout: 5 * timeout })
.should('be.visible')
.click();

playFluency(endText, continueText);

// Check if game is marked as complete on the dashboard
cy.visit('/');
cy.wait(0.2 * timeout);
cy.selectAdministration(administration);
cy.get('.tabview-nav-link-label').contains('ROAM - Varios Dígitos').should('exist');
});
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import { playLetter } from '../../../../support/helper-functions/roar-letter/letterHelpers';
import { isCurrentVersion } from '../../../../support/utils';

const administration = Cypress.env('testSpanishRoarAppsAdministration');
const language = 'es';
const gameCompleteText = '¡Has terminado! ¡Gracias por ayudarme a encontrar esas letras!';

const app = '@bdelab/roar-letter';

describe('ROAR - Letra Play Through', () => {
it('Plays Letra', () => {
playLetter(administration, language, gameCompleteText);
cy.wrap(isCurrentVersion(app)).then((isCurrentVersion) => {
if (isCurrentVersion) {
cy.log(`Did not detect a new version of ${app}, skipping test.`);
} else {
cy.log(`Detected a new version of ${app}, running test.`);
playLetter({
administration: administration,
language: language,
gameCompleteText: gameCompleteText,
});
}
});
});
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import { playSRE } from '../../../../support/helper-functions/roar-sre/sreHelpers';
import { isCurrentVersion } from '../../../../support/utils';

const administration = Cypress.env('testSpanishRoarAppsAdministration');
const language = 'es';

const app = '@bdelab/roar-sre';

describe('ROAR - Sentence Play Through', () => {
it('Plays SRE', () => {
playSRE(administration, language);
cy.wrap(isCurrentVersion(app)).then((isCurrentVersion) => {
if (isCurrentVersion) {
cy.log(`Did not detect a new version of ${app}, skipping test.`);
} else {
cy.log(`Detected a new version of ${app}, running test.`);
playSRE({
administration: administration,
language: language,
});
}
});
});
});
15 changes: 14 additions & 1 deletion cypress/e2e/participant/default-tests/es-tests/playWord-ES.cy.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import { playSWR } from '../../../../support/helper-functions/roar-swr/swrHelpers.js';
import { isCurrentVersion } from '../../../../support/utils';

const administration = Cypress.env('testSpanishRoarAppsAdministration');
const language = 'es';

const app = '@bdelab/roar-swr';

describe('ROAR - Palabra Play Through', () => {
it('Plays Word', () => {
playSWR(administration, language);
cy.wrap(isCurrentVersion(app)).then((isCurrentVersion) => {
if (isCurrentVersion) {
cy.log(`Did not detect a new version of ${app}, skipping test.`);
} else {
cy.log(`Detected a new version of ${app}, running test.`);
playSWR({
administration: administration,
language: language,
});
}
});
});
});
Loading

0 comments on commit 4462d5b

Please sign in to comment.