diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b98605f..cf75c59 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: "CI for all branches" +name: "CI for all branches " on: pull_request: @@ -37,21 +37,28 @@ jobs: run: black --check . - name: Mypy type check - run: mypy app/ - + run: mypy ./ + tests: name: Unit Tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Build and start services + run: docker compose up -d --build --wait --wait-timeout 180 + + - name: Show running containers + run: docker compose ps + + - name: Run testing run: | docker compose exec app python manage.py test > test-reason.txt - name: Upload test reason if: always() - uses: actions/upload-artifact + uses: actions/upload-artifact@v4 with: name: test-reason path: test-reason.txt \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 6e92aed..1c3eb7e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,154 +32,111 @@ services: networks: - net - # kafka: - # image: confluentinc/cp-kafka:latest - # ports: - # - "9092:9092" - # networks: - # - net - # environment: - # # KRaft mode — NO ZOOKEEPER - # CLUSTER_ID: "nlt5fjLLRLSaO1Hm7Gpc5A" - # KAFKA_PROCESS_ROLES: "broker,controller" - # KAFKA_NODE_ID: 1 - # KAFKA_CONTROLLER_QUORUM_VOTERS: "1@kafka:29093" - # KAFKA_LISTENERS: "SASL_PLAINTEXT://0.0.0.0:9092,CONTROLLER://0.0.0.0:29093" - # KAFKA_ADVERTISED_LISTENERS: "SASL_PLAINTEXT://kafka:9092" - # KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "SASL_PLAINTEXT:SASL_PLAINTEXT,CONTROLLER:PLAINTEXT" - # KAFKA_INTER_BROKER_LISTENER_NAME: "SASL_PLAINTEXT" - # KAFKA_CONTROLLER_LISTENER_NAMES: "CONTROLLER" - # KAFKA_SASL_ENABLED_MECHANISMS: "PLAIN" - # KAFKA_SASL_MECHANISM_INTER_BROKER_PROTOCOL: "PLAIN" - # KAFKA_SASL_JAAS_CONFIG: | - # org.apache.kafka.common.security.plain.PlainLoginModule required - # username="admin" - # password="admin-secret" - # user_admin="admin-secret" - # user_client="client-secret"; - # - # KAFKA_OPTS: "-Djava.security.auth.login.config=/tmp/kafka_server_jaas.conf" - # KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 - # KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1 - # KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1 - # - # command: | - # bash -c " - # echo 'KafkaServer { - # org.apache.kafka.common.security.plain.PlainLoginModule required - # username=\"admin\" - # password=\"admin-secret\" - # user_admin=\"admin-secret\" - # user_client=\"client-secret\"; - # };' > /tmp/kafka_server_jaas.conf && - # /etc/confluent/docker/run - # " - - # redis: - # image: 'redis:alpine' - # restart: always - # command: redis-server - # container_name: 'Redis' - # volumes: - # - redis:/data - # networks: - # - net + + redis: + image: 'redis:alpine' + restart: always + command: redis-server + container_name: 'Redis' + volumes: + - redis:/data + networks: + - net - # migrate: - # build: . - # command: poetry run python manage.py migrate - # env_file: - # - .env - # depends_on: - # - redis - # - db - # networks: - # - net + migrate: + build: . + command: poetry run python manage.py migrate + env_file: + - .env + depends_on: + - redis + - db + networks: + - net - # collectstatic: - # build: . - # command: poetry run python manage.py collectstatic --no-input - # volumes: - # - static:/app/static - # - media:/app/media - # networks: - # - net - # env_file: - # - .env + collectstatic: + build: . + command: poetry run python manage.py collectstatic --no-input + volumes: + - static:/app/static + - media:/app/media + networks: + - net + env_file: + - .env - # app: - # build: . - # restart: always - # command: poetry run uvicorn config.asgi:application --host 0.0.0.0 --port 8000 --workers 4 - # volumes: - # - ./app:/app - # - static:/app/static - # - media:/app/media - # env_file: - # - .env - # depends_on: - # - redis - # - db - # ports: - # - 8000:8000 - # networks: - # - net + app: + build: . + restart: always + command: poetry run uvicorn config.asgi:application --host 0.0.0.0 --port 8000 --workers 4 + volumes: + - ./app:/app + - static:/app/static + - media:/app/media + env_file: + - .env + depends_on: + - redis + - db + ports: + - 8000:8000 + networks: + - net - # celery-worker: - # build: . - # command: > - # sh -c " - # sleep 10 && - # poetry run celery -A config worker -l WARNING - # " - # volumes: - # - ./app:/app - # depends_on: - # - app - # - redis - # - db - # environment: - # - CELERY_BROKER_URL=redis://redis:6379/0 - # restart: on-failure - # networks: - # - net - # env_file: - # - .env + celery-worker: + build: . + command: > + sh -c " + sleep 10 && + poetry run celery -A config worker -l WARNING + " + volumes: + - ./app:/app + depends_on: + - app + - redis + - db + environment: + - CELERY_BROKER_URL=redis://redis:6379/0 + restart: on-failure + networks: + - net + env_file: + - .env - # celery-beat: - # build: . - # command: > - # sh -c " - # sleep 15 && - # poetry run celery -A config beat -l INFO - # " - # depends_on: - # - app - # - redis - # - db - # environment: - # - CELERY_BROKKER_URL=redis://redis:6379/0 - # restart: on-failure - # volumes: - # - ./app:/app - # networks: - # - net - # env_file: - # - .env + celery-beat: + build: . + command: > + sh -c " + sleep 15 && + poetry run celery -A config beat -l INFO + " + depends_on: + - app + - redis + - db + environment: + - CELERY_BROKKER_URL=redis://redis:6379/0 + restart: on-failure + volumes: + - ./app:/app + networks: + - net + env_file: + - .env - # notify_service: - # build: . - # volumes: - # - ./notification_service:/app/notification_service - # command: sh -c "python -m notification_service.notification" - # env_file: - # - .env - # depends_on: - # - kafka - # - grafana - # restart: on-failure - # networks: - # - net + notify_service: + build: . + volumes: + - ./notification_service:/app/notification_service + command: sh -c "python -m notification_service.notification" + env_file: + - .env + depends_on: + - grafana + restart: on-failure + networks: + - net alertmanager: image: prom/alertmanager:latest diff --git a/poetry.lock b/poetry.lock index 8cba09c..4fc490d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,5 +1,21 @@ # This file is automatically @generated by Poetry 2.3.2 and should not be changed by hand. +[[package]] +name = "aio-pika" +version = "9.6.2" +description = "Wrapper around the aiormq for asyncio and humans" +optional = false +python-versions = "<4,>=3.10" +groups = ["main"] +files = [ + {file = "aio_pika-9.6.2-py3-none-any.whl", hash = "sha256:2a5478af920d169795071c9c09c7542cd8cdece60438cf7804533dcbcce93b7f"}, + {file = "aio_pika-9.6.2.tar.gz", hash = "sha256:c49e9246080dc8ffa1bb0e4aca407bf3d8ad78c3ee3a93df88b68fe65d7a49b9"}, +] + +[package.dependencies] +aiormq = ">=6.8,<7" +yarl = "*" + [[package]] name = "aiofiles" version = "24.1.0" @@ -165,57 +181,20 @@ yarl = ">=1.17.0,<2.0" speedups = ["Brotli ; platform_python_implementation == \"CPython\"", "aiodns (>=3.3.0)", "brotlicffi ; platform_python_implementation != \"CPython\""] [[package]] -name = "aiokafka" -version = "0.12.0" -description = "Kafka integration with asyncio" +name = "aiormq" +version = "6.9.4" +description = "Pure python AMQP asynchronous client library" optional = false -python-versions = ">=3.9" +python-versions = "<4,>=3.10" groups = ["main"] files = [ - {file = "aiokafka-0.12.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:da8938eac2153ca767ac0144283b3df7e74bb4c0abc0c9a722f3ae63cfbf3a42"}, - {file = "aiokafka-0.12.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:a5c827c8883cfe64bc49100de82862225714e1853432df69aba99f135969bb1b"}, - {file = "aiokafka-0.12.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bea5710f7707ed12a7f8661ab38dfa80f5253a405de5ba228f457cc30404eb51"}, - {file = "aiokafka-0.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d87b1a45c57bbb1c17d1900a74739eada27e4f4a0b0932ab3c5a8cbae8bbfe1e"}, - {file = "aiokafka-0.12.0-cp310-cp310-win32.whl", hash = "sha256:1158e630664d9abc74d8a7673bc70dc10737ff758e1457bebc1c05890f29ce2c"}, - {file = "aiokafka-0.12.0-cp310-cp310-win_amd64.whl", hash = "sha256:06f5889acf8e1a81d6e14adf035acb29afd1f5836447fa8fa23d3cbe8f7e8608"}, - {file = "aiokafka-0.12.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ddc5308c43d48af883667e2f950a0a9739ce2c9bfe69a0b55dc234f58b1b42d6"}, - {file = "aiokafka-0.12.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ff63689cafcd6dd642a15de75b7ae121071d6162cccba16d091bcb28b3886307"}, - {file = "aiokafka-0.12.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:24633931e05a9dc80555a2f845572b6845d2dcb1af12de27837b8602b1b8bc74"}, - {file = "aiokafka-0.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:42b2436c7c69384d210e9169fbfe339d9f49dbdcfddd8d51c79b9877de545e33"}, - {file = "aiokafka-0.12.0-cp311-cp311-win32.whl", hash = "sha256:90511a2c4cf5f343fc2190575041fbc70171654ab0dae64b3bbabd012613bfa7"}, - {file = "aiokafka-0.12.0-cp311-cp311-win_amd64.whl", hash = "sha256:04c8ad27d04d6c53a1859687015a5f4e58b1eb221e8a7342d6c6b04430def53e"}, - {file = "aiokafka-0.12.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:b01947553ff1120fa1cb1a05f2c3e5aa47a5378c720bafd09e6630ba18af02aa"}, - {file = "aiokafka-0.12.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:e3c8ec1c0606fa645462c7353dc3e4119cade20c4656efa2031682ffaad361c0"}, - {file = "aiokafka-0.12.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:577c1c48b240e9eba57b3d2d806fb3d023a575334fc3953f063179170cc8964f"}, - {file = "aiokafka-0.12.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d7b815b2e5fed9912f1231be6196547a367b9eb3380b487ff5942f0c73a3fb5c"}, - {file = "aiokafka-0.12.0-cp312-cp312-win32.whl", hash = "sha256:5a907abcdf02430df0829ac80f25b8bb849630300fa01365c76e0ae49306f512"}, - {file = "aiokafka-0.12.0-cp312-cp312-win_amd64.whl", hash = "sha256:fdbd69ec70eea4a8dfaa5c35ff4852e90e1277fcc426b9380f0b499b77f13b16"}, - {file = "aiokafka-0.12.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f9e8ab97b935ca681a5f28cf22cf2b5112be86728876b3ec07e4ed5fc6c21f2d"}, - {file = "aiokafka-0.12.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:ed991c120fe19fd9439f564201dd746c4839700ef270dd4c3ee6d4895f64fe83"}, - {file = "aiokafka-0.12.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2c01abf9787b1c3f3af779ad8e76d5b74903f590593bc26f33ed48750503e7f7"}, - {file = "aiokafka-0.12.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:08c84b3894d97fd02fcc8886f394000d0f5ce771fab5c498ea2b0dd2f6b46d5b"}, - {file = "aiokafka-0.12.0-cp313-cp313-win32.whl", hash = "sha256:63875fed922c8c7cf470d9b2a82e1b76b4a1baf2ae62e07486cf516fd09ff8f2"}, - {file = "aiokafka-0.12.0-cp313-cp313-win_amd64.whl", hash = "sha256:bdc0a83eb386d2384325d6571f8ef65b4cfa205f8d1c16d7863e8d10cacd995a"}, - {file = "aiokafka-0.12.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:a9590554fae68ec80099beae5366f2494130535a1a3db0c4fa5ccb08f37f6e46"}, - {file = "aiokafka-0.12.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:6c77f5953ff4b25c889aef26df1f28df66c58db7abb7f34ecbe48502e9a6d273"}, - {file = "aiokafka-0.12.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f96d7fd8fdb5f439f7e7860fd8ec37870265d0578475e82049bce60ab07ca045"}, - {file = "aiokafka-0.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b8ddff02b1e981083dff6d1a80d4502e0e83e0e480faf1f881766ca6f23e8d22"}, - {file = "aiokafka-0.12.0-cp39-cp39-win32.whl", hash = "sha256:4aab2767dcc8923626d8d60c314f9ba633563249cff71750db5d70b6ec813da2"}, - {file = "aiokafka-0.12.0-cp39-cp39-win_amd64.whl", hash = "sha256:7a57fda053acd1b88c87803ad0381a1d2a29d36ec561550d11ce9154972b8e23"}, - {file = "aiokafka-0.12.0.tar.gz", hash = "sha256:62423895b866f95b5ed8d88335295a37cc5403af64cb7cb0e234f88adc2dff94"}, + {file = "aiormq-6.9.4-py3-none-any.whl", hash = "sha256:726a8586695e863fba68cf88842065ab12348c9438dcebdfc9d0bddaf6083277"}, + {file = "aiormq-6.9.4.tar.gz", hash = "sha256:0e7c01b662804e1cc7ace9a17794e8c1192a27fc2afa96162362a6e61ae8e8ef"}, ] [package.dependencies] -async-timeout = "*" -packaging = "*" -typing-extensions = ">=4.10.0" - -[package.extras] -all = ["cramjam (>=2.8.0)", "gssapi"] -gssapi = ["gssapi"] -lz4 = ["cramjam (>=2.8.0)"] -snappy = ["cramjam"] -zstd = ["cramjam"] +pamqp = "3.3.0" +yarl = "*" [[package]] name = "aiosignal" @@ -282,6 +261,7 @@ description = "Timeout context manager for asyncio programs" optional = false python-versions = ">=3.8" groups = ["main"] +markers = "python_full_version < \"3.11.3\"" files = [ {file = "async_timeout-5.0.1-py3-none-any.whl", hash = "sha256:39e3809566ff85354557ec2398b55e096c8364bacac9405a7a1fa429e77fe76c"}, {file = "async_timeout-5.0.1.tar.gz", hash = "sha256:d9321a7a3d5a6a5e187e824d2fa0793ce379a202935782d555d6e9d2735677d3"}, @@ -1254,6 +1234,22 @@ files = [ {file = "packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f"}, ] +[[package]] +name = "pamqp" +version = "3.3.0" +description = "RabbitMQ Focused AMQP low-level library" +optional = false +python-versions = ">=3.7" +groups = ["main"] +files = [ + {file = "pamqp-3.3.0-py2.py3-none-any.whl", hash = "sha256:c901a684794157ae39b52cbf700db8c9aae7a470f13528b9d7b4e5f7202f8eb0"}, + {file = "pamqp-3.3.0.tar.gz", hash = "sha256:40b8795bd4efcf2b0f8821c1de83d12ca16d5760f4507836267fd7a02b06763b"}, +] + +[package.extras] +codegen = ["lxml", "requests", "yapf"] +testing = ["coverage", "flake8", "flake8-comprehensions", "flake8-deprecated", "flake8-import-order", "flake8-print", "flake8-quotes", "flake8-rst-docstrings", "flake8-tuple", "yapf"] + [[package]] name = "pillow" version = "10.4.0" @@ -2511,4 +2507,4 @@ propcache = ">=0.2.1" [metadata] lock-version = "2.1" python-versions = "^3.11" -content-hash = "88d6d19c56304108d183d61230405951b5e07e7d80f8182aa68824e01fca92d5" +content-hash = "aacb56373e3242d54a8ab0772f2c255cb4113ad26a79105dc3acbe549b5039ad"