Skip to content

Commit

Permalink
Merge branch 'develop' into fix-ohcnetwork#7333
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Mar 19, 2024
2 parents e4f4e22 + df8c57b commit 6c2e225
Show file tree
Hide file tree
Showing 20 changed files with 469 additions and 195 deletions.
152 changes: 56 additions & 96 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ on:
push:
branches:
- develop
- master
- staging
tags:
- v*
pull_request:
branches:
- develop
- master
- staging
workflow_dispatch:

concurrency:
Expand All @@ -29,25 +31,26 @@ jobs:
runs-on: ubuntu-latest
name: Test
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

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

- name: Cache Docker layers
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('package-lock.json', 'Dockerfile') }}
key: ${{ runner.os }}-buildx-test-${{ hashFiles('package-lock.json', 'Dockerfile') }}
restore-keys: |
${{ runner.os }}-buildx-
${{ runner.os }}-buildx-test-
- name: Test build
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: false
provenance: false
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

Expand All @@ -60,132 +63,89 @@ jobs:
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
build-staging:
build:
needs: test
name: Build & Push Staging to container registries
if: github.ref == 'refs/heads/develop'
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/staging' || github.ref == 'refs/tags/v*'
name: Build & Push to container registries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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_owner }}/${{ env.IMAGE_NAME }}
${{ secrets.DOCKER_HUB_USERNAME }}/${{ env.IMAGE_NAME }}
ghcr.io/${{ github.repository }}
${{ secrets.DOCKER_HUB_USERNAME }}/${{ github.event.repository.name }}
tags: |
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 }}-{{date 'YYYYMMDD'}}-{{sha}}
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 Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Setup QEMU
uses: docker/setup-qemu-action@v3

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('package-lock.json', 'Dockerfile') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v2
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@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build image
uses: docker/build-push-action@v3
with:
context: .
file: 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

- name: Move cache
run: |
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/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
${{ secrets.DOCKER_HUB_USERNAME }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=production-latest,enable=${{ github.ref == 'refs/heads/master' }}
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 Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('package-lock.json', 'Dockerfile') }}
key: ${{ runner.os }}-buildx-build-${{ hashFiles('package-lock.json', 'Dockerfile') }}
restore-keys: |
${{ runner.os }}-buildx-
${{ runner.os }}-buildx-build-
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

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

- name: Build image
uses: docker/build-push-action@v3
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
provenance: false
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
notify-release:
needs: build
if: github.ref == 'refs/tags/v*'
name: Notify release
runs-on: ubuntu-latest
steps:
- name: Notify release
run: |
echo "Release ${{ github.sha }} is ready to be deployed to production"
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 @@ -231,7 +191,7 @@ jobs:
kubectl apply -f care-fe.yaml
deploy-production-manipur:
needs: build-production
needs: notify-release
name: Deploy to GKE Manipur
runs-on: ubuntu-latest
environment:
Expand Down Expand Up @@ -277,7 +237,7 @@ jobs:
kubectl apply -f care-fe.yaml
deploy-production-karnataka:
needs: build-production
needs: notify-release
name: Deploy to GKE Karnataka
runs-on: ubuntu-latest
environment:
Expand Down Expand Up @@ -323,7 +283,7 @@ jobs:
kubectl apply -f care-fe.yaml
deploy-production-sikkim:
needs: build-production
needs: notify-release
name: Deploy to GKE Sikkim
runs-on: ubuntu-latest
environment:
Expand Down Expand Up @@ -369,7 +329,7 @@ jobs:
kubectl apply -f care-fe.yaml
deploy-production-assam:
needs: build-production
needs: notify-release
name: Deploy to GKE Assam
runs-on: ubuntu-latest
environment:
Expand Down Expand Up @@ -415,7 +375,7 @@ jobs:
kubectl apply -f care-fe.yaml
deploy-production-nagaland:
needs: build-production
needs: notify-release
name: Deploy to GKE Nagaland
runs-on: ubuntu-latest
environment:
Expand Down Expand Up @@ -461,7 +421,7 @@ jobs:
kubectl apply -f care-fe.yaml
deploy-production-meghalaya:
needs: build-production
needs: notify-release
name: Deploy to GKE Meghalaya
runs-on: ubuntu-latest
environment:
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#build-stage
FROM node:18-buster-slim as build-stage
FROM --platform=$BUILDPLATFORM node:18-buster-slim as build-stage

WORKDIR /app

ENV NODE_OPTIONS="--max-old-space-size=4096"

RUN if [ "$(uname -m)" = "aarch64" ] || [ "$(uname -m)" = "arm64" ]; then apt-get update && apt-get install -y python3-dev make g++; fi

COPY package.json package-lock.json ./

RUN npm install --legacy-peer-deps
Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobject/Patient/PatientPrescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class PatientPrescription {
}

enterDosage(doseAmount: string) {
cy.get("#dosage").type(doseAmount, { force: true });
cy.get("#base_dosage").type(doseAmount, { force: true });
}

selectDosageFrequency(frequency: string) {
Expand Down
3 changes: 1 addition & 2 deletions src/Components/Facility/ConsultationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -761,10 +761,9 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => {
weight: Number(state.form.weight),
height: Number(state.form.height),
bed: bed && bed instanceof Array ? bed[0]?.id : bed?.id,
patient_no: state.form.patient_no || null,
};

if (state.form.patient_no) data["patient_no"] = state.form.patient_no;

const res = await dispatchAction(
id ? updateConsultation(id!, data) : createConsultation(data)
);
Expand Down
14 changes: 14 additions & 0 deletions src/Components/Form/FormFields/DosageFormField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { DOSAGE_UNITS } from "../../Medicine/models";
import NumericWithUnitsFormField from "./NumericWithUnitsFormField";
import { FormFieldBaseProps } from "./Utils";

type Props = FormFieldBaseProps<string> & {
placeholder?: string;
autoComplete?: string;
min?: string | number;
max?: string | number;
};

export default function DosageFormField(props: Props) {
return <NumericWithUnitsFormField {...props} units={DOSAGE_UNITS} />;
}
2 changes: 2 additions & 0 deletions src/Components/Form/FormFields/NumericWithUnitsFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default function NumericWithUnitsFormField(props: Props) {
autoComplete={props.autoComplete}
required={field.required}
value={numValue}
disabled={props.disabled}
onChange={(e) =>
field.handleChange(Number(e.target.value) + " " + unitValue)
}
Expand All @@ -48,6 +49,7 @@ export default function NumericWithUnitsFormField(props: Props) {
onChange={(e) =>
field.handleChange(numValue + " " + e.target.value)
}
disabled={props.disabled}
>
{props.units.map((unit) => (
<option key={unit}>{unit}</option>
Expand Down
Loading

0 comments on commit 6c2e225

Please sign in to comment.