-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (124 loc) · 4.75 KB
/
checks.yml
File metadata and controls
151 lines (124 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
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 작성하기