-
Notifications
You must be signed in to change notification settings - Fork 7
211 lines (199 loc) · 6.56 KB
/
pr.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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
name: PR checks
on: pull_request
env:
ACTIONS_RUNNER_DEBUG: false
SECRET_KEY: test
ENV: ci
FRONTEND_DOMAIN: http://localhost
MONGO_AUTH_USERNAME: root
MONGO_AUTH_PASSWORD: rootPassXXX
MONGO_APP_DATABASE: binbot
MONGO_KAFKA_DATABASE: kafka
MONGO_AUTH_DATABASE: admin
MONGO_HOSTNAME: data_db
MONGO_PORT: 27017
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
POSTGRES_DB: "postgres"
jobs:
push_to_registry:
name: Test and deploy binbot
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432/tcp
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
data_db:
image: mongo:7.0
options: >-
--health-cmd mongosh
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
MONGO_INITDB_ROOT_USERNAME: ${{ env.MONGO_AUTH_USERNAME }}
MONGO_INITDB_ROOT_PASSWORD: ${{ env.MONGO_AUTH_PASSWORD }}
ports:
- 27017:27017
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Build image
run: docker build --tag binbot .
- name: Run docker container
run: docker run --network host -e POSTGRES_PORT=${{ job.services.postgres.ports[5432] }} --name app -d binbot
- name: Test front-end
run: curl --head --fail --retry-delay 5 --retry 3 --retry-connrefused http://localhost
- name: Test back-end
run: curl --fail --retry-delay 5 --retry 3 --retry-connrefused localhost:8006
- name: Tag image
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
docker commit binbot_api carloswufei/binbot &
docker tag binbot carloswufei/binbot
- name: Push to Docker Hub
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker push carloswufei/binbot
deploy_streaming:
name: Deploy streaming
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Build image
run: docker build --tag binbot_streaming -f Dockerfile.streaming .
- name: Test run script
run: |
docker run --network host --name binbot_streaming \
-e MONGO_HOSTNAME=${{ env.MONGO_HOSTNAME }} \
-e MONGO_PORT=${{ env.MONGO_PORT }} \
-e MONGO_APP_DATABASE=${{ env.MONGO_APP_DATABASE }} \
-e MONGO_AUTH_USERNAME=${{ env.MONGO_AUTH_USERNAME }} \
-e MONGO_AUTH_PASSWORD=${{ env.MONGO_AUTH_PASSWORD }} \
-e PYTHONUNBUFFERED=TRUE \
-e ENV=ci -d binbot_streaming
- name: Tag image
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
docker commit binbot_streaming carloswufei/binbot_streaming &
docker tag binbot_streaming carloswufei/binbot_streaming
- name: Push to Docker Hub
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker push carloswufei/binbot_streaming
deploy_cronjobs:
name: Deploy cronjobs
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Build image
run: docker build --tag binbot_cronjobs -f Dockerfile.cronjobs .
- name: Test run script
run: |
docker run --network host --name binbot_cronjobs \
-e MONGO_HOSTNAME=${{ env.MONGO_HOSTNAME }} \
-e MONGO_PORT=${{ env.MONGO_PORT }} \
-e MONGO_APP_DATABASE=${{ env.MONGO_APP_DATABASE }} \
-e MONGO_AUTH_USERNAME=${{ env.MONGO_AUTH_USERNAME }} \
-e MONGO_AUTH_PASSWORD=${{ env.MONGO_AUTH_PASSWORD }} \
-e PYTHONUNBUFFERED=TRUE \
-e ENV=ci -d binbot_cronjobs
- name: Tag image
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
docker commit binbot_cronjobs carloswufei/binbot_cronjobs &
docker tag binbot_cronjobs carloswufei/binbot_cronjobs
- name: Push to Docker Hub
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker push carloswufei/binbot_cronjobs
python-tests:
name: Python code tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432/tcp
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
defaults:
run:
working-directory: api
steps:
- name: Checkout repo
uses: actions/checkout@v4
# Setup Python (faster than using Python container)
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install pipenv
run: python3 -m pip install pipenv
- name: Install dependencies
run: |
pipenv install --dev --system --deploy --ignore-pipfile --clear
pipenv install httpx coverage
- name: Run tests
env:
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
run: coverage run -m pytest .
python-linting:
name: Python code linting
runs-on: ubuntu-latest
defaults:
run:
working-directory: api
steps:
- name: Checkout repo
uses: actions/checkout@v4
# Setup Python (faster than using Python container)
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install pipenv
run: python3 -m pip install pipenv
- name: Install dependencies
run: |
pipenv install --dev --system --deploy --ignore-pipfile --clear
pipenv install httpx
- name: Run linters
run: |
pipenv run ruff check .
pipenv run mypy .
frontend-tests:
name: React app tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: terminal
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test