Skip to content

πŸ’‘ chore: CI fix env settings #31

πŸ’‘ chore: CI fix env settings

πŸ’‘ chore: CI fix env settings #31

Workflow file for this run

name: CI
on:
push:
jobs:
static-analysis: # mypy, black, ruff λ“± 정적 뢄석
runs-on: ubuntu-22.04 # μ‹€μ œ ν”„λ‘œλ•μ…˜μ—μ„œλŠ” λͺ¨λ“  버전을 κ³ μ •ν•˜λŠ” 것이 μ’‹λ‹€.
# 예기치 λͺ»ν•˜κ²Œ 버전이 μ˜¬λΌκ°€μ„œ μž₯μ• λ‚˜λŠ” 것을 막기 μœ„ν•΄
steps:
- name: Check out the codes
uses: actions/checkout@v2
- name: Setup python environment
id: setup-python
uses: actions/setup-python@v2
with:
python-version: "3.12"
- name: Cache Poetry
id: cache-poetry
uses: actions/cache@v4
with:
key: poetry-1.8.5
path: ~/.local/ # poetry λŠ” ~/.local 에 μ„€μΉ˜λ˜λ―€λ‘œ, 이 디렉터리λ₯Ό ν†΅μ§Έλ‘œ μΊμ‹œν•  κ²ƒμž…λ‹ˆλ‹€.
- name: Install Poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: |
curl -sSL https://install.python-poetry.org | python3 - --version 1.8.5
- name: Register Poetry bin
run: echo "${HOME}/.poetry/bin" >> $GITHUB_PATH
- name: Cache dependencies
id: cache-venv
uses: actions/cache@v4
with:
key: python-${{ steps.setup-python.outputs.python-version }}-poetry-lock-${{ hashFiles('poetry.lock') }}-toml-${{ hashFiles('pyproject.toml') }}-poetry-1.8.5
path: /home/runner/.cache/pypoetry/virtualenvs/
- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: poetry install --no-root
- name: Run Black
run: poetry run black . --check
- name: Run Ruff
run: |
poetry run ruff check --select I
poetry run ruff check
- name: Run Mypy
run: poetry run mypy .
test: # 전체 ν…ŒμŠ€νŠΈ μ‹€ν–‰ν•œλ‹€.
runs-on: ubuntu-22.04
services:
redis:
image: redis:7.2-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 5s
--health-retries 5
env:
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: 3306
MYSQL_USER: root
MYSQL_PASSWORD: password
MYSQL_DATABASE: tellingme_local
REDIS_HOST: localhost
steps:
- name: Check out the codes
uses: actions/checkout@v2
- name: Setup python environment
id: setup-python
uses: actions/setup-python@v2
with:
python-version: "3.12"
- name: Cache Poetry
id: cache-poetry
uses: actions/cache@v4
with:
key: poetry-1.8.5
path: ~/.local/ # poetry λŠ” ~/.local 에 μ„€μΉ˜λ˜λ―€λ‘œ, 이 디렉터리λ₯Ό ν†΅μ§Έλ‘œ μΊμ‹œν•  κ²ƒμž…λ‹ˆλ‹€.
- name: Install Poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: |
curl -sSL https://install.python-poetry.org | python3 - --version 1.8.5
- name: Register Poetry bin
run: echo "${HOME}/.poetry/bin" >> $GITHUB_PATH
- name: Cache dependencies
id: cache-venv
uses: actions/cache@v4
with:
key: python-${{ steps.setup-python.outputs.python-version }}-poetry-lock-${{ hashFiles('poetry.lock') }}-toml-${{ hashFiles('pyproject.toml') }}-poetry-1.8.5
path: /home/runner/.cache/pypoetry/virtualenvs/
- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: poetry install --no-root
- name: Set timezone to KST
run: |
sudo rm /etc/localtime
sudo ln -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime
- name: Start Mysql
run: |
sudo systemctl start mysql
mysql -e "use mysql; FLUSH PRIVILEGES; ALTER USER '${{ env.MYSQL_USER }}'@'localhost' IDENTIFIED BY '${{ env.MYSQL_PASSWORD }}';" -uroot -proot
mysql -e 'CREATE DATABASE ${{ env.MYSQL_DATABASE }};' -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }}
- name: Run tests
run: |
poetry run coverage run -m pytest .
poetry run coverage report -m
# deploy:
# runs-on: ubuntu-24.04
# needs: [test, static-analysis]
# if: github.ref == 'refs/heads/main'
# steps:
# - name: Check out the codes
# uses: actions/checkout@v3
#
# - name: deploy staging
# env:
# PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY_STAGING }}
# HOSTNAME: ${{ secrets.SSH_HOST_STAGING }}
# USER_NAME: ${{ secrets.USER_NAME_STAGING }}
#
# # staging μ„œλ²„μ˜ .bashrc 에 gunicorn_reload κ°€ μ •μ˜λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. gunicorn master μ—κ²Œ HUP λ₯Ό μ€˜μ„œ worker λ₯Ό μž¬μ‹œμž‘ν•©λ‹ˆλ‹€.
# run: |
# echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
# ssh -o StrictHostKeyChecking=no -t -i private_key ${USER_NAME}@${HOSTNAME} "bash -i -c 'gunicorn_reload'"
# todo : CD μž‘μ„±ν•˜κΈ°