From 510f525a1dd10f7dc37ee520c6b88cdf53a71df1 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Mon, 4 Nov 2024 11:29:48 +0530 Subject: [PATCH 01/21] fixed resource utilisation --- .github/workflows/cypress.yaml | 136 ++++++++++++++++----------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 0f588568bbc..768262d2063 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -1,8 +1,6 @@ name: Cypress Tests on: - schedule: - - cron: "30 22 * * *" pull_request: branches: - develop @@ -10,22 +8,18 @@ on: workflow_dispatch: jobs: - cypress-run: - permissions: write-all - if: github.repository == 'ohcnetwork/care_fe' + # Setup job to prepare backend and frontend + setup: + name: Setup Backend and Frontend runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - containers: [1, 2, 3, 4, 5, 6, 7, 8] - env: - REACT_CARE_API_URL: http://localhost:9000 + outputs: + backend_branch: ${{ steps.set_backend_branch.outputs.branch }} steps: - - name: Checkout 📥 + - name: Checkout Repository uses: actions/checkout@v3 - - name: Set backend branch - id: backend-branch + - name: Set Backend Branch + id: set_backend_branch run: | if [[ '${{ github.event.pull_request.base.ref }}' == 'staging' ]]; then echo "branch=staging" >> $GITHUB_OUTPUT @@ -33,14 +27,14 @@ jobs: echo "branch=develop" >> $GITHUB_OUTPUT fi - - name: Checkout care 📥 + - name: Checkout Backend Repository uses: actions/checkout@v3 with: repository: ohcnetwork/care path: care - ref: ${{ steps.backend-branch.outputs.branch }} + ref: ${{ steps.set_backend_branch.outputs.branch }} - - name: Start care docker containers 🐳 + - name: Start Backend Docker Containers run: | cd care echo DISABLE_RATELIMIT=True >> docker/.prebuilt.env @@ -52,7 +46,7 @@ jobs: env: JWKS_BASE64: ${{ secrets.JWKS_BASE64 }} - - name: Wait for care to be up ♻ + - name: Wait for Backend to be Ready uses: nick-fields/retry@v2 with: timeout_minutes: 1 @@ -60,80 +54,86 @@ jobs: command: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000 on_retry_command: sleep 5 - - name: Determine PR Origin - id: pr_origin - run: echo "::set-output name=is_forked::$( echo ${{ github.event.pull_request.head.repo.fork }})" - - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: "20" - - name: Install dependencies 📦 + - name: Install Dependencies run: npm run install-all - - name: Build ⚙️ + - name: Build Frontend run: npm run build - - name: Install Specific Chrome Version - run: | - sudo apt-get install -y wget - sudo wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb - sudo apt-get install ./google-chrome-stable_current_amd64.deb + - name: Cache Cypress Binary and Dependencies + uses: actions/cache@v3 + with: + path: | + ~/.cache/Cypress + node_modules + key: ${{ runner.os }}-build-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build- + + - name: Start Frontend Server + run: npx vite preview --host & - - name: Cypress run for Non-Forked PRs 🥬 - if: steps.pr_origin.outputs.is_forked == 'false' - uses: cypress-io/github-action@v5 + # Parallel Cypress test jobs + e2e-tests: + name: Cypress Parallel Tests + needs: setup + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + job_index: [0, 1, 2, 3] # Adjust based on the number of parallel jobs needed + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Restore Cypress and Node Modules Cache + uses: actions/cache@v3 with: - env: SKIP_PREFLIGHT_CHECK=true - install: false - start: "npx vite preview --host" - wait-on: "http://localhost:4000" - wait-on-timeout: 300 - browser: chrome - record: true - parallel: true - group: "UI-Chrome" + path: | + ~/.cache/Cypress + node_modules + key: ${{ runner.os }}-build-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build- + + - name: Cypress Run for Non-Forked PRs + if: steps.setup.outputs.is_forked == 'false' + run: | + npx cypress-split --ci-build-id ${{ github.run_id }} --record --parallel \ + --group "UI-Parallel" --spec "cypress/e2e/**/*.cy.ts" --env JOB_INDEX=${{ matrix.job_index }} env: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NODE_OPTIONS: --max_old_space_size=4096 - COMMIT_INFO_MESSAGE: ${{github.event.pull_request.title}} - COMMIT_INFO_SHA: ${{github.event.pull_request.head.sha}} + COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} + COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }} - - name: Cypress run for Forked PRs 🥬 - if: steps.pr_origin.outputs.is_forked == 'true' - uses: cypress-io/github-action@v5 - with: - env: SKIP_PREFLIGHT_CHECK=true - install: false - start: "npx vite preview --host" - wait-on: "http://localhost:4000" - wait-on-timeout: 300 - browser: chrome - record: true - parallel: true - group: "UI-Chrome" + - name: Cypress Run for Forked PRs + if: steps.setup.outputs.is_forked == 'true' + run: | + npx cypress-split --ci-build-id ${{ github.run_id }} --group "UI-Parallel" \ + --spec "cypress/e2e/**/*.cy.ts" --env JOB_INDEX=${{ matrix.job_index }} env: CYPRESS_SPLIT_TESTS: "true" CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NODE_OPTIONS: --max_old_space_size=4096 - COMMIT_INFO_MESSAGE: ${{github.event.pull_request.title}} - COMMIT_INFO_SHA: ${{github.event.pull_request.head.sha}} - SPLIT: ${{ strategy.job-total }} - SPLIT_INDEX: ${{ strategy.job-index }} + COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} + COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }} - - name: Upload cypress screenshots on failure 📸 + - name: Upload Cypress Screenshots on Failure uses: actions/upload-artifact@v3 if: failure() with: - name: cypress-screenshots + name: cypress-screenshots-${{ matrix.job_index }} path: cypress/screenshots - - name: Upload cypress videos 📹 + - name: Upload Cypress Videos uses: actions/upload-artifact@v3 - if: steps.pr_origin.outputs.is_forked == 'true' + if: failure() with: - name: cypress-videos - path: cypress/videos + name: cypress-videos-${{ matrix.job_index }} + path: cypress/videos \ No newline at end of file From 95e28164a7e658aae9da0d85696d3a3f4b155897 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Mon, 4 Nov 2024 11:45:23 +0530 Subject: [PATCH 02/21] removed the forked and non-forked repo check --- .github/workflows/cypress.yaml | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 768262d2063..75f7c0af0bd 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -1,6 +1,8 @@ name: Cypress Tests on: + schedule: + - cron: "30 22 * * *" pull_request: branches: - develop @@ -8,18 +10,16 @@ on: workflow_dispatch: jobs: - # Setup job to prepare backend and frontend + # Initial setup job to run backend and frontend setup setup: name: Setup Backend and Frontend runs-on: ubuntu-latest - outputs: - backend_branch: ${{ steps.set_backend_branch.outputs.branch }} steps: - name: Checkout Repository uses: actions/checkout@v3 - name: Set Backend Branch - id: set_backend_branch + id: backend-branch run: | if [[ '${{ github.event.pull_request.base.ref }}' == 'staging' ]]; then echo "branch=staging" >> $GITHUB_OUTPUT @@ -32,7 +32,7 @@ jobs: with: repository: ohcnetwork/care path: care - ref: ${{ steps.set_backend_branch.outputs.branch }} + ref: ${{ steps.backend-branch.outputs.branch }} - name: Start Backend Docker Containers run: | @@ -71,9 +71,9 @@ jobs: path: | ~/.cache/Cypress node_modules - key: ${{ runner.os }}-build-${{ hashFiles('package-lock.json') }} + key: ${{ runner.os }}-cypress-${{ hashFiles('package-lock.json') }} restore-keys: | - ${{ runner.os }}-build- + ${{ runner.os }}-cypress- - name: Start Frontend Server run: npx vite preview --host & @@ -97,12 +97,11 @@ jobs: path: | ~/.cache/Cypress node_modules - key: ${{ runner.os }}-build-${{ hashFiles('package-lock.json') }} + key: ${{ runner.os }}-cypress-${{ hashFiles('package-lock.json') }} restore-keys: | - ${{ runner.os }}-build- + ${{ runner.os }}-cypress- - - name: Cypress Run for Non-Forked PRs - if: steps.setup.outputs.is_forked == 'false' + - name: Cypress Run in Parallel run: | npx cypress-split --ci-build-id ${{ github.run_id }} --record --parallel \ --group "UI-Parallel" --spec "cypress/e2e/**/*.cy.ts" --env JOB_INDEX=${{ matrix.job_index }} @@ -112,18 +111,6 @@ jobs: COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }} - - name: Cypress Run for Forked PRs - if: steps.setup.outputs.is_forked == 'true' - run: | - npx cypress-split --ci-build-id ${{ github.run_id }} --group "UI-Parallel" \ - --spec "cypress/e2e/**/*.cy.ts" --env JOB_INDEX=${{ matrix.job_index }} - env: - CYPRESS_SPLIT_TESTS: "true" - CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} - COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }} - - name: Upload Cypress Screenshots on Failure uses: actions/upload-artifact@v3 if: failure() From 675ddd380d18f6471d6bcd79235a03d7e2725554 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Mon, 4 Nov 2024 11:57:41 +0530 Subject: [PATCH 03/21] reinstall npm --- .github/workflows/cypress.yaml | 83 ++++++---------------------------- 1 file changed, 15 insertions(+), 68 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 75f7c0af0bd..6ea029b3305 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -10,9 +10,9 @@ on: workflow_dispatch: jobs: - # Initial setup job to run backend and frontend setup - setup: - name: Setup Backend and Frontend + # Setup job to start the backend + setup-backend: + name: Setup Backend runs-on: ubuntu-latest steps: - name: Checkout Repository @@ -54,73 +54,20 @@ jobs: command: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000 on_retry_command: sleep 5 - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: "20" - - - name: Install Dependencies - run: npm run install-all - - - name: Build Frontend - run: npm run build - - - name: Cache Cypress Binary and Dependencies - uses: actions/cache@v3 - with: - path: | - ~/.cache/Cypress - node_modules - key: ${{ runner.os }}-cypress-${{ hashFiles('package-lock.json') }} - restore-keys: | - ${{ runner.os }}-cypress- - - name: Start Frontend Server run: npx vite preview --host & - # Parallel Cypress test jobs - e2e-tests: + # Parallel Cypress Test Job Using Reusable Workflow + cypress-tests: name: Cypress Parallel Tests - needs: setup - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - job_index: [0, 1, 2, 3] # Adjust based on the number of parallel jobs needed + needs: setup-backend + uses: bahmutov/cypress-workflows/.github/workflows/split.yml@v1 + with: + nE2E: 4 # Number of parallel containers for running E2E specs + start: "http://localhost:4000" + config: "cypress/e2e/**/*.cy.ts" + secrets: + CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - - name: Restore Cypress and Node Modules Cache - uses: actions/cache@v3 - with: - path: | - ~/.cache/Cypress - node_modules - key: ${{ runner.os }}-cypress-${{ hashFiles('package-lock.json') }} - restore-keys: | - ${{ runner.os }}-cypress- - - - name: Cypress Run in Parallel - run: | - npx cypress-split --ci-build-id ${{ github.run_id }} --record --parallel \ - --group "UI-Parallel" --spec "cypress/e2e/**/*.cy.ts" --env JOB_INDEX=${{ matrix.job_index }} - env: - CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} - COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }} - - - name: Upload Cypress Screenshots on Failure - uses: actions/upload-artifact@v3 - if: failure() - with: - name: cypress-screenshots-${{ matrix.job_index }} - path: cypress/screenshots - - - name: Upload Cypress Videos - uses: actions/upload-artifact@v3 - if: failure() - with: - name: cypress-videos-${{ matrix.job_index }} - path: cypress/videos \ No newline at end of file + - name: Install Cypress and Dependencies + run: npm ci # Ensures all dependencies in package-lock.json are installed \ No newline at end of file From 8bc2ddc36a53a9b60e261cb021136b7d49198458 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Mon, 4 Nov 2024 12:01:18 +0530 Subject: [PATCH 04/21] reinstall frontend --- .github/workflows/cypress.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 6ea029b3305..4ea43c82ad9 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -1,8 +1,6 @@ name: Cypress Tests on: - schedule: - - cron: "30 22 * * *" pull_request: branches: - develop From e7328285cd51e3f0a7b485f53b7f89131872acbe Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Mon, 4 Nov 2024 12:37:33 +0530 Subject: [PATCH 05/21] cache docker only --- .github/workflows/cypress.yaml | 108 +++++++++++++++++++++++++-------- 1 file changed, 83 insertions(+), 25 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 4ea43c82ad9..f1e9eca7d7c 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -8,10 +8,12 @@ on: workflow_dispatch: jobs: - # Setup job to start the backend + # Setup job to build and cache the Docker image for the backend setup-backend: - name: Setup Backend + name: Build and Cache Backend Docker Image runs-on: ubuntu-latest + outputs: + backend_branch: ${{ steps.backend-branch.outputs.branch }} steps: - name: Checkout Repository uses: actions/checkout@v3 @@ -32,40 +34,96 @@ jobs: path: care ref: ${{ steps.backend-branch.outputs.branch }} - - name: Start Backend Docker Containers + - name: Build Backend Docker Image run: | cd care - echo DISABLE_RATELIMIT=True >> docker/.prebuilt.env - echo "CORS_ALLOWED_ORIGINS=\"[\\\"http://localhost:4000\\\"]\"" >> docker/.prebuilt.env - echo JWKS_BASE64=\"$(cat ../.github/runner-files/jwks.b64.txt)\" >> docker/.prebuilt.env - make docker_config_file=docker-compose.pre-built.yaml up - make docker_config_file=docker-compose.pre-built.yaml load-dummy-data + docker build -t care-backend:latest -f docker/Dockerfile . cd .. + + - name: Save Docker Image as Tarball + run: | + docker save care-backend:latest -o care-backend.tar + + - name: Cache Docker Image Tarball + uses: actions/cache@v3 + with: + path: care-backend.tar + key: ${{ runner.os }}-care-backend-image-${{ github.run_id }} + restore-keys: | + ${{ runner.os }}-care-backend-image- + + # Parallel Cypress test jobs with Docker container setup in each job + e2e-tests: + name: Cypress Parallel Tests with Cached Docker Image + needs: setup-backend + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + job_index: [0, 1, 2, 3] # Adjust based on the number of parallel jobs needed + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Restore Docker Image Tarball from Cache + uses: actions/cache@v3 + with: + path: care-backend.tar + key: ${{ runner.os }}-care-backend-image-${{ github.run_id }} + restore-keys: | + ${{ runner.os }}-care-backend-image- + + - name: Load Docker Image + run: docker load -i care-backend.tar + + - name: Start Backend Docker Container + run: | + docker run -d --name care-backend -p 9000:9000 care-backend:latest env: JWKS_BASE64: ${{ secrets.JWKS_BASE64 }} - name: Wait for Backend to be Ready uses: nick-fields/retry@v2 with: - timeout_minutes: 1 - max_attempts: 5 + timeout_minutes: 2 + max_attempts: 10 command: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000 on_retry_command: sleep 5 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Install Frontend Dependencies + run: npm ci + - name: Start Frontend Server - run: npx vite preview --host & + run: | + npx vite preview --host & + env: + NODE_OPTIONS: --max_old_space_size=4096 - # Parallel Cypress Test Job Using Reusable Workflow - cypress-tests: - name: Cypress Parallel Tests - needs: setup-backend - uses: bahmutov/cypress-workflows/.github/workflows/split.yml@v1 - with: - nE2E: 4 # Number of parallel containers for running E2E specs - start: "http://localhost:4000" - config: "cypress/e2e/**/*.cy.ts" - secrets: - CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - steps: - - name: Install Cypress and Dependencies - run: npm ci # Ensures all dependencies in package-lock.json are installed \ No newline at end of file + - name: Run Cypress in Parallel + run: | + npx cypress-split --ci-build-id ${{ github.run_id }} --record --parallel \ + --group "UI-Parallel" --spec "cypress/e2e/**/*.cy.ts" --env JOB_INDEX=${{ matrix.job_index }} + env: + CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} + COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }} + + - name: Upload Cypress Screenshots on Failure + uses: actions/upload-artifact@v3 + if: failure() + with: + name: cypress-screenshots-${{ matrix.job_index }} + path: cypress/screenshots + + - name: Upload Cypress Videos + uses: actions/upload-artifact@v3 + if: failure() + with: + name: cypress-videos-${{ matrix.job_index }} + path: cypress/videos From f0442a4065335c8e709ef5f2ea17b9228dfebb2e Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Mon, 4 Nov 2024 12:41:53 +0530 Subject: [PATCH 06/21] cache docker only --- .github/workflows/cypress.yaml | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index f1e9eca7d7c..85989c8e549 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -1,6 +1,8 @@ name: Cypress Tests on: + schedule: + - cron: "30 22 * * *" pull_request: branches: - develop @@ -12,27 +14,21 @@ jobs: setup-backend: name: Build and Cache Backend Docker Image runs-on: ubuntu-latest - outputs: - backend_branch: ${{ steps.backend-branch.outputs.branch }} steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - - name: Set Backend Branch - id: backend-branch - run: | - if [[ '${{ github.event.pull_request.base.ref }}' == 'staging' ]]; then - echo "branch=staging" >> $GITHUB_OUTPUT - else - echo "branch=develop" >> $GITHUB_OUTPUT - fi - - name: Checkout Backend Repository uses: actions/checkout@v3 with: - repository: ohcnetwork/care + repository: ohcnetwork/care # Replace with your backend repo path: care - ref: ${{ steps.backend-branch.outputs.branch }} + ref: ${{ github.event.pull_request.base.ref }} + + - name: Set Backend Environment Variables + run: | + echo DISABLE_RATELIMIT=True >> care/docker/.prebuilt.env + echo "CORS_ALLOWED_ORIGINS=\"[\\\"http://localhost:4000\\\"]\"" >> care/docker/.prebuilt.env + echo JWKS_BASE64=\"$(cat .github/runner-files/jwks.b64.txt)\" >> care/docker/.prebuilt.env + env: + JWKS_BASE64: ${{ secrets.JWKS_BASE64 }} - name: Build Backend Docker Image run: | @@ -62,7 +58,7 @@ jobs: matrix: job_index: [0, 1, 2, 3] # Adjust based on the number of parallel jobs needed steps: - - name: Checkout Repository + - name: Checkout Frontend Repository uses: actions/checkout@v3 - name: Restore Docker Image Tarball from Cache From 13e68ce956f28c5e352197132e83649ad24f5f24 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Mon, 4 Nov 2024 12:51:26 +0530 Subject: [PATCH 07/21] cache docker only --- .github/workflows/cypress.yaml | 89 +++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 28 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 85989c8e549..82388caeab8 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -1,8 +1,6 @@ name: Cypress Tests on: - schedule: - - cron: "30 22 * * *" pull_request: branches: - develop @@ -10,18 +8,35 @@ on: workflow_dispatch: jobs: - # Setup job to build and cache the Docker image for the backend - setup-backend: - name: Build and Cache Backend Docker Image + # Setup job to build, cache the Docker image for the backend, and prepare frontend dependencies + setup-environment: + name: Build and Cache Frontend & Backend runs-on: ubuntu-latest + outputs: + backend_branch: ${{ steps.backend-branch.outputs.branch }} steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + # Set backend branch based on target branch of the PR + - name: Set Backend Branch + id: backend-branch + run: | + if [[ '${{ github.event.pull_request.base.ref }}' == 'staging' ]]; then + echo "branch=staging" >> $GITHUB_OUTPUT + else + echo "branch=develop" >> $GITHUB_OUTPUT + fi + + # Checkout backend repository with the specified branch - name: Checkout Backend Repository uses: actions/checkout@v3 with: - repository: ohcnetwork/care # Replace with your backend repo + repository: ohcnetwork/care path: care - ref: ${{ github.event.pull_request.base.ref }} + ref: ${{ steps.backend-branch.outputs.branch }} + # Set Backend Environment Variables - name: Set Backend Environment Variables run: | echo DISABLE_RATELIMIT=True >> care/docker/.prebuilt.env @@ -30,55 +45,73 @@ jobs: env: JWKS_BASE64: ${{ secrets.JWKS_BASE64 }} + # Build Backend Docker Image - name: Build Backend Docker Image run: | cd care docker build -t care-backend:latest -f docker/Dockerfile . cd .. - - name: Save Docker Image as Tarball + # Save Docker Image as Tarball for Caching + - name: Save Backend Docker Image as Tarball + run: docker save care-backend:latest -o care-backend.tar + + # Install Frontend Dependencies and Build + - name: Install Frontend Dependencies and Build run: | - docker save care-backend:latest -o care-backend.tar + npm install + npm run build - - name: Cache Docker Image Tarball + # Cache Backend Docker Image and Frontend Build + - name: Cache Backend Docker Image and Frontend Build uses: actions/cache@v3 with: - path: care-backend.tar - key: ${{ runner.os }}-care-backend-image-${{ github.run_id }} + path: | + care-backend.tar + node_modules + dist # Assuming frontend build output is in `dist` folder + key: ${{ runner.os }}-frontend-backend-cache-${{ github.run_id }} restore-keys: | - ${{ runner.os }}-care-backend-image- + ${{ runner.os }}-frontend-backend-cache- # Parallel Cypress test jobs with Docker container setup in each job e2e-tests: - name: Cypress Parallel Tests with Cached Docker Image - needs: setup-backend + name: Cypress Parallel Tests with Cached Environment + needs: setup-environment runs-on: ubuntu-latest strategy: fail-fast: false matrix: job_index: [0, 1, 2, 3] # Adjust based on the number of parallel jobs needed steps: - - name: Checkout Frontend Repository + - name: Checkout Repository uses: actions/checkout@v3 - - name: Restore Docker Image Tarball from Cache + # Restore Cached Backend Docker Image and Frontend Build + - name: Restore Backend Docker Image and Frontend Build Cache uses: actions/cache@v3 with: - path: care-backend.tar - key: ${{ runner.os }}-care-backend-image-${{ github.run_id }} + path: | + care-backend.tar + node_modules + dist + key: ${{ runner.os }}-frontend-backend-cache-${{ github.run_id }} restore-keys: | - ${{ runner.os }}-care-backend-image- + ${{ runner.os }}-frontend-backend-cache- - - name: Load Docker Image + # Load Docker Image from Tarball + - name: Load Backend Docker Image run: docker load -i care-backend.tar + # Start Backend Docker Container - name: Start Backend Docker Container run: | docker run -d --name care-backend -p 9000:9000 care-backend:latest env: JWKS_BASE64: ${{ secrets.JWKS_BASE64 }} - - name: Wait for Backend to be Ready + # Wait for Backend to be Ready + - name: Wait for Backend Health Check uses: nick-fields/retry@v2 with: timeout_minutes: 2 @@ -86,20 +119,18 @@ jobs: command: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000 on_retry_command: sleep 5 - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: "20" - + # Install Frontend Dependencies (to ensure they are intact) - name: Install Frontend Dependencies - run: npm ci + run: npm ci # `npm ci` is faster and ensures a clean install + # Start Frontend Server - name: Start Frontend Server run: | npx vite preview --host & env: NODE_OPTIONS: --max_old_space_size=4096 + # Run Cypress in Parallel - name: Run Cypress in Parallel run: | npx cypress-split --ci-build-id ${{ github.run_id }} --record --parallel \ @@ -110,6 +141,7 @@ jobs: COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }} + # Upload Cypress Screenshots on Failure - name: Upload Cypress Screenshots on Failure uses: actions/upload-artifact@v3 if: failure() @@ -117,6 +149,7 @@ jobs: name: cypress-screenshots-${{ matrix.job_index }} path: cypress/screenshots + # Upload Cypress Videos - name: Upload Cypress Videos uses: actions/upload-artifact@v3 if: failure() From 72fa809ec474b7b547637377a62c64c62bba6f61 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 6 Nov 2024 02:17:03 +0530 Subject: [PATCH 08/21] trying cache and multiple job approach --- .github/workflows/cypress.yaml | 229 +++++++++++------- .../patient_spec/PatientInvestigation.cy.ts | 0 package-lock.json | 16 ++ 3 files changed, 158 insertions(+), 87 deletions(-) create mode 100644 cypress/e2e/patient_spec/PatientInvestigation.cy.ts diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 82388caeab8..5cbf7313808 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -8,18 +8,21 @@ on: workflow_dispatch: jobs: - # Setup job to build, cache the Docker image for the backend, and prepare frontend dependencies - setup-environment: - name: Build and Cache Frontend & Backend + cypress-run: + permissions: write-all + if: github.repository == 'ohcnetwork/care_fe' runs-on: ubuntu-latest - outputs: - backend_branch: ${{ steps.backend-branch.outputs.branch }} + strategy: + fail-fast: false + matrix: + containers: [1, 2, 3, 4] + env: + REACT_CARE_API_URL: http://localhost:9000 steps: - - name: Checkout Repository + - name: Checkout 📥 uses: actions/checkout@v3 - # Set backend branch based on target branch of the PR - - name: Set Backend Branch + - name: Set backend branch id: backend-branch run: | if [[ '${{ github.event.pull_request.base.ref }}' == 'staging' ]]; then @@ -28,131 +31,183 @@ jobs: echo "branch=develop" >> $GITHUB_OUTPUT fi - # Checkout backend repository with the specified branch - - name: Checkout Backend Repository + - name: Checkout care backend 📥 uses: actions/checkout@v3 with: repository: ohcnetwork/care path: care ref: ${{ steps.backend-branch.outputs.branch }} - # Set Backend Environment Variables - - name: Set Backend Environment Variables + - name: Start care backend docker containers 🐳 run: | - echo DISABLE_RATELIMIT=True >> care/docker/.prebuilt.env - echo "CORS_ALLOWED_ORIGINS=\"[\\\"http://localhost:4000\\\"]\"" >> care/docker/.prebuilt.env - echo JWKS_BASE64=\"$(cat .github/runner-files/jwks.b64.txt)\" >> care/docker/.prebuilt.env + cd care + echo DISABLE_RATELIMIT=True >> docker/.prebuilt.env + echo "CORS_ALLOWED_ORIGINS=\"[\\\"http://localhost:4000\\\"]\"" >> docker/.prebuilt.env + echo JWKS_BASE64=\"$(cat ../.github/runner-files/jwks.b64.txt)\" >> docker/.prebuilt.env + make docker_config_file=docker-compose.pre-built.yaml up + make docker_config_file=docker-compose.pre-built.yaml load-dummy-data + cd .. env: JWKS_BASE64: ${{ secrets.JWKS_BASE64 }} - # Build Backend Docker Image - - name: Build Backend Docker Image + - name: Wait for care backend to be up ♻ + uses: nick-fields/retry@v2 + with: + timeout_minutes: 1 + max_attempts: 5 + command: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000 + on_retry_command: sleep 5 + + - name: Cache Backend Docker Image 📦 run: | - cd care - docker build -t care-backend:latest -f docker/Dockerfile . - cd .. + docker save care_backend -o backend-cache.tar + - name: Upload Backend Cache Artifact + uses: actions/upload-artifact@v3 + with: + name: backend-docker-cache + path: backend-cache.tar + + - name: Determine Frontend PR Origin + id: pr_origin + run: echo "::set-output name=is_forked::$( echo ${{ github.event.pull_request.head.repo.fork }})" + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Install frontend dependencies 📦 + run: npm run install-all - # Save Docker Image as Tarball for Caching - - name: Save Backend Docker Image as Tarball - run: docker save care-backend:latest -o care-backend.tar + - name: Build the frontend after downloading all dependencies ⚙️ + run: npm run build - # Install Frontend Dependencies and Build - - name: Install Frontend Dependencies and Build + - name: Cache Frontend Build 📦 run: | - npm install - npm run build + tar -cvf frontend-build-cache.tar ./build + - name: Upload Frontend Cache Artifact + uses: actions/upload-artifact@v3 + with: + name: frontend-build-cache + path: frontend-build-cache.tar - # Cache Backend Docker Image and Frontend Build - - name: Cache Backend Docker Image and Frontend Build - uses: actions/cache@v3 - with: - path: | - care-backend.tar - node_modules - dist # Assuming frontend build output is in `dist` folder - key: ${{ runner.os }}-frontend-backend-cache-${{ github.run_id }} - restore-keys: | - ${{ runner.os }}-frontend-backend-cache- - - # Parallel Cypress test jobs with Docker container setup in each job - e2e-tests: - name: Cypress Parallel Tests with Cached Environment - needs: setup-environment +jobs: + cypress-run: + needs: build-and-cache # Ensure this job runs after the build and cache job runs-on: ubuntu-latest strategy: fail-fast: false matrix: - job_index: [0, 1, 2, 3] # Adjust based on the number of parallel jobs needed + containers: [1, 2, 3, 4] + env: + REACT_CARE_API_URL: http://localhost:9000 steps: - - name: Checkout Repository + - name: Checkout 📥 uses: actions/checkout@v3 - # Restore Cached Backend Docker Image and Frontend Build - - name: Restore Backend Docker Image and Frontend Build Cache - uses: actions/cache@v3 + # Download the cached backend Docker image + - name: Download Backend Cache + uses: actions/download-artifact@v3 with: - path: | - care-backend.tar - node_modules - dist - key: ${{ runner.os }}-frontend-backend-cache-${{ github.run_id }} - restore-keys: | - ${{ runner.os }}-frontend-backend-cache- - - # Load Docker Image from Tarball - - name: Load Backend Docker Image - run: docker load -i care-backend.tar - - # Start Backend Docker Container - - name: Start Backend Docker Container + name: backend-docker-cache + path: . + + # Load the cached Docker image + - name: Load Backend Docker Image 🐳 + run: docker load -i backend-cache.tar + + # Start backend Docker containers + - name: Start care backend docker containers 🐳 run: | - docker run -d --name care-backend -p 9000:9000 care-backend:latest - env: - JWKS_BASE64: ${{ secrets.JWKS_BASE64 }} + cd care + echo DISABLE_RATELIMIT=True >> docker/.prebuilt.env + echo "CORS_ALLOWED_ORIGINS=\"[\\\"http://localhost:4000\\\"]\"" >> docker/.prebuilt.env + echo JWKS_BASE64=\"$(cat ../.github/runner-files/jwks.b64.txt)\" >> docker/.prebuilt.env + make docker_config_file=docker-compose.pre-built.yaml up + cd .. - # Wait for Backend to be Ready - - name: Wait for Backend Health Check + # Check backend health + - name: Wait for backend health check ♻ uses: nick-fields/retry@v2 with: - timeout_minutes: 2 - max_attempts: 10 + timeout_minutes: 1 + max_attempts: 5 command: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000 on_retry_command: sleep 5 - # Install Frontend Dependencies (to ensure they are intact) - - name: Install Frontend Dependencies - run: npm ci # `npm ci` is faster and ensures a clean install + # Download the cached frontend build + - name: Download Frontend Cache + uses: actions/download-artifact@v3 + with: + name: frontend-build-cache + path: . + + # Extract frontend cache and install dependencies + - name: Extract and Install Frontend Dependencies 📦 + run: | + tar -xvf frontend-build-cache.tar + npm install - # Start Frontend Server - - name: Start Frontend Server + # Install Chrome + - name: Install Specific Chrome Version run: | - npx vite preview --host & + sudo apt-get install -y wget + sudo wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb + sudo apt-get install ./google-chrome-stable_current_amd64.deb + + # Run Cypress tests for Non-Forked PRs + - name: Cypress run for Non-Forked PRs 🥬 + if: steps.pr_origin.outputs.is_forked == 'false' + uses: cypress-io/github-action@v5 + with: + start: "npx vite preview --host" + wait-on: "http://localhost:4000" + wait-on-timeout: 300 + browser: chrome + record: true + parallel: true + group: "UI-Chrome" env: + CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NODE_OPTIONS: --max_old_space_size=4096 + COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} + COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }} - # Run Cypress in Parallel - - name: Run Cypress in Parallel - run: | - npx cypress-split --ci-build-id ${{ github.run_id }} --record --parallel \ - --group "UI-Parallel" --spec "cypress/e2e/**/*.cy.ts" --env JOB_INDEX=${{ matrix.job_index }} + # Run Cypress tests for Forked PRs + - name: Cypress run for Forked PRs 🥬 + if: steps.pr_origin.outputs.is_forked == 'true' + uses: cypress-io/github-action@v5 + with: + start: "npx vite preview --host" + wait-on: "http://localhost:4000" + wait-on-timeout: 300 + browser: chrome + record: true + parallel: true + group: "UI-Chrome" env: + CYPRESS_SPLIT_TESTS: "true" CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NODE_OPTIONS: --max_old_space_size=4096 COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }} + SPLIT: ${{ strategy.job-total }} + SPLIT_INDEX: ${{ strategy.job-index }} - # Upload Cypress Screenshots on Failure - - name: Upload Cypress Screenshots on Failure + # Upload Cypress screenshots on failure + - name: Upload cypress screenshots on failure 📸 uses: actions/upload-artifact@v3 if: failure() with: - name: cypress-screenshots-${{ matrix.job_index }} + name: cypress-screenshots path: cypress/screenshots - # Upload Cypress Videos - - name: Upload Cypress Videos + # Upload Cypress videos + - name: Upload cypress videos 📹 uses: actions/upload-artifact@v3 - if: failure() + if: steps.pr_origin.outputs.is_forked == 'true' with: - name: cypress-videos-${{ matrix.job_index }} + name: cypress-videos path: cypress/videos diff --git a/cypress/e2e/patient_spec/PatientInvestigation.cy.ts b/cypress/e2e/patient_spec/PatientInvestigation.cy.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/package-lock.json b/package-lock.json index a4276cb3d35..993dbace84f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -107,6 +107,18 @@ "node": ">=20.12.0" } }, + "apps/care_hcx_fe": { + "version": "1.0.0", + "license": "ISC", + "devDependencies": { + "react": "^18.0.0", + "react-dom": "^18.0.0" + }, + "peerDependencies": { + "react": "18.3.1", + "react-dom": "18.3.1" + } + }, "apps/care_livekit_fe": { "name": "care-livekit", "version": "0.0.1", @@ -6604,6 +6616,10 @@ "node": ">=6" } }, + "node_modules/care_hcx_fe": { + "resolved": "apps/care_hcx_fe", + "link": true + }, "node_modules/care-livekit": { "resolved": "apps/care_livekit_fe", "link": true From 1ec27ba52e09b0169e3c059a61112ed986401491 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 6 Nov 2024 02:19:25 +0530 Subject: [PATCH 09/21] trying cache and multiple job approach --- .github/workflows/cypress.yaml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 5cbf7313808..515c90703c8 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -8,16 +8,10 @@ on: workflow_dispatch: jobs: - cypress-run: + build-and-cache: permissions: write-all - if: github.repository == 'ohcnetwork/care_fe' runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - containers: [1, 2, 3, 4] - env: - REACT_CARE_API_URL: http://localhost:9000 + if: github.repository == 'ohcnetwork/care_fe' steps: - name: Checkout 📥 uses: actions/checkout@v3 @@ -91,9 +85,8 @@ jobs: name: frontend-build-cache path: frontend-build-cache.tar -jobs: - cypress-run: - needs: build-and-cache # Ensure this job runs after the build and cache job + cypress-tests: + needs: build-and-cache # Ensure this job runs after build-and-cache completes runs-on: ubuntu-latest strategy: fail-fast: false From 0f81d3bd382238fa0e83e1e7b2af9448629eb360 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 6 Nov 2024 02:28:02 +0530 Subject: [PATCH 10/21] trying cache and multiple job approach --- .github/workflows/cypress.yaml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 515c90703c8..af0bae52108 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -55,11 +55,12 @@ jobs: - name: Cache Backend Docker Image 📦 run: | docker save care_backend -o backend-cache.tar - - name: Upload Backend Cache Artifact - uses: actions/upload-artifact@v3 - with: - name: backend-docker-cache - path: backend-cache.tar + + - name: Upload Backend Cache Artifact + uses: actions/upload-artifact@v3 + with: + name: backend-docker-cache + path: backend-cache.tar - name: Determine Frontend PR Origin id: pr_origin @@ -79,11 +80,12 @@ jobs: - name: Cache Frontend Build 📦 run: | tar -cvf frontend-build-cache.tar ./build - - name: Upload Frontend Cache Artifact - uses: actions/upload-artifact@v3 - with: - name: frontend-build-cache - path: frontend-build-cache.tar + + - name: Upload Frontend Cache Artifact + uses: actions/upload-artifact@v3 + with: + name: frontend-build-cache + path: frontend-build-cache.tar cypress-tests: needs: build-and-cache # Ensure this job runs after build-and-cache completes From ed42cccbcc47cd168a685e70ccf9ca59e447e817 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 6 Nov 2024 02:37:37 +0530 Subject: [PATCH 11/21] modified backend name --- .github/workflows/cypress.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index af0bae52108..25aa440f547 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -54,7 +54,7 @@ jobs: - name: Cache Backend Docker Image 📦 run: | - docker save care_backend -o backend-cache.tar + docker save care-backend-1 -o backend-cache.tar - name: Upload Backend Cache Artifact uses: actions/upload-artifact@v3 From 985fb68145e087b9870e7347e1e0836d39363396 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 6 Nov 2024 02:45:15 +0530 Subject: [PATCH 12/21] modified backend name --- .github/workflows/cypress.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 25aa440f547..1e0e1c92c1c 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -54,7 +54,7 @@ jobs: - name: Cache Backend Docker Image 📦 run: | - docker save care-backend-1 -o backend-cache.tar + docker save care_local -o backend-cache.tar - name: Upload Backend Cache Artifact uses: actions/upload-artifact@v3 From a7c6e417593f24e2c6cb940991c90d401e3b44e8 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 6 Nov 2024 02:47:19 +0530 Subject: [PATCH 13/21] modified backend name of image --- .github/workflows/cypress.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 1e0e1c92c1c..f8fb69db844 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -206,3 +206,4 @@ jobs: with: name: cypress-videos path: cypress/videos + From e31df5510dcbeb79aa80067a2ef1339201b5bba9 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 6 Nov 2024 02:53:23 +0530 Subject: [PATCH 14/21] check the image list --- .github/workflows/cypress.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index f8fb69db844..258ef7ae0bf 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -51,6 +51,10 @@ jobs: max_attempts: 5 command: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000 on_retry_command: sleep 5 + + - name: List Docker Images 🐳 + run: + docker images - name: Cache Backend Docker Image 📦 run: | @@ -206,4 +210,4 @@ jobs: with: name: cypress-videos path: cypress/videos - + From 5c22e0f4002d6f04f4994019e141925a481479d8 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 6 Nov 2024 02:53:45 +0530 Subject: [PATCH 15/21] check the available image list --- .github/workflows/cypress.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 258ef7ae0bf..81057821538 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -53,8 +53,8 @@ jobs: on_retry_command: sleep 5 - name: List Docker Images 🐳 - run: - docker images + run: | + run: docker images - name: Cache Backend Docker Image 📦 run: | From 01b2fc0b27f39f4a644ca98b75ad41022538a2eb Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 6 Nov 2024 02:58:27 +0530 Subject: [PATCH 16/21] check the image list --- .github/workflows/cypress.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 81057821538..fd27147d08d 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -53,8 +53,7 @@ jobs: on_retry_command: sleep 5 - name: List Docker Images 🐳 - run: | - run: docker images + run: docker images - name: Cache Backend Docker Image 📦 run: | From 8f25f6b2170e64ebc42b049d213f87db21a435e3 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 6 Nov 2024 03:03:32 +0530 Subject: [PATCH 17/21] check the ava image list --- .github/workflows/cypress.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index fd27147d08d..45cfa1f8705 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -209,4 +209,3 @@ jobs: with: name: cypress-videos path: cypress/videos - From a4ac0fc498ae9f4a53987d1c036dc378090c6f41 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 6 Nov 2024 03:08:33 +0530 Subject: [PATCH 18/21] modified the backend name --- .github/workflows/cypress.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 45cfa1f8705..54856d6d3a3 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -57,7 +57,7 @@ jobs: - name: Cache Backend Docker Image 📦 run: | - docker save care_local -o backend-cache.tar + docker save ghcr.io/ohcnetwork/care:latest -o backend-cache.tar - name: Upload Backend Cache Artifact uses: actions/upload-artifact@v3 From 4a379899903e54d573a96812bf1f32e97f1de1b9 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 6 Nov 2024 03:08:54 +0530 Subject: [PATCH 19/21] modified the backend name list --- .github/workflows/cypress.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 54856d6d3a3..81dfac2dbc2 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -209,3 +209,4 @@ jobs: with: name: cypress-videos path: cypress/videos + From 33ef9862edb4a799d6af4826263ac926ed226d8d Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 6 Nov 2024 03:23:33 +0530 Subject: [PATCH 20/21] debug the cypress step 2 --- .github/workflows/cypress.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 81dfac2dbc2..06f23e7bdf9 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -51,9 +51,6 @@ jobs: max_attempts: 5 command: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000 on_retry_command: sleep 5 - - - name: List Docker Images 🐳 - run: docker images - name: Cache Backend Docker Image 📦 run: | @@ -114,6 +111,9 @@ jobs: - name: Load Backend Docker Image 🐳 run: docker load -i backend-cache.tar + - name: List Directory Contents for Debugging 🗂️ + run: ls -al + # Start backend Docker containers - name: Start care backend docker containers 🐳 run: | From 53bdd6c2b795912118dd760dc57f9bd82fc91e8d Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 6 Nov 2024 03:32:55 +0530 Subject: [PATCH 21/21] debug the cypress step 2 --- .github/workflows/cypress.yaml | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 06f23e7bdf9..79b9d4f0962 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -87,8 +87,9 @@ jobs: name: frontend-build-cache path: frontend-build-cache.tar + jobs: cypress-tests: - needs: build-and-cache # Ensure this job runs after build-and-cache completes + needs: build-and-cache runs-on: ubuntu-latest strategy: fail-fast: false @@ -97,8 +98,15 @@ jobs: env: REACT_CARE_API_URL: http://localhost:9000 steps: - - name: Checkout 📥 + - name: Checkout care_fe repository 📥 + uses: actions/checkout@v3 + + - name: Checkout care backend repository 📥 uses: actions/checkout@v3 + with: + repository: ohcnetwork/care # Replace with the actual owner/repo if different + path: care + ref: ${{ needs.build-and-cache.outputs.backend-branch }} # Ensure this is defined in the previous job # Download the cached backend Docker image - name: Download Backend Cache @@ -111,18 +119,19 @@ jobs: - name: Load Backend Docker Image 🐳 run: docker load -i backend-cache.tar - - name: List Directory Contents for Debugging 🗂️ - run: ls -al - + - name: List Directory Contents After Checkout 🗂️ + run: ls -al + # Start backend Docker containers - name: Start care backend docker containers 🐳 run: | cd care - echo DISABLE_RATELIMIT=True >> docker/.prebuilt.env - echo "CORS_ALLOWED_ORIGINS=\"[\\\"http://localhost:4000\\\"]\"" >> docker/.prebuilt.env - echo JWKS_BASE64=\"$(cat ../.github/runner-files/jwks.b64.txt)\" >> docker/.prebuilt.env + echo "DISABLE_RATELIMIT=True" >> docker/.prebuilt.env + echo 'CORS_ALLOWED_ORIGINS=["http://localhost:4000"]' >> docker/.prebuilt.env + echo "JWKS_BASE64=${{ secrets.JWKS_BASE64 }}" >> docker/.prebuilt.env make docker_config_file=docker-compose.pre-built.yaml up - cd .. + env: + JWKS_BASE64: ${{ secrets.JWKS_BASE64 }} # Check backend health - name: Wait for backend health check ♻