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

Init cypress tests #466

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open
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
171 changes: 171 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
name: Cypress Tests

on: [push]

jobs:
setup:
runs-on: ubuntu-latest
container: cypress/browsers:node16.14.2-slim-chrome100-ff99-edge
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Cypress install
uses: cypress-io/github-action@v5
with:
runTests: false

- name: Cache Cypress
uses: actions/cache@v3
with:
path: ~/.cache/Cypress
key: my-cache-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Cache node modules
uses: actions/cache@v3
with:
path: node_modules
key: node_modules-${{ hashFiles('package-lock.json') }}
# loading an older version is fine here, since it will get an npm install
restore-keys: |
node_modules-

- name: Install dependencies
run: npm ci

ui-chrome-tests:
timeout-minutes: 15
runs-on: ubuntu-latest
container: cypress/browsers:node16.14.2-slim-chrome100-ff99-edge
needs: setup
strategy:
# when one test fails, DO NOT cancel the other
# containers, because this will kill Cypress processes
# leaving the Dashboard hanging ...
# https://github.com/cypress-io/github-action/issues/48
fail-fast: false
matrix:
# run copies of the current job in parallel
containers: [1, 2]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Load node_modules
uses: actions/cache@v3
with:
path: node_modules
key: node_modules-${{ hashFiles('package-lock.json') }}
# no restore-keys here, so we only accept this exact version

- name: Load cypress binary
uses: actions/cache@v3
with:
path: ~/.cache/Cypress
key: my-cache-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: "UI Tests - Chrome"
uses: cypress-io/github-action@v5
with:
install: false
start: npm start
wait-on: http://localhost:4200
browser: chrome
record: true
parallel: true
group: "UI - Chrome"
env:
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}

ui-firefox-tests:
timeout-minutes: 15
runs-on: ubuntu-latest
container:
image: cypress/browsers:node16.14.2-slim-chrome100-ff99-edge
options: --user 1001
needs: setup
strategy:
# when one test fails, DO NOT cancel the other
# containers, because this will kill Cypress processes
# leaving the Dashboard hanging ...
# https://github.com/cypress-io/github-action/issues/48
fail-fast: false
matrix:
# run copies of the current job in parallel
containers: [1, 2]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Load node_modules
uses: actions/cache@v3
with:
path: node_modules
key: node_modules-${{ hashFiles('package-lock.json') }}
# no restore-keys here, so we only accept this exact version

- name: Load cypress binary
uses: actions/cache@v3
with:
path: ~/.cache/Cypress
key: my-cache-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: "UI Tests - Firefox"
uses: cypress-io/github-action@v5
with:
install: false
start: npm start
wait-on: http://localhost:4200
browser: firefox
record: true
parallel: true
group: "UI - Firefox"
env:
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}

ui-edge-tests:
timeout-minutes: 15
runs-on: ubuntu-latest
container: cypress/browsers:node16.14.2-slim-chrome100-ff99-edge
needs: setup
strategy:
# when one test fails, DO NOT cancel the other
# containers, because this will kill Cypress processes
# leaving the Dashboard hanging ...
# https://github.com/cypress-io/github-action/issues/48
fail-fast: false
matrix:
# run copies of the current job in parallel
containers: [1, 2]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Load node_modules
uses: actions/cache@v3
with:
path: node_modules
key: node_modules-${{ hashFiles('package-lock.json') }}
# no restore-keys here, so we only accept this exact version

- name: Load cypress binary
uses: actions/cache@v3
with:
path: ~/.cache/Cypress
key: my-cache-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: "UI Tests - Edge"
uses: cypress-io/github-action@v5
with:
install: false
start: npm start
wait-on: http://localhost:4200
browser: edge
record: true
parallel: true
group: "UI - Edge"
env:
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ testem.log
# e2e
/e2e/*.js
/e2e/*.map
/cypress/screenshots/*
/cypress/videos/*

# System Files
.DS_Store
Expand Down
69 changes: 69 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
stages:
- build
- test

## Set environment variables for folders in "cache" job settings for npm modules and Cypress binary
variables:
npm_config_cache: '$CI_PROJECT_DIR/.npm'
CYPRESS_CACHE_FOLDER: '$CI_PROJECT_DIR/cache/Cypress'
FF_USE_FASTZIP: 1

cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .cache/*
- cache/Cypress
- build
- .npm/

# ## Install NPM dependencies and Cypress
install:
image: cypress/browsers:node16.14.2-slim-chrome100-ff99-edge
stage: build
script:
- npm ci

with-backend:
image: docker
services:
- docker:dind
stage: test
needs:
- install
parallel: 2
before_script:
- apk --update add --no-cache nodejs npm gcompat libstdc++ libc6-compat
script:
- docker run -d -e ARLAS_ELASTIC_NODES=$ARLAS_ELASTIC_NODES -e ARLAS_ELASTIC_INDEX=.demo_arlas -e ARLAS_ELASTIC_CREDENTIALS=$ARLAS_ELASTIC_CREDENTIALS -e ARLAS_ELASTIC_ENABLE_SSL=true -e ARLAS_CORS_ENABLED=true -p9999:9999 --name=arlas-server-ci gisaia/arlas-server:21.0.0
- i=1; until nc -w 2 localhost 9999; do if [ $i -lt 30 ]; then sleep 1; else break; fi; i=$(($i + 1)); done
- npm ci --cache .npm --prefer-offline
- npm run start &
- npx wait-on http://localhost:4200
# - npx cypress run --parallel --record --browser chrome --group "UI - Chrome"
- docker run --network host -v $PWD:/e2e -w /e2e -e CYPRESS_RECORD_KEY=$CYPRESS_RECORD_KEY --entrypoint=cypress cypress/included:9.6.1 run --record --browser chrome --group "UI - Chrome" --parallel

ui-chrome-tests:
image: cypress/browsers:node16.14.2-slim-chrome100-ff99-edge
stage: test
parallel: 2
needs:
- install
script:
- npm ci --cache .npm --prefer-offline
# start the server in the background
- npm run start & npx wait-on http://localhost:4200
# run Cypress tests in parallel
- npx cypress run --parallel --record --browser chrome --group "UI - Chrome"

ui-firefox-tests:
image: cypress/browsers:node16.14.2-slim-chrome100-ff99-edge
stage: test
parallel: 2
needs:
- install
script:
- npm ci --cache .npm --prefer-offline
# start the server in the background
- npm run start & npx wait-on http://localhost:4200
# run Cypress tests in parallel
- npx cypress run --parallel --record --browser firefox --group "UI - Firefox"
4 changes: 4 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"baseUrl": "http://localhost:4200",
"projectId": "hq1hyq"
}
5 changes: 5 additions & 0 deletions cypress/fixtures/count.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"collection": "demo_eo",
"nbhits": 10,
"totalnb": 25000
}
Loading