💊 Enhance Bed Layout Visualization with Interactive Detailed View (#1… #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Playwright Tests | |
| # This workflow runs Playwright E2E tests with backend integration | |
| # - Triggers on push to main branches and PRs | |
| # - Uses path filtering to skip unnecessary runs | |
| # - Runs tests in parallel using 3 shards | |
| # - Provides detailed test reports as artifacts | |
| on: | |
| push: | |
| branches: [main, develop, production] | |
| pull_request: | |
| branches: [develop, production] | |
| paths: | |
| - "src/**" | |
| - "tests/**" | |
| - "package.json" | |
| - "package-lock.json" | |
| - "playwright.config.ts" | |
| - ".github/workflows/playwright.yaml" | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| NODE_VERSION: "22" | |
| REACT_CARE_API_URL: http://localhost:9000 | |
| BACKEND_STARTUP_TIMEOUT: 120 | |
| TEST_SHARDS: 3 | |
| jobs: | |
| # Detect if test-related files changed | |
| changes: | |
| if: github.repository == 'ohcnetwork/care_fe' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tests: ${{ steps.filter.outputs.tests }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dorny/paths-filter@v3 | |
| id: filter | |
| with: | |
| filters: | | |
| tests: | |
| - 'tests/**' | |
| - 'src/**' | |
| - 'package.json' | |
| - 'playwright.config.ts' | |
| # Build application once and cache for all test shards | |
| build: | |
| if: github.repository == 'ohcnetwork/care_fe' && needs.changes.outputs.tests == 'true' | |
| needs: changes | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout 📥 | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci --prefer-offline | |
| - name: Build application | |
| run: npm run build | |
| env: | |
| NODE_ENV: production | |
| - name: Cache build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| dist/ | |
| node_modules/ | |
| key: build-${{ github.sha }} | |
| # Run E2E tests with backend integration | |
| test: | |
| if: github.repository == 'ohcnetwork/care_fe' && needs.changes.outputs.tests == 'true' | |
| needs: [changes, build] | |
| timeout-minutes: 30 | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| shard: [1, 2, 3] | |
| steps: | |
| - name: Checkout 📥 | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set backend branch | |
| id: backend-branch | |
| run: echo "branch=develop" >> $GITHUB_OUTPUT | |
| - name: Checkout care 📥 | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ohcnetwork/care | |
| path: care | |
| ref: ${{ steps.backend-branch.outputs.branch }} | |
| fetch-depth: 0 | |
| - name: Start care docker containers 🐳 | |
| run: | | |
| cd care | |
| echo DISABLE_RATELIMIT=True >> docker/.local.env | |
| echo JWKS_BASE64=\"$(cat ../.github/runner-files/jwks.b64.txt)\" >> docker/.local.env | |
| echo MAX_QUESTIONNAIRE_TEXT_RESPONSE_SIZE=500 >> docker/.local.env | |
| make docker_config_file=docker-compose.local.yaml up load-fixtures | |
| cd .. | |
| env: | |
| JWKS_BASE64: ${{ secrets.JWKS_BASE64 }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: "npm" | |
| - name: Restore build cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| dist/ | |
| node_modules/ | |
| key: build-${{ github.sha }} | |
| - name: Cache Playwright browsers | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/ms-playwright | |
| key: ${{ runner.os }}-playwright-${{ hashFiles('package-lock.json') }}-${{ hashFiles('playwright.config.ts') }} | |
| restore-keys: | | |
| ${{ runner.os }}-playwright-${{ hashFiles('package-lock.json') }}- | |
| ${{ runner.os }}-playwright- | |
| - name: Install Playwright browsers | |
| run: npx playwright install --with-deps chromium | |
| - name: Run Playwright tests (Shard ${{ matrix.shard }}/${{ env.TEST_SHARDS }}) | |
| id: test | |
| run: | | |
| npx playwright test --shard=${{ matrix.shard }}/${{ env.TEST_SHARDS }} | |
| env: | |
| NODE_ENV: production | |
| REACT_CARE_API_URL: ${{ env.REACT_CARE_API_URL }} | |
| - name: Annotate test failure | |
| if: failure() && steps.test.conclusion == 'failure' | |
| run: | | |
| echo "::error::Playwright tests failed in shard ${{ matrix.shard }}/${{ env.TEST_SHARDS }}" | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: playwright-results-shard-${{ matrix.shard }} | |
| path: | | |
| playwright-report/ | |
| test-results/ | |
| retention-days: 7 | |
| - name: Stop backend services | |
| if: always() | |
| run: | | |
| cd care | |
| make docker_config_file=docker-compose.local.yaml down || true | |
| # Aggregate results and create final report | |
| report: | |
| if: always() && github.repository == 'ohcnetwork/care_fe' && needs.changes.outputs.tests == 'true' | |
| needs: [changes, test] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all test results | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: playwright-results-shard-* | |
| path: all-results | |
| - name: Merge test results | |
| id: merge | |
| run: | | |
| TOTAL_TESTS=0 | |
| PASSED_TESTS=0 | |
| FAILED_TESTS=0 | |
| SKIPPED_TESTS=0 | |
| # Parse test results from each shard | |
| for dir in all-results/playwright-results-shard-*/; do | |
| if [ -f "$dir/test-results.json" ]; then | |
| # Add your result parsing logic here | |
| echo "Processing results from $dir" | |
| fi | |
| done | |
| echo "total=$TOTAL_TESTS" >> $GITHUB_OUTPUT | |
| echo "passed=$PASSED_TESTS" >> $GITHUB_OUTPUT | |
| echo "failed=$FAILED_TESTS" >> $GITHUB_OUTPUT | |
| echo "skipped=$SKIPPED_TESTS" >> $GITHUB_OUTPUT | |
| if [ $FAILED_TESTS -gt 0 ]; then | |
| echo "status=❌ Failed" >> $GITHUB_OUTPUT | |
| else | |
| echo "status=✅ Passed" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Upload final report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-final-report | |
| path: all-results/ | |
| retention-days: 14 | |
| - name: Comment PR with test results | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const status = '${{ steps.merge.outputs.status }}'; | |
| const total = '${{ steps.merge.outputs.total }}' || 'N/A'; | |
| const passed = '${{ steps.merge.outputs.passed }}' || 'N/A'; | |
| const failed = '${{ steps.merge.outputs.failed }}' || 'N/A'; | |
| const skipped = '${{ steps.merge.outputs.skipped }}' || 'N/A'; | |
| const shards = ${{ env.TEST_SHARDS }}; | |
| const body = `## 🎭 Playwright Test Results | |
| **Status:** ${status} | |
| **Test Shards:** ${shards} | |
| | Metric | Count | | |
| |--------|-------| | |
| | Total Tests | ${total} | | |
| | ✅ Passed | ${passed} | | |
| | ❌ Failed | ${failed} | | |
| | ⏭️ Skipped | ${skipped} | | |
| 📊 Detailed results are available in the [playwright-final-report](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) artifact. | |
| <sub>Run: [#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})</sub>`; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: body | |
| }); | |
| - name: Fail workflow if tests failed | |
| if: needs.test.result == 'failure' | |
| run: | | |
| echo "::error::One or more test shards failed" | |
| exit 1 |