Skip to content

Commit

Permalink
Merge branch 'coronasafe:develop' into fix-ohcnetwork#1956
Browse files Browse the repository at this point in the history
  • Loading branch information
UdaySagar-Git authored Mar 28, 2024
2 parents 1959e28 + fa46f2f commit 299b499
Show file tree
Hide file tree
Showing 57 changed files with 2,389 additions and 792 deletions.
135 changes: 37 additions & 98 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ name: Deploy Care
on:
workflow_dispatch:
push:
tags:
- 'v*'
branches:
- master
- production
- develop
- staging
paths-ignore:
- "docs/**"

Expand Down Expand Up @@ -33,32 +35,35 @@ jobs:
test:
uses: ./.github/workflows/test-base.yml

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

- name: Docker meta
- name: Generate docker tags
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
${{ secrets.DOCKER_HUB_USERNAME }}/${{ github.event.repository.name }}
tags: |
type=raw,value=latest-${{ github.run_number }}
type=raw,value=production-latest,enable=${{ github.ref == 'refs/heads/v*' }}
type=raw,value=production-latest-${{ github.run_number }}-{{date 'YYYYMMDD'}}-{{sha}},enable=${{ github.ref == 'refs/heads/v*' }}
type=raw,value=staging-latest,enable=${{ github.ref == 'refs/heads/staging' }}
type=raw,value=staging-latest-${{ github.run_number }}-{{date 'YYYYMMDD'}}-{{sha}},enable=${{ github.ref == 'refs/heads/staging' }}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/develop' }}
type=raw,value=latest-${{ github.run_number }},enable=${{ github.ref == 'refs/heads/develop' }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
flavor: |
latest=true
latest=false
- name: Set up QEMU
- name: Setup QEMU
uses: docker/setup-qemu-action@v3

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

- name: Login to DockerHub
Expand All @@ -75,14 +80,14 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Cache Docker layers
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Pipfile.lock', 'docker/prod.Dockerfile') }}
key: ${{ runner.os }}-buildx-build-${{ hashFiles('Pipfile.lock', 'docker/prod.Dockerfile') }}
restore-keys: |
${{ runner.os }}-buildx-
${{ runner.os }}-buildx-build-
- name: Build image
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
Expand Down Expand Up @@ -110,86 +115,19 @@ jobs:
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
build-production:
needs: test
name: Build & Push Production to container registries
if: github.ref == 'refs/heads/production'
notify-release:
needs: build
if: github.ref == 'refs/tags/v*'
name: Notify release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}
${{ secrets.DOCKER_HUB_USERNAME }}/${{ github.event.repository.name }}
tags: |
type=raw,value=production-latest,enable=${{ github.ref == 'refs/heads/production' }}
type=raw,value=production-latest-${{ github.run_number }}-{{date 'YYYYMMDD'}}-{{sha}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
flavor: |
latest=false
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Pipfile.lock', 'docker/prod.Dockerfile') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build image
uses: docker/build-push-action@v5
with:
context: .
file: docker/prod.Dockerfile
push: true
provenance: false
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
build-args: |
APP_VERSION=${{ github.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- 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 }}

- name: Move cache
- name: Notify release
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
echo "Release ${{ github.sha }} is ready to be deployed to production"
deploy-staging-egov:
needs: build-staging
needs: build
if: github.ref == 'refs/heads/develop'
name: Deploy to ECS API Egov
runs-on: ubuntu-latest
environment:
Expand Down Expand Up @@ -253,7 +191,8 @@ jobs:
wait-for-service-stability: true

deploy-staging-gcp:
needs: build-staging
needs: build
if: github.ref == 'refs/heads/staging'
name: Deploy to staging GCP cluster
runs-on: ubuntu-latest
environment:
Expand Down Expand Up @@ -299,7 +238,7 @@ jobs:
kubectl apply -f care-celery-worker.yaml
deploy-production-manipur:
needs: build-production
needs: notify-release
name: Deploy to GKE Manipur
runs-on: ubuntu-latest
environment:
Expand Down Expand Up @@ -345,7 +284,7 @@ jobs:
kubectl apply -f care-celery-worker.yaml
deploy-production-karnataka:
needs: build-production
needs: notify-release
name: Deploy to GKE Karnataka
runs-on: ubuntu-latest
environment:
Expand Down Expand Up @@ -391,7 +330,7 @@ jobs:
kubectl apply -f care-celery-worker.yaml
deploy-production-assam:
needs: build-production
needs: notify-release
name: Deploy to GKE Assam
runs-on: ubuntu-latest
environment:
Expand Down Expand Up @@ -437,7 +376,7 @@ jobs:
kubectl apply -f care-celery-worker.yaml
deploy-production-sikkim:
needs: build-production
needs: notify-release
name: Deploy to GKE Sikkim
runs-on: ubuntu-latest
environment:
Expand Down Expand Up @@ -483,7 +422,7 @@ jobs:
kubectl apply -f care-celery-worker.yaml
deploy-production-nagaland:
needs: build-production
needs: notify-release
name: Deploy to GKE Nagaland
runs-on: ubuntu-latest
environment:
Expand Down Expand Up @@ -529,7 +468,7 @@ jobs:
kubectl apply -f care-celery-worker.yaml
deploy-production-meghalaya:
needs: build-production
needs: notify-release
name: Deploy to GKE Meghalaya
runs-on: ubuntu-latest
environment:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ name: Docs
on:
push:
branches:
- master
- develop
paths:
- "docs/**"
pull_request:
branches:
- master
- develop
paths:
- "docs/**"
workflow_dispatch:
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
retention-days: 30

deploy-docs:
if: github.repository == 'coronasafe/care' && github.ref == 'refs/heads/master'
if: github.repository == 'coronasafe/care' && github.ref == 'refs/heads/develop'
name: Deploy docs
runs-on: ubuntu-latest
needs: build-docs
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: Lint Code Base

on:
pull_request:
branches: [master]
branches:
- develop
- staging
merge_group:

jobs:
Expand All @@ -24,7 +26,7 @@ jobs:
- name: Lint Code Base
uses: github/super-linter/slim@v5
env:
DEFAULT_BRANCH: master
DEFAULT_BRANCH: develop
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_ALL_CODEBASE: false
VALIDATE_PYTHON_BLACK: true
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/test-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:
with:
load: true
set: |
*.cache-from=type=local,src=/tmp/.buildx-cache
*.cache-to=type=local,dest=/tmp/.buildx-cache-new
*.cache-from=type=local,src=/tmp/.buildx-cache
*.cache-to=type=local,dest=/tmp/.buildx-cache-new
files: docker-compose.yaml,docker-compose.local.yaml

- name: Start services
Expand All @@ -35,6 +35,9 @@ jobs:
- name: Check migrations
run: make checkmigration

- name: Validate integrity of fixtures
run: make load-dummy-data

- name: Run tests
run: make test-coverage

Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
rev: v4.4.0
hooks:
- id: no-commit-to-branch
args: [--branch, master, --branch, production]
args: [--branch, develop, --branch, staging, --branch, production]
- id: check-merge-conflict
- id: check-builtin-literals
- id: mixed-line-ending
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"githubPullRequests.ignoredPullRequestBranches": ["master"],
"githubPullRequests.ignoredPullRequestBranches": ["develop", "staging"],
"python.formatting.blackPath": "${workspaceFolder}/.venv/bin/black",
"python.formatting.provider": "black",
"python.languageServer": "Pylance",
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pre-commit install

to run pre-commit on your branch:
```bash
pre-commit run --files $(git diff --name-only master...HEAD)
pre-commit run --files $(git diff --name-only develop...HEAD)
```

#### Using Docker
Expand Down
14 changes: 7 additions & 7 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name = "pypi"
[packages]
argon2-cffi = "==23.1.0"
authlib = "==1.2.1"
boto3 = "==1.34.27"
boto3 = "==1.34.65"
celery = "==5.3.6"
django = "==4.2.10"
django-environ = "==0.11.2"
Expand All @@ -23,18 +23,18 @@ django-rest-passwordreset = "==1.3.0"
django-simple-history = "==3.3.0"
djangoql = "==0.17.1"
djangorestframework = "==3.14.0"
djangorestframework-simplejwt = "==5.3.0"
djangorestframework-simplejwt = "==5.3.1"
dry-rest-permissions = "==0.1.10"
drf-nested-routers = "==0.93.4"
drf-spectacular = "==0.26.4"
"fhir.resources" = "==6.5.0"
gunicorn = "==21.2.0"
healthy-django = "==0.1.0"
jsonschema = "==4.20.0"
jwcrypto = "==1.5.1"
jwcrypto = "==1.5.6"
newrelic = "==9.3.0"
pillow = "==10.2.0"
psycopg = "==3.1.14"
psycopg = "==3.1.18"
pycryptodome = "==3.20.0"
pydantic = "==1.10.12" # fix for fhir.resources < 7.0.2
pyjwt = "==2.8.0"
Expand All @@ -48,17 +48,17 @@ redis-om = "==0.2.1"

[dev-packages]
black = "==23.9.1"
boto3-stubs = {extras = ["s3", "boto3"], version = "==1.34.27"}
boto3-stubs = {extras = ["s3", "boto3"], version = "==1.34.65"}
coverage = "==7.4.0"
debugpy = "==1.7.0"
debugpy = "==1.8.1"
django-coverage-plugin = "==3.1.0"
django-debug-toolbar = "==4.2.0"
django-extensions = "==3.2.3"
django-silk = "==5.0.3"
django-stubs = "==4.2.4"
djangorestframework-stubs = "==3.14.2"
factory-boy = "==3.3.0"
flake8 = "==6.1.0"
flake8 = "==7.0.0"
freezegun = "==1.2.2"
ipython = "==8.15.0"
isort = "==5.12.0"
Expand Down
Loading

0 comments on commit 299b499

Please sign in to comment.