Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/geekgawd/care into list-d…
Browse files Browse the repository at this point in the history
…etail-serializer-patient-external
  • Loading branch information
GeekGawd committed Sep 28, 2023
2 parents 9e3b566 + 2829067 commit ca7a79a
Show file tree
Hide file tree
Showing 109 changed files with 8,335 additions and 4,270 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.venv
.git
htmlcov
staticfiles
.coverage
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
source .venv/bin/activate; unset PS1
layout pipenv
dotenv
21 changes: 21 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "docker"
directory: "/docker"
schedule:
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
2 changes: 1 addition & 1 deletion .github/workflows/deployment-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('r*/base.txt', 'r*/production.txt', 'Dockerfile') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deployment-lambda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('r*/base.txt', 'r*/production.txt', 'Dockerfile') }}
Expand Down
164 changes: 38 additions & 126 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
paths-ignore:
- "docs/**"

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

env:
IMAGE_NAME: care
AWS_DEFAULT_REGION: ap-south-1
Expand All @@ -24,105 +28,18 @@ env:
CONTAINER_NAME_BACKEND: "care-backend"
CONTAINER_NAME_WORKER: "care-celery-worker"
CONTAINER_NAME_CRON: "care-celery-beat"

jobs:
test:
if: github.repository == 'coronasafe/care' && (github.ref == 'refs/heads/production' || github.ref == 'refs/heads/master')
runs-on: ubuntu-latest
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/care
name: Test
services:
db:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: care
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis:alpine
ports:
- 6379:6379
localstack:
image: localstack/localstack:latest
env:
AWS_DEFAULT_REGION: ap-south-1
EDGE_PORT: 4566
SERVICES: s3
ports:
- 4566:4566
steps:
- uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('r*/base.txt', 'r*/production.txt', 'Dockerfile') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Test build
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
push: false
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install binutils libproj-dev libjpeg-dev zlib1g-dev -y
pip install --upgrade pip
pip install -r requirements/local.txt
- name: Configure environment
run: |
echo "JWKS_BASE64=$(python manage.py generate_jwks)" >> $GITHUB_ENV
- name: Run celery worker for tests
run: celery -A config.celery_app worker -B --loglevel=INFO --detach

- name: Run Tests with coverage
run: coverage run manage.py test --settings=config.settings.test

- name: Generate coverage report
run: |
coverage combine || true
coverage xml
coverage report -m
- name: Upload coverage report
uses: codecov/codecov-action@v2

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
uses: ./.github/workflows/test-base.yml

build-staging:
needs: test
name: Build & Push Staging to container registries
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Docker meta
id: meta
Expand All @@ -141,14 +58,6 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('r*/base.txt', 'r*/production.txt', 'Dockerfile') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v2
with:
Expand All @@ -166,24 +75,33 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
file: docker/prod.Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
build-args: |
APP_VERSION=${{ github.sha }}
cache-from: type=gha,scope=cached-stage
cache-to: type=gha,scope=cached-stage,mode=max

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
version: ${{ github.sha }}

build-production:
needs: test
name: Build & Push Production to container registries
if: github.ref == 'refs/heads/production'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Docker meta
id: meta
Expand All @@ -200,17 +118,6 @@ jobs:
flavor: |
latest=false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('r*/base.txt', 'r*/production.txt', 'Dockerfile') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v2
with:
Expand All @@ -228,16 +135,22 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
file: docker/prod.Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
build-args: |
APP_VERSION=${{ github.sha }}
cache-from: type=gha,scope=cached-stage
cache-to: type=gha,scope=cached-stage,mode=max

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
version: ${{ github.sha }}

deploy-staging-egov:
needs: build-staging
Expand All @@ -248,7 +161,7 @@ jobs:
url: https://careapi.ohc.network
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
Expand Down Expand Up @@ -303,7 +216,6 @@ jobs:
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true


deploy-production-manipur:
needs: build-production
name: Deploy to GKE Manipur
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ jobs:
- uses: actions/setup-python@v3
with:
python-version: "3.11"
cache: 'pipenv'
cache-dependency-path: |
Pipfile.lock
- name: Install pipenv
run: curl https://raw.githubusercontent.com/pypa/pipenv/master/get-pipenv.py | python

- name: Install dependencies
run: |
pip install -r requirements/docs.txt
run: pipenv sync --categories "docs"

- name: Build docs
run: |
Expand Down Expand Up @@ -61,7 +66,7 @@ jobs:
touch build/.nojekyll
- name: Deploy docs
uses: JamesIves/github-pages-deploy-action@v4.3.3
uses: JamesIves/github-pages-deploy-action@v4.4.3
with:
branch: gh-pages
folder: build
1 change: 1 addition & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Lint Code Base
on:
pull_request:
branches: [master]
merge_group:

jobs:
build:
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/test-base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test

on:
workflow_call:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

- name: Bake docker images
uses: docker/[email protected]
with:
load: true
builder: ${{ steps.buildx.outputs.name }}
set: |
*.cache-from=type=gha,scope=cached-stage
*.cache-to=type=gha,scope=cached-stage,mode=max
files: docker-compose.yaml,docker-compose.local.yaml

- name: Start services
run: docker compose -f docker-compose.yaml -f docker-compose.local.yaml up -d --no-build

- name: Check migrations
run: make checkmigration

- name: Run tests
run: make test-coverage

- name: Upload coverage report
uses: codecov/codecov-action@v3
8 changes: 8 additions & 0 deletions .github/workflows/test-merge-queue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Test Pull Request

on:
merge_group:

jobs:
test:
uses: ./.github/workflows/test-base.yml
Loading

0 comments on commit ca7a79a

Please sign in to comment.