Skip to content

Commit

Permalink
Merge 'develop' into main (#1)
Browse files Browse the repository at this point in the history
* ops: small tweaks and config changes

* ops: add missing volume for coverage
  • Loading branch information
nickatnight authored Feb 22, 2023
1 parent e3eb809 commit 0e508c7
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
branches:
- main
- develop

env:
DOCTL_VERSION: 1.92.0

Expand Down Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 8 additions & 0 deletions backend/src/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
10 changes: 8 additions & 2 deletions ops/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
- [email protected]
- DOMAIN_LIST=api.tagyoureitbackend.com
- DOMAIN_LIST=api.tagyoureitbot.com

labels:
com.tagyoureitbackend.container.name: tagyoureitbackend-nginx
Expand Down
10 changes: 8 additions & 2 deletions ops/docker-compose.staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
- [email protected]
- DOMAIN_LIST=api-staging.tagyoureitbackend.com
- DOMAIN_LIST=api-staging.tagyoureitbot.com

labels:
com.tagyoureitbackend.container.name: tagyoureitbackend-nginx
Expand Down
7 changes: 2 additions & 5 deletions ops/docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

version: '3.7'

volumes:
test-data:

services:
backend:
build:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0e508c7

Please sign in to comment.