Skip to content

Commit

Permalink
Merge pull request #42 from REAN-Foundation/release/uat-0.2.4
Browse files Browse the repository at this point in the history
Release/uat 0.2.4
  • Loading branch information
nisha-inflectionzone authored Jun 25, 2024
2 parents f653188 + 7d687cf commit 9038d2d
Show file tree
Hide file tree
Showing 954 changed files with 67,336 additions and 22,856 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
20 changes: 10 additions & 10 deletions .github/workflows/aha-prod-ci-cd.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ jobs:

Github-ECR-Tag-Check:
runs-on: ubuntu-latest

steps:
- name: check tag
uses: mukunku/tag-exists-action@v1.2.0
id: checkTag
with:
with:
tag: ${{ github.event.inputs.Tag_name }}

- name: Get release
if: ${{ steps.checkTag.outputs.exists == 'true' }}
id: result_release
Expand All @@ -38,27 +38,27 @@ jobs:
with:
tag: ${{ github.event.inputs.Tag_name }}
repo: REAN-Foundation/rean-admin-portal

- name: Configure AWS credentials
if: ${{ steps.checkTag.outputs.exists == 'true' }}
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Get ECR Image Tag
if: ${{ steps.checkTag.outputs.exists == 'true' }}
id: imageidvar
run: |
image_tag+=${{ steps.result_release.outputs.tag_name }} && image_tag+=_ && image_tag+=${{ steps.result_release.outputs.id }}
echo "imagetag_value=$(aws ecr-public describe-image-tags --repository-name rean-admin-portal --region us-east-1 --query "imageTagDetails[?imageTag=='$image_tag'].imageTag" --output text)" >> $GITHUB_OUTPUT
- name: ECR Image and Github Tag Check
run: |
if [[ ${{ steps.checkTag.outputs.exists }} == 'false' ]]; then exit 1; fi
if [[ -z "${{ steps.imageidvar.outputs.imagetag_value }}" ]]; then exit 1; fi
outputs:
release_name: ${{ steps.result_release.outputs.tag_name }}
release_id: ${{ steps.result_release.outputs.id }}
Expand All @@ -73,7 +73,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get release
id: result_release
uses: cardinalby/git-get-release-action@v1
Expand All @@ -82,7 +82,7 @@ jobs:
with:
tag: ${{ github.event.inputs.Tag_name }}
repo: REAN-Foundation/rean-admin-portal

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
Expand Down Expand Up @@ -140,4 +140,4 @@ jobs:
url: 'https://reanfoundation.duplocloud.net/subscriptions/${{ secrets.DUPLO_ID }}/UpdateEcsService'
method: 'POST'
data: '{"TaskDefinition":${{ steps.taskdefintionvar.outputs.task_definition_arn }},"Name": "${{ secrets.SERVICE_NAME }}","Replicas":1, "HealthCheckGracePeriodSeconds": 1200,"DnsPrfx": ""}'
bearerToken: ${{ secrets.DUPLOCLOUD_TOKEN }}
bearerToken: ${{ secrets.DUPLOCLOUD_TOKEN }}
86 changes: 86 additions & 0 deletions .github/workflows/deploy-ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Admin Portal Deployment

on:
push:
branches:
- develop-inflection

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install AWS CLI
run: |
sudo apt-get update
sudo apt-get install -y awscli
# - name: Install dependencies
# run: |
# pip install -r requirements.txt

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-south-1

- name: Login to Amazon ECR
run: aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin 443751504066.dkr.ecr.ap-south-1.amazonaws.com

- name: Copy env file
run: aws s3 cp s3://reancare-configs/rean-admin-portal/.env ./.env

- name: Build Docker image
run: |
docker build -t 443751504066.dkr.ecr.ap-south-1.amazonaws.com/rean-admin-portal:${{ github.sha }} .
docker push 443751504066.dkr.ecr.ap-south-1.amazonaws.com/rean-admin-portal:${{ github.sha }}
- name: SSH into EC2 instance
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
docker stop admin-portal || true
docker rm admin-portal || true
aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin 443751504066.dkr.ecr.ap-south-1.amazonaws.com
docker pull 443751504066.dkr.ecr.ap-south-1.amazonaws.com/rean-admin-portal:${{ github.sha }}
docker run -d -p 3000:3000 --network host --name admin-portal 443751504066.dkr.ecr.ap-south-1.amazonaws.com/rean-admin-portal:${{ github.sha }}
# - name: Get the latest revision of ECS task definition
# id: get-latest-revision
# run: |
# latest_revision=$(aws ecs describe-task-definition --task-definition document-processor --query 'taskDefinition.revision' --output text)
# echo "Latest revision: $latest_revision"
# echo "::set-output name=revision::$latest_revision"

# - name: Download task definition
# run: |
# aws ecs describe-task-definition --task-definition document-processor:${{ steps.get-latest-revision.outputs.revision }} \
# --query taskDefinition > task-definition.json
# cat task-definition.json

# - name: Update container image in task definition
# run: |
# jq '.containerDefinitions[0].image="443751504066.dkr.ecr.ap-south-1.amazonaws.com/document-processor:${{ github.sha }}"' task-definition.json > new-task-definition.json
# jq 'del(.taskDefinitionArn, .revision, .status, .registeredAt, .registeredBy, .requiresAttributes, .compatibilities)' new-task-definition.json > modified-task-definition.json
# mv modified-task-definition.json new-task-definition.json
# cat new-task-definition.json

# - name: Create a new revision of ECS task definition
# id: create-new-revision
# run: |
# new_revision=$(aws ecs register-task-definition --cli-input-json file://new-task-definition.json --query 'taskDefinition.revision' --output text)
# echo "New revision created: $new_revision"
# echo "::set-output name=new-revision::$new_revision"

# - name: Deploy to ECS
# run: |
# aws ecs update-service --cluster reancare-cluster --service document-processor --task-definition document-processor:${{ steps.create-new-revision.outputs.new-revision }} --force-new-deployment
3 changes: 2 additions & 1 deletion .github/workflows/dev-ci-cd.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Copy env file
run: aws s3 cp s3://${{ secrets.ENV_FILE_BUCKET_PATH }}/.env ./.env

Expand All @@ -74,6 +74,7 @@ jobs:
tags: ${{ steps.login-ecr.outputs.registry }}/rean-admin-portal:${{ steps.vars.outputs.branch }}_${{ steps.vars.outputs.sha_short }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache


- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
Expand Down
Empty file modified .github/workflows/pr-ci-cd.yml
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions .github/workflows/prod-ci-cd.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
branches: [main]

jobs:

Publish-Release:
runs-on: ubuntu-latest
steps:
Expand All @@ -25,11 +25,11 @@ jobs:
publish : true
env:
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }}

outputs:
release_id: ${{ steps.new_publish.outputs.id }}
release_name: ${{ steps.new_publish.outputs.tag_name }}


Deploy-ECS:
needs: Publish-Release
Expand Down
19 changes: 12 additions & 7 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"pluginSearchDirs": ["."],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
"useTabs": false,
"tabWidth": 4,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"endOfLine": "lf",
"bracketSpacing": true,
"printWidth": 120,
"singleAttributePerLine": true,
"plugins": ["prettier-plugin-svelte"],
"pluginSearchDirs": ["."],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch server",
"request": "launch",
"runtimeArgs": ["run-script", "dev"],
"runtimeExecutable": "npm",
"skipFiles": ["<node_internals>/**"],
"type": "node",
"console": "integratedTerminal"
},

{
"type": "chrome",
"request": "launch",
"name": "Launch Edge",
"url": "http://localhost:5173",
"webRoot": "${workspaceFolder}"
}
],
"compounds": [
{
"name": "Both",
"configurations": ["Launch server", "Launch Edge"]
}
]
}
32 changes: 19 additions & 13 deletions Dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18.12.0-alpine3.16 AS builder
FROM node:18.20-alpine3.19 AS builder

WORKDIR /app
COPY . .
Expand All @@ -9,30 +9,36 @@ RUN npm run build

#######################################

FROM node:18.12.0-alpine3.16
FROM node:18.20-alpine3.19

RUN apk add bash
RUN apk add --no-cache \
python3 \
&& rm -rf /var/cache/apk/*
RUN apk add --update alpine-sdk
RUN apk add chromium \
harfbuzz
# RUN apk add chromium \
# harfbuzz
# RUN apk --no-cache add aws-cli

RUN apk update
RUN apk upgrade

WORKDIR /app
RUN rm -rf ./*
# RUN rm -rf ./*

COPY --from=builder ./app/package*.json ./
COPY --from=builder ./app/build .
COPY --from=builder ./app/ ./
# COPY --from=builder ./app/build .
# COPY --from=builder ./app/entrypoint.sh ./

RUN npm install --production

COPY . /app

#CMD ["node", "index.js"]
RUN npm install

# # COPY . /app
##
##
# CMD ["npm", "run", "dev", "--", "--host", "--port", "3000"]
ARG ORIGIN
ENV ORIGIN=${ORIGIN}
RUN chmod +x /app/entrypoint.sh
ENTRYPOINT ["/bin/bash", "-c", "/app/entrypoint.sh"]
ENTRYPOINT ["/bin/bash", "-c", "/app/entrypoint.sh"]

#CMD ["node", "build/index.js"]
2 changes: 2 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { defineConfig } from "cypress";

export default defineConfig({

e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here

},
},
});
28 changes: 14 additions & 14 deletions cypress/e2e/02-drug/01-table.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('test', () => {
cy.contains('Clinical').click()
cy.wait(2000)
// eslint-disable-next-line no-useless-escape
cy.contains('Drugs').click()
cy.contains('Drug').click()
cy.wait(2000)
cy.contains('→').scrollIntoView()
cy.wait(2000)
Expand All @@ -31,15 +31,17 @@ describe('test', () => {
cy.wait(2000)
cy.get('select').select('10')
cy.wait(2000)
cy.get(':nth-child(1) > .relative > .input').scrollIntoView()
cy.contains('Drugs').scrollIntoView()
cy.wait(2000)
cy.get(':nth-child(2) > :nth-child(6) > a > .svelte-fa').click()
cy.get(':nth-child(2) > :nth-child(6) > .btn > .text-lg').click()
cy.wait(2000)
cy.get('input[name=drugName]').clear()
cy.wait(2000)
cy.get('input[name=drugName]').type('Dndxeame')
cy.wait(2000)
cy.get('select[name=genericName]').select('Paracetamol')
cy.get('input[name=genericName]').clear()
cy.wait(2000)
cy.get('input[name=genericName]').type('Paracetamol')
cy.wait(2000)
cy.get('input[name=ingredients]').clear()
cy.wait(2000)
Expand All @@ -61,19 +63,17 @@ describe('test', () => {
cy.wait(2000)
cy.get('button[type=submit]').click()
cy.wait(2000)
cy.get(':nth-child(1) > .text-primary-primary-500').click()
cy.wait(2000)
cy.get(':nth-child(1) > .relative > .input').type('Dndxeame')
cy.wait(2000)
cy.get('.lg\\:w-20').click()
cy.wait(2000)
cy.get(':nth-child(1) > .relative > .input').clear()
cy.contains('Drugs').click()
cy.wait(2000)
cy.get(':nth-child(2) > .relative > .input').type('Paracetamol')
cy.get('input[name=drugName]').type('Dndxeame')
cy.wait(5000)
cy.get('input[name=drugName]').clear()
cy.wait(2000)
cy.get('.lg\\:w-20').click()
cy.get('input[name=genericName]').type('Paracetamol')
cy.wait(5000)
cy.get('input[name=genericName]').clear()
cy.wait(2000)
cy.get(':nth-child(2) > .relative > .input').clear()

})
});

Expand Down
Loading

0 comments on commit 9038d2d

Please sign in to comment.