Commit 937eb7a9 authored by Konstantin Schulz's avatar Konstantin Schulz

backend CI should now fail if any unit test fails

parent 792c713a
Pipeline #12439 passed with stages
in 2 minutes and 41 seconds
......@@ -17,7 +17,7 @@ ci_frontend:
ci_backend:
stage: ci
script:
- docker-compose run --rm mcserver bash -c "source ../venv/bin/activate && coverage run --rcfile=.coveragerc tests.py && coverage combine && coverage report -m" > ci_backend.log
- docker-compose run --rm --entrypoint="./coverage_backend.sh" mcserver > ci_backend.log
artifacts:
paths:
- ci_backend.log
......
docker-compose build
docker-compose run --rm --entrypoint="npm run test-ci" mc_frontend > ci_frontend.log
docker-compose run --rm mcserver bash -c "source ../venv/bin/activate && coverage run --rcfile=.coveragerc tests.py && coverage combine && coverage report -m" > ci_backend.log
docker-compose run --rm --entrypoint="npm run test-ci" mc_frontend >ci_frontend.log
docker-compose run --rm --entrypoint="./coverage_backend.sh" mcserver > ci_backend.log
./coverage_ci.sh
cat coverage.log
......@@ -17,5 +17,6 @@ exclude_lines =
# Don't complain if non-runnable code isn't run:
if __name__ == .__main__.:
except ModuleNotFoundError:
fail_under = 100
ignore_errors = True
show_missing = True
#!/bin/bash
source ../venv/bin/activate
coverage run --rcfile=.coveragerc tests.py
coverage combine && coverage report -m
......@@ -18,14 +18,6 @@ from flask_sqlalchemy import SQLAlchemy
from open_alchemy import init_yaml
from mcserver.config import Config
# remove stale connections from the connection pool after 1 hour
db: SQLAlchemy = SQLAlchemy() # session_options={"autocommit": True, "pool_recycle": 3600}
migrate: Migrate = Migrate(directory=Config.MIGRATIONS_DIRECTORY)
if not hasattr(open_alchemy.models, Config.DATABASE_TABLE_CORPUS):
# do this _BEFORE_ you add any APIs to your application
init_yaml(Config.API_SPEC_MODELS_YAML_FILE_PATH, base=db.Model,
models_filename=os.path.join(Config.MC_SERVER_DIRECTORY, "models_auto.py"))
def apply_event_handlers(app: FlaskApp):
"""Applies event handlers to a given Flask application, such as logging after requests or teardown logic."""
......@@ -64,6 +56,11 @@ def create_app(cfg: Type[Config] = Config) -> Flask:
return app
def create_database() -> SQLAlchemy:
"""Creates a new connection to a database, which will handle all future database transactions."""
return SQLAlchemy() # session_options={"autocommit": True}
def full_init(app: Flask, cfg: Type[Config] = Config) -> None:
""" Fully initializes the application, including logging."""
from mcserver.app.services import DatabaseService
......@@ -145,6 +142,13 @@ def shutdown_session(exception=None):
db.session.remove()
db: SQLAlchemy = create_database()
migrate: Migrate = Migrate(directory=Config.MIGRATIONS_DIRECTORY)
if not hasattr(open_alchemy.models, Config.DATABASE_TABLE_CORPUS):
# do this _BEFORE_ you add any APIs to your application
init_yaml(Config.API_SPEC_MODELS_YAML_FILE_PATH, base=db.Model,
models_filename=os.path.join(Config.MC_SERVER_DIRECTORY, "models_auto.py"))
# import the models so we can access them from other parts of the app using imports from "app.models";
# this has to be at the bottom of the file
from mcserver.app import models
......
......@@ -145,6 +145,8 @@ class Config(object):
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL") or DATABASE_URL_SQLITE
# BEWARE: if True, logs every single database statement executed by this application to STDOUT
SQLALCHEMY_ECHO = False
# remove stale connections from the connection pool after 1 hour
SQLALCHEMY_POOL_RECYCLE = 3600
SQLALCHEMY_TRACK_MODIFICATIONS = False
STATIC_EXERCISES_REPOSITORY_URL = "https://scm.cms.hu-berlin.de/callidus/machina-callida/-/archive/master/machina-callida-master.zip?path=mc_frontend%2Fsrc%2Fassets%2Fh5p"
STOP_WORDS_LATIN_PATH = os.path.join(CACHE_DIRECTORY, "stop_words_latin.json")
......
......@@ -259,7 +259,7 @@ export class HelperService {
configMC.backendBaseUrl = part1.concat(configMC.backendBaseApiPath).concat('/');
}
if (!configMC.frontendBaseUrl) {
configMC.frontendBaseUrl = location.href.substring(0, location.href.lastIndexOf('/') + 1);
configMC.frontendBaseUrl = location.href.substring(0, location.href.lastIndexOf('/'));
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment