Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More e2e testing changes #108

Merged
merged 15 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions .github/workflows/pull_request_cypress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Pull Request Cypress Testing

on:
pull_request_target:
types: [opened, synchronize, reopened]
branches: [master, main]

env:
PAGE_LIMIT: ${{ github.event.inputs.PAGE_LIMIT }}
SEARCH_KEYWORDS: ${{ github.event.inputs.SEARCH_KEYWORDS }}
FILTER_FACET: ${{ github.event.inputs.FILTER_FACET }}
MULTIPLE_FILTER_FACETS: ${{ github.event.inputs.MULTIPLE_FILTER_FACETS }}
DATASET_IDS: ${{ github.event.inputs.DATASET_IDS }}
TAXON_MODELS: ${{ github.event.inputs.TAXON_MODELS }}
THREE_SYNC_VIEW: ${{ github.event.inputs.THREE_SYNC_VIEW }}
SEARCH_IN_MAP: ${{ github.event.inputs.SEARCH_IN_MAP }}
SCAFFOLD_DATASET_IDS: ${{ github.event.inputs.SCAFFOLD_DATASET_IDS }}
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
ALGOLIA_INDEX: ${{ secrets.ALGOLIA_INDEX }}
AWS_USER_POOL_ID: ${{ secrets.AWS_USER_POOL_ID }}
AWS_USER_POOL_WEB_CLIENT_ID: ${{ secrets.AWS_USER_POOL_WEB_CLIENT_ID }}
BIOLUCIDA_PASSWORD: ${{ secrets.BIOLUCIDA_PASSWORD }}
BIOLUCIDA_USERNAME: ${{ secrets.BIOLUCIDA_USERNAME }}
BITLY_ACCESS_TOKEN: ${{ secrets.BITLY_ACCESS_TOKEN }}
BLACKFYNN_API_SECRET: ${{ secrets.BLACKFYNN_API_SECRET }}
BLACKFYNN_API_TOKEN: ${{ secrets.BLACKFYNN_API_TOKEN }}
BLACKFYNN_CONCEPTS_API_HOST: ${{ secrets.BLACKFYNN_CONCEPTS_API_HOST }}
CTF_API_HOST: ${{ secrets.CTF_API_HOST }}
CTF_CDA_ACCESS_TOKEN: ${{ secrets.CTF_CDA_ACCESS_TOKEN }}
CTF_SPACE_ID: ${{ secrets.CTF_SPACE_ID }}
DEPLOY_ENV: ${{ secrets.DEPLOY_ENV }}
DISABLE_REDIRECT_SSL: ${{ secrets.DISABLE_REDIRECT_SSL }}
FLATMAP_API_HOST: ${{ secrets.FLATMAP_API_HOST }}
LOGIN_API_URL: ${{ secrets.LOGIN_API_URL }}
NODE_ENV: ${{ secrets.NODE_ENV }}
NPM_CONFIG_PRODUCTION: ${{ secrets.NPM_CONFIG_PRODUCTION }}
OSPARC_HOST: ${{ secrets.OSPARC_HOST }}
PORTAL_API_HOST: ${{ secrets.PORTAL_API_HOST }}
RECAPTCHA_SECRET_KEY: ${{ secrets.RECAPTCHA_SECRET_KEY }}
RECAPTCHA_SITE_KEY: ${{ secrets.RECAPTCHA_SITE_KEY }}
SHOW_FUNDING_FACET: ${{ secrets.SHOW_FUNDING_FACET }}
SHOW_HIERARCHAL_FACETS: ${{ secrets.SHOW_HIERARCHAL_FACETS }}
SHOW_LOGIN_FEATURE: ${{ secrets.SHOW_LOGIN_FEATURE }}
SHOW_METRICS: ${{ secrets.SHOW_METRICS }}
SHOW_OSPARC_TAB: ${{ secrets.SHOW_OSPARC_TAB }}
SHOW_TIMESERIES_VIEWER: ${{ secrets.SHOW_TIMESERIES_VIEWER }}
SPARC_PORTAL_USER_ID: ${{ secrets.SPARC_PORTAL_USER_ID }}
SPARC_PORTAL_USER_SECRET: ${{ secrets.SPARC_PORTAL_USER_SECRET }}

jobs:
pull-request-cypress-run:
if: github.event_name == 'pull_request_target'
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4]

steps:
- uses: actions-cool/check-user-permission@main
id: checkUser
with:
require: "write"
username: ${{ github.event.pull_request.user.name }}

- name: Checkout
if: steps.checkUser.outputs.require-result == 'true'
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18.17.1

- name: Automated Run Testing when Pull Request
if: steps.checkUser.outputs.require-result == 'true'
uses: cypress-io/github-action@v6
env:
ROOT_URL: ${{ secrets.ROOT_URL }} # http://localhost:3000
with:
build: yarn build
start: yarn preview
wait-on: ${{ secrets.ROOT_URL }}
record: true
parallel: true

- name: Skip tests
if: steps.checkUser.outputs.require-result == 'false'
uses: actions/github-script@v4
with:
script: |
core.setFailed('Pull request is opened by an user without write permission, tests are skipped for security reason')
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
# This is a basic workflow to help you get started with Actions

name: Cypress Timeline Tests
name: Quality Control Cypress Testing

on:
# push:
# branches: [master, main]

pull_request_target:
types: [opened, synchronize, reopened]
branches: [master, main]

schedule:
- cron: "0 0 * * 1"

workflow_dispatch:
inputs:
PORTAL_TARGET:
Expand Down Expand Up @@ -113,107 +101,7 @@ env:
SPARC_PORTAL_USER_SECRET: ${{ secrets.SPARC_PORTAL_USER_SECRET }}

jobs:
pull-request-cypress-run:
if: github.event_name == 'pull_request_target'
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4]

steps:
- uses: actions-cool/check-user-permission@main
id: checkUser
with:
require: "write"
username: ${{ github.event.pull_request.user.name }}

- name: Checkout
if: steps.checkUser.outputs.require-result == 'true'
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18.17.1

- name: Automated Run Testing when Pull Request
if: steps.checkUser.outputs.require-result == 'true'
uses: cypress-io/github-action@v6
env:
ROOT_URL: ${{ secrets.ROOT_URL }} # http://localhost:3000
with:
build: yarn build
start: yarn preview
wait-on: ${{ secrets.ROOT_URL }}
record: true
parallel: true

- name: Skip tests
if: steps.checkUser.outputs.require-result == 'false'
uses: actions/github-script@v4
with:
script: |
core.setFailed('Pull request is opened by an user without write permission, tests are skipped for security reason')

schedule-cypress-run-staging:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18.17.1

- name: Schedule Run Testing against Staging
uses: cypress-io/github-action@v6
env:
ROOT_URL: "https://staging.sparc.science"
with:
wait-on: ${{ env.ROOT_URL }}
record: true
parallel: true

schedule-cypress-run-production:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18.17.1

- name: Schedule Run Testing against Production
uses: cypress-io/github-action@v6
env:
ROOT_URL: "https://sparc.science"
with:
wait-on: ${{ env.ROOT_URL }}
record: true
parallel: true

manual-cypress-run:
quality-control-cypress-run:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest

Expand Down
105 changes: 105 additions & 0 deletions .github/workflows/scheduled_cypress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Scheduled Cypress Testing

on:
schedule:
- cron: "0 0 * * 1"

env:
PAGE_LIMIT: ${{ github.event.inputs.PAGE_LIMIT }}
SEARCH_KEYWORDS: ${{ github.event.inputs.SEARCH_KEYWORDS }}
FILTER_FACET: ${{ github.event.inputs.FILTER_FACET }}
MULTIPLE_FILTER_FACETS: ${{ github.event.inputs.MULTIPLE_FILTER_FACETS }}
DATASET_IDS: ${{ github.event.inputs.DATASET_IDS }}
TAXON_MODELS: ${{ github.event.inputs.TAXON_MODELS }}
THREE_SYNC_VIEW: ${{ github.event.inputs.THREE_SYNC_VIEW }}
SEARCH_IN_MAP: ${{ github.event.inputs.SEARCH_IN_MAP }}
SCAFFOLD_DATASET_IDS: ${{ github.event.inputs.SCAFFOLD_DATASET_IDS }}
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
ALGOLIA_INDEX: ${{ secrets.ALGOLIA_INDEX }}
AWS_USER_POOL_ID: ${{ secrets.AWS_USER_POOL_ID }}
AWS_USER_POOL_WEB_CLIENT_ID: ${{ secrets.AWS_USER_POOL_WEB_CLIENT_ID }}
BIOLUCIDA_PASSWORD: ${{ secrets.BIOLUCIDA_PASSWORD }}
BIOLUCIDA_USERNAME: ${{ secrets.BIOLUCIDA_USERNAME }}
BITLY_ACCESS_TOKEN: ${{ secrets.BITLY_ACCESS_TOKEN }}
BLACKFYNN_API_SECRET: ${{ secrets.BLACKFYNN_API_SECRET }}
BLACKFYNN_API_TOKEN: ${{ secrets.BLACKFYNN_API_TOKEN }}
BLACKFYNN_CONCEPTS_API_HOST: ${{ secrets.BLACKFYNN_CONCEPTS_API_HOST }}
CTF_API_HOST: ${{ secrets.CTF_API_HOST }}
CTF_CDA_ACCESS_TOKEN: ${{ secrets.CTF_CDA_ACCESS_TOKEN }}
CTF_SPACE_ID: ${{ secrets.CTF_SPACE_ID }}
DEPLOY_ENV: ${{ secrets.DEPLOY_ENV }}
DISABLE_REDIRECT_SSL: ${{ secrets.DISABLE_REDIRECT_SSL }}
FLATMAP_API_HOST: ${{ secrets.FLATMAP_API_HOST }}
LOGIN_API_URL: ${{ secrets.LOGIN_API_URL }}
NODE_ENV: ${{ secrets.NODE_ENV }}
NPM_CONFIG_PRODUCTION: ${{ secrets.NPM_CONFIG_PRODUCTION }}
OSPARC_HOST: ${{ secrets.OSPARC_HOST }}
PORTAL_API_HOST: ${{ secrets.PORTAL_API_HOST }}
RECAPTCHA_SECRET_KEY: ${{ secrets.RECAPTCHA_SECRET_KEY }}
RECAPTCHA_SITE_KEY: ${{ secrets.RECAPTCHA_SITE_KEY }}
SHOW_FUNDING_FACET: ${{ secrets.SHOW_FUNDING_FACET }}
SHOW_HIERARCHAL_FACETS: ${{ secrets.SHOW_HIERARCHAL_FACETS }}
SHOW_LOGIN_FEATURE: ${{ secrets.SHOW_LOGIN_FEATURE }}
SHOW_METRICS: ${{ secrets.SHOW_METRICS }}
SHOW_OSPARC_TAB: ${{ secrets.SHOW_OSPARC_TAB }}
SHOW_TIMESERIES_VIEWER: ${{ secrets.SHOW_TIMESERIES_VIEWER }}
SPARC_PORTAL_USER_ID: ${{ secrets.SPARC_PORTAL_USER_ID }}
SPARC_PORTAL_USER_SECRET: ${{ secrets.SPARC_PORTAL_USER_SECRET }}

jobs:
scheduled-cypress-run-staging:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18.17.1

- name: Schedule Run Testing against Staging
uses: cypress-io/github-action@v6
env:
ROOT_URL: "https://staging.sparc.science"
with:
wait-on: ${{ env.ROOT_URL }}
record: true
parallel: true

scheduled-cypress-run-production:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18.17.1

- name: Schedule Run Testing against Production
uses: cypress-io/github-action@v6
env:
ROOT_URL: "https://sparc.science"
with:
wait-on: ${{ env.ROOT_URL }}
record: true
parallel: true
4 changes: 3 additions & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig } from "cypress";
import dynamicConfig from './tests/cypress/support/dynamicConfig.js'

export default defineConfig({
defaultCommandTimeout: 5000,
Expand All @@ -17,9 +18,10 @@ export default defineConfig({
testIsolation: true,
// pageLoadTimeout: 1024*1024*1024,
setupNodeEvents(on, config) {
// implement node event listeners here
return dynamicConfig(config)
},
env: {
PORTAL_API: process.env.PORTAL_API_HOST ? process.env.PORTAL_API_HOST : 'https://sparc-api.herokuapp.com',
// databrowser.js
PAGE_LIMIT: process.env.PAGE_LIMIT ? process.env.PAGE_LIMIT : '20',
SEARCH_KEYWORDS: process.env.SEARCH_KEYWORDS ? process.env.SEARCH_KEYWORDS : 'Spine, Neck',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@nuxt/devtools": "latest",
"@nuxtjs/turnstile": "^0.6.3",
"@zadigetvoltaire/nuxt-gtm": "^0.0.13",
"cypress": "^13.6.6",
"cypress": "13.9.0",
"nuxt": "^3.8.2",
"nuxt-svgo": "^3.5.6",
"sass": "^1.66.1",
Expand Down
Loading
Loading