mirror of
https://github.com/bec-project/bec_atlas.git
synced 2025-07-14 07:01:48 +02:00
Merge branch 'ci/init_setup' into 'main'
refactor: cleanup; added more ci jobs See merge request bec/bec_atlas!2
This commit is contained in:
@ -1,24 +1,89 @@
|
|||||||
image: $CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX/python:3.11
|
image: $CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX/python:3.11
|
||||||
|
|
||||||
stages:
|
|
||||||
- test
|
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
SCYLLA_HOST: scylla
|
SCYLLA_HOST: scylla
|
||||||
SCYLLA_PORT: 9042
|
SCYLLA_PORT: 9042
|
||||||
SCYLLA_KEYSPACE: bec_atlas
|
SCYLLA_KEYSPACE: bec_atlas
|
||||||
|
|
||||||
|
workflow:
|
||||||
|
rules:
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "schedule"'
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "web"'
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "pipeline"'
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "parent_pipeline"'
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
||||||
|
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
|
||||||
|
when: never
|
||||||
|
- if: $CI_COMMIT_BRANCH
|
||||||
|
auto_cancel:
|
||||||
|
on_new_commit: interruptible
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- Formatter
|
||||||
|
- test
|
||||||
|
|
||||||
|
include:
|
||||||
|
- template: Security/Secret-Detection.gitlab-ci.yml
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- name: $CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX/scylladb/scylla:latest
|
- name: $CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX/scylladb/scylla:latest
|
||||||
alias: scylla
|
alias: scylla
|
||||||
|
|
||||||
# before_script:
|
formatter:
|
||||||
# - pip install ./backend
|
stage: Formatter
|
||||||
# - python -u ./backend/bec_atlas/utils/setup_database.py
|
needs: []
|
||||||
|
script:
|
||||||
|
- pip install black isort
|
||||||
|
- isort --check --diff --line-length=100 --profile=black --multi-line=3 --trailing-comma ./backend/bec_atlas
|
||||||
|
- black --check --diff --color --line-length=100 --skip-magic-trailing-comma ./backend/bec_atlas
|
||||||
|
rules:
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "schedule"'
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "web"'
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "pipeline"'
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "parent_pipeline"'
|
||||||
|
when: never
|
||||||
|
- if: $CI_COMMIT_BRANCH
|
||||||
|
interruptible: true
|
||||||
|
|
||||||
|
pylint:
|
||||||
|
stage: Formatter
|
||||||
|
needs: []
|
||||||
|
script:
|
||||||
|
- pip install pylint pylint-exit anybadge
|
||||||
|
- mkdir ./pylint
|
||||||
|
- pylint ./backend/bec_atlas --output-format=text | tee ./pylint/pylint.log || pylint-exit $?
|
||||||
|
- PYLINT_SCORE=$(sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p' ./pylint/pylint.log)
|
||||||
|
- anybadge --label=Pylint --file=pylint/pylint.svg --value=$PYLINT_SCORE 2=red 4=orange 8=yellow 10=green
|
||||||
|
- echo "Pylint score is $PYLINT_SCORE"
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- ./pylint/
|
||||||
|
expire_in: 1 week
|
||||||
|
rules:
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "schedule"'
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "web"'
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "pipeline"'
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "parent_pipeline"'
|
||||||
|
when: never
|
||||||
|
- if: $CI_COMMIT_BRANCH
|
||||||
|
interruptible: true
|
||||||
|
|
||||||
test:
|
backend_pytest:
|
||||||
stage: test
|
stage: test
|
||||||
|
needs: []
|
||||||
script:
|
script:
|
||||||
- pip install ./backend[dev]
|
- pip install ./backend[dev]
|
||||||
- pytest --skip-docker --random-order ./backend/tests
|
- pip install coverage pytest-asyncio
|
||||||
|
- coverage run --concurrency=thread --source=./backend --omit=*/backend/tests/* -m pytest -v --junitxml=report.xml --skip-docker --random-order --full-trace ./backend/tests
|
||||||
|
- coverage report
|
||||||
|
- coverage xml
|
||||||
|
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
|
||||||
|
artifacts:
|
||||||
|
reports:
|
||||||
|
junit: report.xml
|
||||||
|
coverage_report:
|
||||||
|
coverage_format: cobertura
|
||||||
|
path: coverage.xml
|
||||||
|
interruptible: true
|
@ -3,12 +3,13 @@ from datetime import datetime, timedelta
|
|||||||
from typing import Annotated
|
from typing import Annotated
|
||||||
|
|
||||||
import jwt
|
import jwt
|
||||||
from bec_atlas.datasources.scylladb import scylladb_schema as schema
|
|
||||||
from fastapi import Depends, HTTPException, status
|
from fastapi import Depends, HTTPException, status
|
||||||
from fastapi.security import OAuth2PasswordBearer
|
from fastapi.security import OAuth2PasswordBearer
|
||||||
from jwt.exceptions import InvalidTokenError
|
from jwt.exceptions import InvalidTokenError
|
||||||
from pwdlib import PasswordHash
|
from pwdlib import PasswordHash
|
||||||
|
|
||||||
|
from bec_atlas.datasources.scylladb import scylladb_schema as schema
|
||||||
|
|
||||||
ALGORITHM = "HS256"
|
ALGORITHM = "HS256"
|
||||||
ACCESS_TOKEN_EXPIRE_MINUTES = 30
|
ACCESS_TOKEN_EXPIRE_MINUTES = 30
|
||||||
|
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from bec_atlas.authentication import get_password_hash
|
|
||||||
from bec_atlas.datasources.scylladb import scylladb_schema as schema
|
|
||||||
from cassandra.cluster import Cluster
|
from cassandra.cluster import Cluster
|
||||||
from cassandra.cqlengine import connection
|
from cassandra.cqlengine import connection
|
||||||
from cassandra.cqlengine.management import create_keyspace_simple, sync_table
|
from cassandra.cqlengine.management import create_keyspace_simple, sync_table
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from bec_atlas.authentication import get_password_hash
|
||||||
|
from bec_atlas.datasources.scylladb import scylladb_schema as schema
|
||||||
|
|
||||||
|
|
||||||
class ScylladbDatasource:
|
class ScylladbDatasource:
|
||||||
KEYSPACE = "bec_atlas"
|
KEYSPACE = "bec_atlas"
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import socketio
|
import socketio
|
||||||
import uvicorn
|
import uvicorn
|
||||||
|
from fastapi import FastAPI
|
||||||
|
|
||||||
from bec_atlas.datasources.datasource_manager import DatasourceManager
|
from bec_atlas.datasources.datasource_manager import DatasourceManager
|
||||||
from bec_atlas.router.redis_router import RedisRouter, RedisWebsocket
|
from bec_atlas.router.redis_router import RedisRouter, RedisWebsocket
|
||||||
from bec_atlas.router.scan_router import ScanRouter
|
from bec_atlas.router.scan_router import ScanRouter
|
||||||
from bec_atlas.router.user import UserRouter
|
from bec_atlas.router.user import UserRouter
|
||||||
from fastapi import FastAPI
|
|
||||||
|
|
||||||
CONFIG = {"redis": {"host": "localhost", "port": 6380}, "scylla": {"hosts": ["localhost"]}}
|
CONFIG = {"redis": {"host": "localhost", "port": 6380}, "scylla": {"hosts": ["localhost"]}}
|
||||||
|
|
||||||
|
@ -4,10 +4,11 @@ import json
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import socketio
|
import socketio
|
||||||
from bec_atlas.router.base_router import BaseRouter
|
|
||||||
from bec_lib.endpoints import MessageEndpoints
|
from bec_lib.endpoints import MessageEndpoints
|
||||||
from fastapi import APIRouter, WebSocket, WebSocketDisconnect
|
from fastapi import APIRouter, WebSocket, WebSocketDisconnect
|
||||||
|
|
||||||
|
from bec_atlas.router.base_router import BaseRouter
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from bec_lib.redis_connector import RedisConnector
|
from bec_lib.redis_connector import RedisConnector
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
from fastapi import APIRouter, Depends
|
||||||
|
|
||||||
from bec_atlas.authentication import get_current_user
|
from bec_atlas.authentication import get_current_user
|
||||||
from bec_atlas.datasources.scylladb import scylladb_schema as schema
|
from bec_atlas.datasources.scylladb import scylladb_schema as schema
|
||||||
from bec_atlas.router.base_router import BaseRouter
|
from bec_atlas.router.base_router import BaseRouter
|
||||||
from fastapi import APIRouter, Depends
|
|
||||||
|
|
||||||
|
|
||||||
class ScanRouter(BaseRouter):
|
class ScanRouter(BaseRouter):
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
from typing import Annotated
|
from typing import Annotated
|
||||||
|
|
||||||
from bec_atlas.authentication import create_access_token, get_current_user, verify_password
|
|
||||||
from bec_atlas.datasources.scylladb import scylladb_schema as schema
|
|
||||||
from bec_atlas.router.base_router import BaseRouter
|
|
||||||
from fastapi import APIRouter, Depends
|
from fastapi import APIRouter, Depends
|
||||||
from fastapi.exceptions import HTTPException
|
from fastapi.exceptions import HTTPException
|
||||||
from fastapi.security import OAuth2PasswordRequestForm
|
from fastapi.security import OAuth2PasswordRequestForm
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from bec_atlas.authentication import create_access_token, get_current_user, verify_password
|
||||||
|
from bec_atlas.datasources.scylladb import scylladb_schema as schema
|
||||||
|
from bec_atlas.router.base_router import BaseRouter
|
||||||
|
|
||||||
|
|
||||||
class UserLoginRequest(BaseModel):
|
class UserLoginRequest(BaseModel):
|
||||||
username: str
|
username: str
|
||||||
|
@ -2,6 +2,7 @@ import argparse
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import libtmux
|
import libtmux
|
||||||
|
|
||||||
from bec_atlas.utils.service_handler import ServiceHandler
|
from bec_atlas.utils.service_handler import ServiceHandler
|
||||||
|
|
||||||
|
|
||||||
|
0
backend/tests/__init__.py
Normal file
0
backend/tests/__init__.py
Normal file
@ -1,5 +1,4 @@
|
|||||||
import os
|
import os
|
||||||
import socket
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from bec_atlas.main import AtlasApp
|
from bec_atlas.main import AtlasApp
|
||||||
|
Reference in New Issue
Block a user