-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (162 loc) · 5.37 KB
/
main.yml
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: cinemax-notifications
on:
push:
branches: [ main ]
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10']
services:
postgres:
image: postgres:14.5-alpine
ports:
- 5432:5432
env:
POSTGRES_DB: notifications_database
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
options: >-
--health-cmd "pg_isready"
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:7.0.5
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5
kafka:
image: confluentinc/cp-kafka:7.3.1
ports:
- 29092:29092
env:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_AUTO_CREATE_TOPICS_ENABLE: true
options: >-
--health-cmd "nc -z localhost 9092 || exit -1"
--health-interval 5s
--health-timeout 10s
--health-retries 10
zookeeper:
image: zookeeper:3.8
options: >-
--health-cmd "nc -z localhost 2181 || exit -1"
--health-interval 5s
--health-timeout 10s
--health-retries 10
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r backend/django_admin/requirements.txt --no-cache-dir
pip install -r backend/fastapi_receiver/requirements.txt --no-cache-dir
pip install -r backend/faust_worker/requirements.txt --no-cache-dir
- name: Lint with flake8
run: |
pip install wemake-python-styleguide flake8-html
flake8 backend --format=html --htmldir=flake8
- name: Lint with mypy
run: |
pip install mypy types-requests lxml
mypy backend --html-report=mypy
- name: Run Admin Panel
run: |
cd backend/django_admin/src
nohup python manage.py runserver &
- name: Stop Admin Panel
run: |
kill $(ps aux | grep python | grep manage.py | awk '{print $2}')
- name: Run API
run: |
cd backend/fastapi_receiver/src
nohup python main.py &
- name: Stop API
run: |
kill $(ps aux | grep python | grep main.py | awk '{print $2}')
- name: Run Worker
run: |
cd backend/faust_worker/src
nohup python main.py worker &
- name: Stop Worker
run: |
kill $(ps aux | grep python | grep main.py | awk '{print $2}')
- name: Output results
uses: actions/upload-artifact@v3
with:
name: Report
path: |
flake8/
mypy/
docker:
name: Docker
runs-on: ubuntu-latest
needs: tests
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push Backend to Docker Hub
uses: docker/build-push-action@v2
with:
push: true
context: backend/django_admin
tags: |
${{ secrets.DOCKER_USERNAME }}/notifications_admin:${{ vars.TAG }}
${{ secrets.DOCKER_USERNAME }}/notifications_admin:latest
- name: Push Backend to Docker Hub
uses: docker/build-push-action@v2
with:
push: true
context: backend/fastapi_receiver
tags: |
${{ secrets.DOCKER_USERNAME }}/notifications_api:${{ vars.TAG }}
${{ secrets.DOCKER_USERNAME }}/notifications_api:latest
- name: Push Backend to Docker Hub
uses: docker/build-push-action@v2
with:
push: true
context: backend/faust_worker
tags: |
${{ secrets.DOCKER_USERNAME }}/notifications_worker:${{ vars.TAG }}
${{ secrets.DOCKER_USERNAME }}/notifications_worker:latest
send_message:
name: Send message
runs-on: ubuntu-latest
needs: docker
steps:
- name: Send message
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
В репозитории ${{ github.repository }} выполнен коммит:
Автор: ${{ github.event.commits[0].author.name }}
Сообщение: ${{ github.event.commits[0].message }}
Ссылка: https://github.com/${{ github.repository }}/commit/${{github.sha}}