diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 1104d7f480d..79b9d4f0962 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 @@ -31,14 +25,14 @@ jobs: echo "branch=develop" >> $GITHUB_OUTPUT fi - - name: Checkout care 📥 + - name: Checkout care backend 📥 uses: actions/checkout@v3 with: repository: ohcnetwork/care path: care ref: ${{ steps.backend-branch.outputs.branch }} - - name: Start care docker containers 🐳 + - name: Start care backend docker containers 🐳 run: | cd care echo DISABLE_RATELIMIT=True >> docker/.prebuilt.env @@ -50,7 +44,7 @@ jobs: env: JWKS_BASE64: ${{ secrets.JWKS_BASE64 }} - - name: Wait for care to be up ♻ + - name: Wait for care backend to be up ♻ uses: nick-fields/retry@v2 with: timeout_minutes: 1 @@ -58,7 +52,17 @@ jobs: command: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000 on_retry_command: sleep 5 - - name: Determine PR Origin + - name: Cache Backend Docker Image 📦 + run: | + docker save ghcr.io/ohcnetwork/care:latest -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 }})" @@ -67,24 +71,102 @@ jobs: with: node-version: "20" - - name: Install dependencies 📦 + - name: Install frontend dependencies 📦 run: npm run install-all - - name: Build ⚙️ + - name: Build the frontend after downloading all dependencies ⚙️ run: npm run build + - 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 + + jobs: + cypress-tests: + needs: build-and-cache + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + containers: [1, 2, 3, 4] + env: + REACT_CARE_API_URL: http://localhost:9000 + steps: + - 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 + uses: actions/download-artifact@v3 + with: + name: backend-docker-cache + path: . + + # Load the cached Docker image + - name: Load Backend Docker Image 🐳 + run: docker load -i backend-cache.tar + + - 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=${{ secrets.JWKS_BASE64 }}" >> docker/.prebuilt.env + make docker_config_file=docker-compose.pre-built.yaml up + env: + JWKS_BASE64: ${{ secrets.JWKS_BASE64 }} + + # Check backend health + - name: Wait for backend health check ♻ + 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 + + # 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 + + # Install Chrome - 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 + # 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: - env: SKIP_PREFLIGHT_CHECK=true - install: false start: "npx vite preview --host" wait-on: "http://localhost:4000" wait-on-timeout: 300 @@ -96,15 +178,14 @@ jobs: 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 }} + # 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: - env: SKIP_PREFLIGHT_CHECK=true - install: false start: "npx vite preview --host" wait-on: "http://localhost:4000" wait-on-timeout: 300 @@ -117,11 +198,12 @@ jobs: 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 }} SPLIT: ${{ strategy.job-total }} SPLIT_INDEX: ${{ strategy.job-index }} + # Upload Cypress screenshots on failure - name: Upload cypress screenshots on failure 📸 uses: actions/upload-artifact@v3 if: failure() @@ -129,9 +211,11 @@ jobs: name: cypress-screenshots path: cypress/screenshots + # Upload Cypress videos - name: Upload cypress videos 📹 uses: actions/upload-artifact@v3 if: steps.pr_origin.outputs.is_forked == 'true' with: name: cypress-videos - path: cypress/videos \ No newline at end of file + 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