-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #725 from CharlesSheelam/smoke-testing
feat: add cypress end to end tests
- Loading branch information
Showing
49 changed files
with
908 additions
and
91 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,34 @@ | ||
name: E2E Tests | ||
|
||
on: | ||
workflow_dispatch # disabled pending db seeding | ||
# push: | ||
# branches: [ main ] | ||
# pull_request: | ||
# branches: [ main ] | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
e2e: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: build containers and run cypress e2e tests | ||
# TODO: seed the database with a sparse(r) dump so there are pages to test.. | ||
|
||
- name: deploy services in e2e mode | ||
run: make e2e | ||
|
||
- name: run e2e tests | ||
uses: cypress-io/github-action@v6 | ||
with: | ||
working-directory: e2e | ||
wait-on: "http://localhost:8000" | ||
wait-on-timeout: 300 | ||
|
||
- name: display service logs | ||
if: failure() | ||
run: docker compose -f docker-compose.yml -f e2e.yml logs | ||
|
||
- name: upload cypress videos | ||
if: failure() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: cypress-videos | ||
path: e2e/cypress/videos |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,25 @@ | ||
from .dev import * | ||
from .test import * | ||
|
||
DEPLOY_ENVIRONMENT = Environment.TEST | ||
DEBUG = True | ||
|
||
DJANGO_VITE_DEV_MODE = False | ||
|
||
SHARE_DIR = path.realpath("/shared/e2e") | ||
LIBRARY_ROOT = path.join(SHARE_DIR, "library") | ||
LIBRARY_PREVIOUS_ROOT = path.join(SHARE_DIR, ".latest") | ||
REPOSITORY_ROOT = path.join(BASE_DIR, "repository") | ||
BACKUP_ROOT = path.join(SHARE_DIR, "backups") | ||
BORG_ROOT = path.join(BACKUP_ROOT, "repo") | ||
EXTRACT_ROOT = path.join(SHARE_DIR, "extract") | ||
MEDIA_ROOT = path.join(SHARE_DIR, "media") | ||
|
||
DATABASES = { | ||
"default": { | ||
"ENGINE": "django.db.backends.postgresql", | ||
"NAME": os.getenv("DB_NAME"), | ||
"USER": os.getenv("DB_USER"), | ||
"PASSWORD": read_secret("db_password", os.getenv("DB_PASSWORD")), | ||
"HOST": "e2edb", | ||
"PORT": os.getenv("DB_PORT"), | ||
} | ||
} |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,44 @@ | ||
services: | ||
e2e: | ||
image: comses/cypress | ||
build: e2e | ||
environment: | ||
- CYPRESS_baseUrl=http://server:8000 | ||
db: | ||
image: alpine # disable the normal db container | ||
command: tail -f /dev/null | ||
healthcheck: | ||
disable: true | ||
e2edb: | ||
image: postgis/postgis:15-3.4 | ||
secrets: | ||
- db_password # re-using the same db password | ||
volumes: | ||
- ./e2e/cypress:/code/cypress | ||
- ./e2e/cypress.config.js:/code/cypress.config.js | ||
- ./django/deploy/wait-for-it.sh:/code/wait-for-it.sh | ||
depends_on: | ||
- server | ||
- ./build/secrets/db_password:/run/secrets/db_password | ||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U ${DB_USER} -d ${DB_NAME}"] | ||
interval: 30s | ||
timeout: 5s | ||
retries: 5 | ||
environment: | ||
POSTGRES_USER: "${DB_USER}" | ||
POSTGRES_DB: "${DB_NAME}" | ||
POSTGRES_PASSWORD_FILE: /run/secrets/db_password | ||
vite: | ||
volumes: | ||
- ./frontend:/code | ||
command: ["npm", "run", "build"] | ||
environment: | ||
NODE_ENV: "e2e" | ||
server: | ||
image: comses/server:dev | ||
volumes: | ||
- ./django:/code | ||
- ./docs:/docs | ||
depends_on: | ||
db: | ||
condition: service_started | ||
e2edb: | ||
condition: service_healthy | ||
elasticsearch: | ||
condition: service_healthy | ||
redis: | ||
condition: service_started | ||
vite: | ||
condition: service_completed_successfully | ||
healthcheck: | ||
test: ["CMD", "curl", "-f", "http://localhost:8000"] | ||
interval: 30s | ||
timeout: 10s | ||
retries: 5 | ||
environment: | ||
DJANGO_SETTINGS_MODULE: "core.settings.e2e" | ||
ports: | ||
- "127.0.0.1:8000:8000" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/prettierrc", | ||
"semi": true, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"singleQuote": false, | ||
"printWidth": 100, | ||
"trailingComma": "es5", | ||
"bracketSpacing": true, | ||
"bracketSameLine": false, | ||
"arrowParens": "avoid" | ||
} |
This file was deleted.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#generated from chatgpt | ||
|
||
[tool.poetry] | ||
name = "logistic-growth-model" | ||
version = "0.1.0" | ||
description = "A simple logistic growth model simulation" | ||
authors = ["Your Name <[email protected]>"] | ||
license = "MIT" | ||
readme = "README.md" | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.8" | ||
numpy = "^1.21.0" | ||
matplotlib = "^3.4.2" | ||
|
||
[tool.poetry.dev-dependencies] | ||
pytest = "^6.2.4" | ||
|
||
[build-system] | ||
requires = ["poetry-core>=1.0.0"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#generated from chatgpt | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
# Logistic growth model parameters | ||
r = 0.1 # Growth rate | ||
K = 1000 # Carrying capacity | ||
P0 = 10 # Initial population | ||
t_max = 100 # Time duration | ||
dt = 1 # Time step | ||
|
||
# Time array | ||
time = np.arange(0, t_max, dt) | ||
|
||
# Population array | ||
population = np.zeros_like(time) | ||
population[0] = P0 | ||
|
||
# Logistic growth model calculation | ||
for t in range(1, len(time)): | ||
population[t] = population[t-1] + r * population[t-1] * (1 - population[t-1] / K) * dt | ||
|
||
# Plot the results | ||
plt.figure(figsize=(10, 6)) | ||
plt.plot(time, population, label='Population') | ||
plt.xlabel('Time') | ||
plt.ylabel('Population') | ||
plt.title('Logistic Growth Model') | ||
plt.legend() | ||
plt.grid(True) | ||
plt.show() | ||
|
Oops, something went wrong.