diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eb69637..a8f84e3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,6 +7,7 @@ on: branches: - main - develop + env: DOCTL_VERSION: 1.92.0 @@ -47,6 +48,8 @@ jobs: # DIGITALOCEAN_ACCESS_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }} # REGISTRY: ${{ secrets.REGISTRY }} # POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} + # PASSWORD: ${{ secrets.PASSWORD }} + # CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} # with: # user: ubuntu # host: ${{ secrets.STAGING_HOST_IP }} @@ -67,6 +70,8 @@ jobs: # DIGITALOCEAN_ACCESS_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }} # REGISTRY: ${{ secrets.REGISTRY }} # POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} + # PASSWORD: ${{ secrets.PASSWORD }} + # CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} # with: # user: ubuntu # host: ${{ secrets.PROD_HOST_IP }} diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 2266ec4..98c3129 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -14,11 +14,12 @@ jobs: - name: Run unit tests run: | docker compose -f ops/docker-compose.test.yml up --detach --wait - docker compose -f ops/docker-compose.test.yml exec backend pytest --cov-report=xml:/data/coverage.xml --cov=src/ . + docker compose -f ops/docker-compose.test.yml exec backend pytest --cov-report=xml:/data/coverage.xml --cov=src/ tests/ - name: Codecov - uses: codecov/codecov-action@v1 + if: success() + uses: codecov/codecov-action@v3 with: - file: /data/coverage.xml + files: /data/coverage.xml flags: unittests - name: Clean-up if: always() diff --git a/README.md b/README.md index 323c634..6349f48 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ a) A few years ago I read a [reddit blog post](https://www.redditinc.com/blog/ho b) Want keep my Python skills fresh since I've been doing a lot of full-stack development in my previous role (React/Java). -c) Showcase the ecosystem of my open source projects and how they work together: [Create Release GHA](https://github.com/nickatnight/releases-action), [FastAPI Backend Base](https://github.com/nickatnight/fastapi-backend-base), [Reddit Bot Base](https://github.com/nickatnight/docker-reddit-bot-base). +c) Showcase the ecosystem of my open source projects and how they work together: [Create Release GHA](https://github.com/nickatnight/releases-action), [FastAPI Backend Base](https://github.com/nickatnight/cookiecutter-fastapi-backend), [Reddit Bot Base](https://github.com/nickatnight/docker-reddit-bot-base). d) I'm curious to see stats of user engagement (how long did a game chain last, how many users did it contain, which subreddit plays the most, etc) diff --git a/backend/src/core/config.py b/backend/src/core/config.py index 08e4cf7..1983e68 100644 --- a/backend/src/core/config.py +++ b/backend/src/core/config.py @@ -30,6 +30,14 @@ class Settings(BaseSettings): POOL_SIZE: Optional[int] POSTGRES_URL: Optional[str] + CLIENT_ID: str = Field(default="", env="CLIENT_ID") + CLIENT_SECRET: str = Field(default="", env="CLIENT_SECRET") + USERNAME: str = Field(default="TagYoureItBot", env="USERNAME") + PASSWORD: str = Field(default="", env="PASSWORD") + BOT_NAME: str = Field(default="tag-youre-it-bot", env="BOT_NAME") + DEVELOPER: str = Field(default="nickatnight", env="DEVELOPER") + VERSION: str = Field(default="v1", env="VERSION") + @validator("POOL_SIZE", pre=True) def build_pool(cls, v: Optional[str], values: Dict[str, Any]) -> Any: if isinstance(v, int): diff --git a/ops/docker-compose.prod.yml b/ops/docker-compose.prod.yml index 75dcf4a..f73fd2f 100644 --- a/ops/docker-compose.prod.yml +++ b/ops/docker-compose.prod.yml @@ -12,6 +12,12 @@ x-fastapi-envs: &fastapi_envs - POSTGRES_PORT=5432 - VERSION=v1 - DEBUG=False + - CLIENT_ID=o6KtOpg-lDsN2aTVcihEjw + - CLIENT_SECRET=${CLIENT_SECRET} + - BOT_NAME=tag-youre-it-bot + - DEVELOPER=nickatnight + - USERNAME=TagYoureItBot + - PASSWORD=${PASSWORD} x-default_deploy: &default_deploy deploy: @@ -47,11 +53,11 @@ services: image: ${REGISTRY}/nginx:${GITHUB_SHA} environment: - UPSTREAMS=/:backend:8000 - - NGINX_SERVER_NAME=api.tagyoureitbackend.com # without this, /admin redirects to https://_/ + - NGINX_SERVER_NAME=api.tagyoureitbot.com # without this, /admin redirects to https://_/ - ENABLE_SSL=true - HTTPS_REDIRECT=true - CERTBOT_EMAIL=nickkelly.858@gmail.com - - DOMAIN_LIST=api.tagyoureitbackend.com + - DOMAIN_LIST=api.tagyoureitbot.com labels: com.tagyoureitbackend.container.name: tagyoureitbackend-nginx diff --git a/ops/docker-compose.staging.yml b/ops/docker-compose.staging.yml index 1c415f0..b5562f1 100644 --- a/ops/docker-compose.staging.yml +++ b/ops/docker-compose.staging.yml @@ -11,6 +11,12 @@ x-fastapi-envs: &fastapi_envs - POSTGRES_DB=tagyoureitbackend - POSTGRES_PORT=5432 - VERSION=v1 + - CLIENT_ID=o6KtOpg-lDsN2aTVcihEjw + - CLIENT_SECRET=${CLIENT_SECRET} + - BOT_NAME=tag-youre-it-bot + - DEVELOPER=nickatnight + - USERNAME=TagYoureItBot + - PASSWORD=${PASSWORD} x-default_deploy: &default_deploy deploy: @@ -46,11 +52,11 @@ services: image: ${REGISTRY}/nginx:${GITHUB_SHA} environment: - UPSTREAMS=/:backend:8000 - - NGINX_SERVER_NAME=api-staging.tagyoureitbackend.com # without this, /admin redirects to https://_/ + - NGINX_SERVER_NAME=api-staging.tagyoureitbot.com # without this, /admin redirects to https://_/ - ENABLE_SSL=true - HTTPS_REDIRECT=true - CERTBOT_EMAIL=nickkelly.858@gmail.com - - DOMAIN_LIST=api-staging.tagyoureitbackend.com + - DOMAIN_LIST=api-staging.tagyoureitbot.com labels: com.tagyoureitbackend.container.name: tagyoureitbackend-nginx diff --git a/ops/docker-compose.test.yml b/ops/docker-compose.test.yml index 9c2493a..b945bf1 100644 --- a/ops/docker-compose.test.yml +++ b/ops/docker-compose.test.yml @@ -2,9 +2,6 @@ version: '3.7' -volumes: - test-data: - services: backend: build: @@ -32,12 +29,12 @@ services: - POSTGRES_DB=test - POSTGRES_PORT=5432 - POSTGRES_HOST=db-test - volumes: - - test-data:/data # to access coverage.xml depends_on: - db-test expose: - "8000" + volumes: + - /data:/data # to access coverage.xml db-test: image: postgres:14.1-alpine