diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f218640..dca69d3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,7 +3,7 @@ name: Deploy on: workflow_dispatch: - push: + push: &trigger branches: - main paths: @@ -12,9 +12,9 @@ on: - "Dockerfile" - "requirements.txt" - "app/**" - # - "data/**" - "root/**" - "scripts/**" + pull_request: *trigger release: types: - published @@ -71,4 +71,6 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} target: prod - push: true + + # pr에서는 테스트용이기 때문에 push하지 않음 (dry-run) + push: ${{ github.event_name != 'pull_request' }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1939f3e..dd492ce 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,7 +29,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - if [ -f requirements.txt ]; then + if [ -f requirements-dev.txt ]; then + pip install -r requirements-dev.txt + elif [ -f requirements.txt ]; then pip install -r requirements.txt fi diff --git a/Dockerfile b/Dockerfile index 8a5bff6..d19d6ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,6 @@ RUN uv venv $VIRTUAL_ENV # 운영용: 빌드 FROM prod-base AS prod-build -RUN apk add --no-cache gdal-dev gcc g++ COPY requirements.txt . RUN uv pip install --no-cache -r requirements.txt @@ -40,5 +39,4 @@ WORKDIR /app/scripts FROM base AS dev ENV APP_ENV=development ENV PYTHONDONTWRITEBYTECODE=1 -RUN apk add --no-cache gdal-dev gcc g++ WORKDIR /app/scripts diff --git a/README.md b/README.md index 891239c..0a26c59 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,11 @@ ## 설치 +> [!NOTE] +> `requirements-dev.txt` 파일 지정 시 +> [테스트](#테스트) 및 [insert-data](#insert-data) +> 작업에 사용되는 라이브러리까지 같이 설치됨 + 나열된 목록을 한 번에 설치 ```shell @@ -54,7 +59,7 @@ fastapi dev app 내장 명령어 목록 및 설명 -### create-user +### create user 데이터베이스에 사용자 추가 @@ -63,7 +68,11 @@ fastapi dev app docker exec -it create-user [name] ``` -### insert-data +### insert data + +> [!IMPORTANT] +> 도커 이미지 경량화를 위해 제거되었으며, +> 파이썬으로 직접 파일을 실행할 수 있습니다. > [!IMPORTANT] > [url.txt](data/url.txt) 파일 내 구글 드라이브에서 모든 파일 다운로드 @@ -71,10 +80,11 @@ docker exec -it create-user [name] `data` 폴더 내 csv 파일 내 데이터를 데이터베이스에 삽입 (테이블 자동 생성) ```shell -docker exec -it insert-data +python3 scripts/insert_data.py +# docker exec -it insert-data # deprecated ``` -### insert-seeds +### insert seeds > [!IMPORTANT] > `insert-data`가 먼저 수행되어야 함 @@ -88,10 +98,13 @@ docker exec -it insert-data ```shell # num_of_recs 기본값: 30 # num_of_users 기본값: 0 + +python3 scripts/insert_seeds.py [num_of_recs] [num_of_users] +# or docker exec -it insert-seeds [num_of_recs] [num_of_users] ``` -### drop-seeds +### drop seeds > [!NOTE] > 게스트 계정과 property_infrastructure 테이블 데이터는 삭제되지 않음 @@ -99,21 +112,25 @@ docker exec -it insert-seeds [num_of_recs] [num_of_users] 생성된 seed 데이터 삭제. ```shell +python3 scripts/drop_seeds.py +# or docker exec -it drop-seeds ``` -### drop-tables +### drop tables 데이블 삭제 ```shell +python3 scripts/drop_tables.py [-y|--yes] +# or docker exec -it drop-tables [-y|--yes] ``` 연결된 데이터베이스의 모든 테이블 삭제. `-y` 또는 `--yes` 입력 시 삭제 여부를 묻지 않고 즉시 삭제함. -### drop-to-seeds +### drop to seeds `drop-tables`, `insert-data`, `insert-seeds`를 연속으로 실행하는 스크립트 diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..1a0a5b7 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,5 @@ +-r requirements.txt + +pytest +pytest-cov +geopandas diff --git a/requirements.txt b/requirements.txt index b594e02..55a8fa7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,6 @@ fastapi[standard] itsdangerous scalar-fastapi -pytest -pytest-cov sqlalchemy geoalchemy2 pymysql @@ -10,4 +8,3 @@ argon2-cffi python-dotenv cuid2 redis -geopandas diff --git a/scripts/insert_data.py b/scripts/insert_data.py old mode 100755 new mode 100644 index 97f40cd..a03686f --- a/scripts/insert_data.py +++ b/scripts/insert_data.py @@ -1,5 +1,3 @@ -#!/usr/bin/with-contenv python3 - import re import os import sys