Skip to content

Feature/migrate to gh #2263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 0 additions & 62 deletions .circleci/config.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -14,7 +14,13 @@ permissions:
packages: write

jobs:
ci:
name: CI
uses: ./.github/workflows/ci.yml

build:
name: Publish Helm
needs: ci
runs-on: ubuntu-latest

steps:
@@ -55,4 +61,4 @@ jobs:

- name: Push Helm Chart
run: |
helm push .helm-charts/ifrcgo-helm-${{ steps.get_version.outputs.VERSION }}.tgz oci://ghcr.io/ifrcgo/go-api
helm push .helm-charts/ifrcgo-helm-${{ steps.get_version.outputs.VERSION }}.tgz oci://ghcr.io/ifrcgo/go-api
23 changes: 0 additions & 23 deletions .github/workflows/ci.yaml

This file was deleted.

69 changes: 69 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: CI

on:
workflow_call:
pull_request:
# NOTE: For develop & master, they are run through helm github action ./build-publish-docker-helm.yml


jobs:
pre_commit_checks:
name: 🚴 Pre-Commit checks 🚴
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@main
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@main
with:
cache: 'poetry'
- run: poetry install
- uses: pre-commit/action@main

test:
name: 🚴 Checks & Test 🚴
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@main

- name: 🐳 Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: 🐳 Build image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: false
load: true
tags: ifrcgo/go-api:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Docker config setup & Pull docker images
run: |
cp .env-sample .env &&
docker compose run --rm serve ls

- name: 🕮 Validate if there are no pending django migrations.
run: |
docker compose run --rm serve ./manage.py makemigrations --check --dry-run || {
echo 'There are some changes to be reflected in the migration. Make sure to run makemigrations';
exit 1;
}

- name: 🕮 Validate SentryMonitor config
run: |
docker compose run --rm serve ./manage.py cron_job_monitor --validate-only || {
echo 'There are some changes to be reflected in the SentryMonitor. Make sure to update SentryMonitor';
exit 1;
}

- name: Run django migrations
run: docker compose run --rm serve ./manage.py test --keepdb -v 2 --pattern="test_fake.py"

- name: 🤞 Run Test 🧪
run: docker compose run --rm serve pytest --reuse-db --durations=10
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.9-bullseye

ENV PYTHONUNBUFFERED 1
ENV PYTHONUNBUFFERED=1
EXPOSE 80
EXPOSE 443

34 changes: 29 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.5'

x-server: &base_server_setup
image: ifrcgo/go-api:latest
build: .
@@ -29,8 +27,8 @@ x-server: &base_server_setup
CACHE_MIDDLEWARE_SECONDS: ${CACHE_MIDDLEWARE_SECONDS:-600}
ELASTIC_SEARCH_HOST: ${ELASTIC_SEARCH_HOST:-elasticsearch://elasticsearch:9200}
# Appeal API
APPEALS_USER: ${APPEALS_USER}
APPEALS_PASS: ${APPEALS_PASS}
APPEALS_USER: ${APPEALS_USER:-}
APPEALS_PASS: ${APPEALS_PASS:-}
# Sentry
SENTRY_DSN: ${SENTRY_DSN:-}
SENTRY_SAMPLE_RATE: ${SENTRY_SAMPLE_RATE:-0.2}
@@ -56,7 +54,6 @@ x-server: &base_server_setup
- db
- redis
- elasticsearch
- kibana


services:
@@ -107,6 +104,7 @@ services:
- '5601:5601'
depends_on:
- elasticsearch
profiles: [elasticsearch]

serve:
<<: *base_server_setup
@@ -119,93 +117,119 @@ services:
<<: *base_server_setup
command: python manage.py run_celery_dev

# ------------------ Helper CLI Commands
# Usage: `docker compose run --rm <service-name>`
# Example: `docker compose run --rm bash`
bash:
<<: *base_server_setup
entrypoint: /bin/bash
profiles: [cli]

shell:
<<: *base_server_setup
command: python manage.py shell
profiles: [cli]

loaddata:
<<: *base_server_setup
command: python manage.py loaddata Regions Countries Districts DisasterTypes Actions Groups
profiles: [cli]

ingest_databank:
<<: *base_server_setup
command: python manage.py ingest_databank
profiles: [cli]

collectstatic:
<<: *base_server_setup
command: python manage.py collectstatic --noinput -l
profiles: [cli]

createsuperuser:
<<: *base_server_setup
command: python manage.py createsuperuser
profiles: [cli]

ingest_appeals:
<<: *base_server_setup
command: python manage.py ingest_appeals
profiles: [cli]

ingest_appeal_docs:
<<: *base_server_setup
command: python manage.py ingest_appeal_docs
profiles: [cli]

user_registration_reminder:
<<: *base_server_setup
command: python manage.py user_registration_reminder
profiles: [cli]

ingest_appeal_docs_fullscan:
<<: *base_server_setup
command: python manage.py ingest_appeal_docs --fullscan
profiles: [cli]

ingest_mdb:
<<: *base_server_setup
command: python manage.py ingest_mdb
profiles: [cli]

migrate:
<<: *base_server_setup
command: python manage.py migrate
profiles: [cli]

makemigrations:
<<: *base_server_setup
command: python manage.py makemigrations
profiles: [cli]

makemigrations_merge:
<<: *base_server_setup
command: python manage.py makemigrations --merge
profiles: [cli]

make_permissions:
<<: *base_server_setup
command: python manage.py make_permissions
profiles: [cli]

test:
<<: *base_server_setup
command: pytest --durations=10
profiles: [cli]

test_snapshot_update:
<<: *base_server_setup
command: python manage.py test -k --snapshot-update
profiles: [cli]

testr:
<<: *base_server_setup
command: pytest --reuse-db --durations=10 -s
profiles: [cli]

coverage:
<<: *base_server_setup
command: coverage run --source='.' manage.py test -k
profiles: [cli]

coverage_report:
<<: *base_server_setup
command: coverage report
profiles: [cli]

coverage_html:
<<: *base_server_setup
command: coverage html
profiles: [cli]

triggers_to_db:
<<: *base_server_setup
command: python manage.py triggers_to_db
profiles: [cli]


volumes:
redis-data: