name: E2E Tests on: push: branches: - main pull_request: branches: - main concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: changes: runs-on: ubuntu-latest permissions: pull-requests: read outputs: test-changes: ${{ steps.changes.outputs.test-sources }} steps: - name: ๐Ÿ“ฅ Checkout repo uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: ๐Ÿ” Check if any source code has changed id: changes uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3 with: filters: | test-sources: - 'packages/**/src/**/*!(.test).ts' - 'packages/**/src/**/*!(.test).tsx' - 'packages/**/src/**/*!(.test).js' - 'packages/**/src/**/*!(.test).jsx' - 'packages/**/src/**/*.scss' - 'packages/**/src/routes.json' - 'package.json' - 'playwright.config.ts' - 'e2e/**/*.ts' - 'e2e/**/*.js' - 'e2e/support/github/**/*.*' - 'example.env' - '.github/workflows/e2e.yml' run-e2e-on-esm-core: needs: changes if: ${{ needs.changes.outputs.test-changes == 'true' }} runs-on: ubuntu-latest timeout-minutes: 25 steps: - name: ๐Ÿ“ฅ Checkout repo uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: ๐Ÿ“„ Copy test environment variables run: cp example.env .env - name: ๐Ÿ› ๏ธ Setup node uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 22 - name: ๐Ÿ’พ Cache dependencies id: cache-dependencies uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: | **/node_modules !e2e_repo/** key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: ๐Ÿ“ฆ Install dependencies if: steps.cache-dependencies.outputs.cache-hit != 'true' run: yarn install --immutable - name: ๐Ÿš€ Setup local cache server for Turborepo uses: rharkor/caching-for-turbo@760158c05c47e7a764f78e9a22ca3b5a6ed8c52e # v2.5.2 - name: ๐Ÿ—๏ธ Build apps run: yarn turbo run build --color --concurrency=5 - name: ๐Ÿ’พ Cache Playwright Browsers id: playwright-cache uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ~/.cache/ms-playwright key: ${{ runner.os }}-playwright-${{ hashFiles('**/yarn.lock') }} - name: ๐ŸŽญ Install Playwright Browsers run: yarn playwright install chromium --with-deps - name: ๐Ÿ–ฅ๏ธ Start dev server and wait for backend run: bash e2e/support/github/run-e2e-docker-env.sh - name: ๐Ÿงช Run E2E tests run: yarn playwright test - name: ๐Ÿ“ค Upload Report uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 if: always() with: name: report-esm-core path: playwright-report/ retention-days: 30 run-e2e-on-other-repos: needs: changes if: ${{ needs.changes.outputs.test-changes == 'true' }} runs-on: ubuntu-latest strategy: matrix: repo: - openmrs-esm-patient-management - openmrs-esm-patient-chart - openmrs-esm-form-builder fail-fast: false steps: - name: ๐Ÿ“ฅ Checkout esm-core repo uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: ๐Ÿ› ๏ธ Setup node uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 22 - name: ๐Ÿ’พ Cache dependencies id: cache-dependencies uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: | **/node_modules !e2e_repo/** key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - name: ๐Ÿ“ฆ Install dependencies if: steps.cache-dependencies.outputs.cache-hit != 'true' run: yarn install --immutable - name: ๐Ÿš€ Setup local cache server for Turborepo uses: rharkor/caching-for-turbo@760158c05c47e7a764f78e9a22ca3b5a6ed8c52e # v2.5.2 - name: ๐Ÿ—๏ธ Build apps run: yarn turbo run build --color --concurrency=5 - name: ๐Ÿ–ฅ๏ธ Start dev server and wait for backend run: bash e2e/support/github/run-e2e-docker-env.sh - name: ๐Ÿ“ฅ Checkout to the ${{ matrix.repo }} main branch uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: openmrs/${{ matrix.repo }} ref: main path: e2e_repo - name: ๐Ÿ“„ Copy test environment variables for ${{ matrix.repo }} run: cp example.env .env working-directory: e2e_repo - name: ๐Ÿ’พ Cache dependencies for ${{ matrix.repo }} id: cache-other-repo-dependencies uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: e2e_repo/**/node_modules key: ${{ runner.os }}-${{ matrix.repo }}-${{ hashFiles('e2e_repo/**/yarn.lock') }} - name: ๐Ÿ“ฆ Install dependencies for ${{ matrix.repo }} if: steps.cache-other-repo-dependencies.outputs.cache-hit != 'true' run: yarn install --immutable working-directory: e2e_repo - name: ๐Ÿ’พ Cache Playwright Browsers for ${{ matrix.repo }} id: playwright-cache uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ~/.cache/ms-playwright key: ${{ runner.os }}-playwright-${{ hashFiles('e2e_repo/**/yarn.lock') }} - name: ๐ŸŽญ Install Playwright Browsers for ${{ matrix.repo }} run: yarn playwright install chromium --with-deps working-directory: e2e_repo - name: ๐Ÿงช Run E2E tests for ${{ matrix.repo }} run: yarn playwright test --retries=1 working-directory: e2e_repo - name: ๐Ÿ“ค Upload Report for ${{ matrix.repo }} uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 if: always() with: name: report-${{ matrix.repo }} path: e2e_repo/playwright-report/ retention-days: 30 - name: ๐Ÿ“ Capture Server Logs if: always() uses: openmrs/openmrs-contrib-gha-workflows/.github/actions/capture-docker-logs@main with: dest: "./logs" - name: ๐Ÿ“ค Upload Logs as Artifact uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 if: always() with: name: server-logs-${{ matrix.repo }} path: "./logs" retention-days: 2 overwrite: true # Single required check for branch protection: passes when E2E tests were skipped as unneeded or all passed. # Uses always() rather than !cancelled() because a skipped job counts as passing for required checks. e2e-status: needs: [changes, run-e2e-on-esm-core, run-e2e-on-other-repos] if: ${{ always() }} runs-on: ubuntu-latest steps: - name: โŒ Fail if any E2E job failed or was cancelled if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} run: exit 1