Skip to content

Commit 74b6305

Browse files
Merge pull request #2263 from IFRCGo/feature/migrate-to-gh
Feature/migrate to gh
2 parents 2298d74 + 761fdbb commit 74b6305

File tree

6 files changed

+106
-92
lines changed

6 files changed

+106
-92
lines changed

.circleci/config.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.

.github/workflows/build-publish-docker-helm.yaml renamed to .github/workflows/build-publish-docker-helm.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ permissions:
1414
packages: write
1515

1616
jobs:
17+
ci:
18+
name: CI
19+
uses: ./.github/workflows/ci.yml
20+
1721
build:
22+
name: Publish Helm
23+
needs: ci
1824
runs-on: ubuntu-latest
1925

2026
steps:
@@ -55,4 +61,4 @@ jobs:
5561
5662
- name: Push Helm Chart
5763
run: |
58-
helm push .helm-charts/ifrcgo-helm-${{ steps.get_version.outputs.VERSION }}.tgz oci://ghcr.io/ifrcgo/go-api
64+
helm push .helm-charts/ifrcgo-helm-${{ steps.get_version.outputs.VERSION }}.tgz oci://ghcr.io/ifrcgo/go-api

.github/workflows/ci.yaml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: CI
2+
3+
on:
4+
workflow_call:
5+
pull_request:
6+
# NOTE: For develop & master, they are run through helm github action ./build-publish-docker-helm.yml
7+
8+
9+
jobs:
10+
pre_commit_checks:
11+
name: 🚴 Pre-Commit checks 🚴
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@main
16+
- name: Install poetry
17+
run: pipx install poetry
18+
- uses: actions/setup-python@main
19+
with:
20+
cache: 'poetry'
21+
- run: poetry install
22+
- uses: pre-commit/action@main
23+
24+
test:
25+
name: 🚴 Checks & Test 🚴
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- uses: actions/checkout@main
30+
31+
- name: 🐳 Set up Docker Buildx
32+
id: buildx
33+
uses: docker/setup-buildx-action@v3
34+
35+
- name: 🐳 Build image
36+
uses: docker/build-push-action@v6
37+
with:
38+
context: .
39+
file: Dockerfile
40+
push: false
41+
load: true
42+
tags: ifrcgo/go-api:latest
43+
cache-from: type=gha
44+
cache-to: type=gha,mode=max
45+
46+
- name: Docker config setup & Pull docker images
47+
run: |
48+
cp .env-sample .env &&
49+
docker compose run --rm serve ls
50+
51+
- name: 🕮 Validate if there are no pending django migrations.
52+
run: |
53+
docker compose run --rm serve ./manage.py makemigrations --check --dry-run || {
54+
echo 'There are some changes to be reflected in the migration. Make sure to run makemigrations';
55+
exit 1;
56+
}
57+
58+
- name: 🕮 Validate SentryMonitor config
59+
run: |
60+
docker compose run --rm serve ./manage.py cron_job_monitor --validate-only || {
61+
echo 'There are some changes to be reflected in the SentryMonitor. Make sure to update SentryMonitor';
62+
exit 1;
63+
}
64+
65+
- name: Run django migrations
66+
run: docker compose run --rm serve ./manage.py test --keepdb -v 2 --pattern="test_fake.py"
67+
68+
- name: 🤞 Run Test 🧪
69+
run: docker compose run --rm serve pytest --reuse-db --durations=10

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM python:3.9-bullseye
22

3-
ENV PYTHONUNBUFFERED 1
3+
ENV PYTHONUNBUFFERED=1
44
EXPOSE 80
55
EXPOSE 443
66

docker-compose.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.5'
2-
31
x-server: &base_server_setup
42
image: ifrcgo/go-api:latest
53
build: .
@@ -29,8 +27,8 @@ x-server: &base_server_setup
2927
CACHE_MIDDLEWARE_SECONDS: ${CACHE_MIDDLEWARE_SECONDS:-600}
3028
ELASTIC_SEARCH_HOST: ${ELASTIC_SEARCH_HOST:-elasticsearch://elasticsearch:9200}
3129
# Appeal API
32-
APPEALS_USER: ${APPEALS_USER}
33-
APPEALS_PASS: ${APPEALS_PASS}
30+
APPEALS_USER: ${APPEALS_USER:-}
31+
APPEALS_PASS: ${APPEALS_PASS:-}
3432
# Sentry
3533
SENTRY_DSN: ${SENTRY_DSN:-}
3634
SENTRY_SAMPLE_RATE: ${SENTRY_SAMPLE_RATE:-0.2}
@@ -56,7 +54,6 @@ x-server: &base_server_setup
5654
- db
5755
- redis
5856
- elasticsearch
59-
- kibana
6057

6158

6259
services:
@@ -107,6 +104,7 @@ services:
107104
- '5601:5601'
108105
depends_on:
109106
- elasticsearch
107+
profiles: [elasticsearch]
110108

111109
serve:
112110
<<: *base_server_setup
@@ -119,93 +117,119 @@ services:
119117
<<: *base_server_setup
120118
command: python manage.py run_celery_dev
121119

120+
# ------------------ Helper CLI Commands
121+
# Usage: `docker compose run --rm <service-name>`
122+
# Example: `docker compose run --rm bash`
122123
bash:
123124
<<: *base_server_setup
124125
entrypoint: /bin/bash
126+
profiles: [cli]
125127

126128
shell:
127129
<<: *base_server_setup
128130
command: python manage.py shell
131+
profiles: [cli]
129132

130133
loaddata:
131134
<<: *base_server_setup
132135
command: python manage.py loaddata Regions Countries Districts DisasterTypes Actions Groups
136+
profiles: [cli]
133137

134138
ingest_databank:
135139
<<: *base_server_setup
136140
command: python manage.py ingest_databank
141+
profiles: [cli]
137142

138143
collectstatic:
139144
<<: *base_server_setup
140145
command: python manage.py collectstatic --noinput -l
146+
profiles: [cli]
141147

142148
createsuperuser:
143149
<<: *base_server_setup
144150
command: python manage.py createsuperuser
151+
profiles: [cli]
145152

146153
ingest_appeals:
147154
<<: *base_server_setup
148155
command: python manage.py ingest_appeals
156+
profiles: [cli]
149157

150158
ingest_appeal_docs:
151159
<<: *base_server_setup
152160
command: python manage.py ingest_appeal_docs
161+
profiles: [cli]
153162

154163
user_registration_reminder:
155164
<<: *base_server_setup
156165
command: python manage.py user_registration_reminder
166+
profiles: [cli]
157167

158168
ingest_appeal_docs_fullscan:
159169
<<: *base_server_setup
160170
command: python manage.py ingest_appeal_docs --fullscan
171+
profiles: [cli]
161172

162173
ingest_mdb:
163174
<<: *base_server_setup
164175
command: python manage.py ingest_mdb
176+
profiles: [cli]
165177

166178
migrate:
167179
<<: *base_server_setup
168180
command: python manage.py migrate
181+
profiles: [cli]
169182

170183
makemigrations:
171184
<<: *base_server_setup
172185
command: python manage.py makemigrations
186+
profiles: [cli]
173187

174188
makemigrations_merge:
175189
<<: *base_server_setup
176190
command: python manage.py makemigrations --merge
191+
profiles: [cli]
177192

178193
make_permissions:
179194
<<: *base_server_setup
180195
command: python manage.py make_permissions
196+
profiles: [cli]
181197

182198
test:
183199
<<: *base_server_setup
184200
command: pytest --durations=10
201+
profiles: [cli]
185202

186203
test_snapshot_update:
187204
<<: *base_server_setup
188205
command: python manage.py test -k --snapshot-update
206+
profiles: [cli]
189207

190208
testr:
191209
<<: *base_server_setup
192210
command: pytest --reuse-db --durations=10 -s
211+
profiles: [cli]
193212

194213
coverage:
195214
<<: *base_server_setup
196215
command: coverage run --source='.' manage.py test -k
216+
profiles: [cli]
197217

198218
coverage_report:
199219
<<: *base_server_setup
200220
command: coverage report
221+
profiles: [cli]
201222

202223
coverage_html:
203224
<<: *base_server_setup
204225
command: coverage html
226+
profiles: [cli]
205227

206228
triggers_to_db:
207229
<<: *base_server_setup
208230
command: python manage.py triggers_to_db
231+
profiles: [cli]
232+
209233

210234
volumes:
211235
redis-data:

0 commit comments

Comments
 (0)