Feature/challenge daniel velazco #6
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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| test_suite: | |
| description: 'Which suite to run (all | ui | api)' | |
| required: false | |
| default: 'all' | |
| type: choice | |
| options: [all, ui, api] | |
| jobs: | |
| test: | |
| name: Lint & Test | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| # ── 1. Checkout ────────────────────────────────────────────────────────── | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # ── 2. Node.js ─────────────────────────────────────────────────────────── | |
| - name: Set up Node.js 24 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '24.14.1' | |
| # ── 3. Dependencies (node_modules cached by package.json hash) ──────────── | |
| - name: Cache node_modules | |
| id: node-modules-cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: node_modules | |
| key: node-modules-${{ runner.os }}-${{ hashFiles('package.json') }} | |
| - name: Install dependencies | |
| if: steps.node-modules-cache.outputs.cache-hit != 'true' | |
| run: npm install | |
| env: | |
| npm_config_registry: https://registry.npmjs.org | |
| # ── 4. Playwright browsers (cached) ────────────────────────────────────── | |
| - name: Cache Playwright browsers | |
| id: playwright-cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/ms-playwright | |
| key: playwright-${{ runner.os }}-${{ hashFiles('package.json') }} | |
| restore-keys: playwright-${{ runner.os }}- | |
| - name: Install Playwright browsers | |
| if: steps.playwright-cache.outputs.cache-hit != 'true' | |
| run: npx playwright install --with-deps | |
| - name: Install Playwright OS dependencies (cached hit) | |
| if: steps.playwright-cache.outputs.cache-hit == 'true' | |
| run: npx playwright install-deps | |
| # ── 5. Lint ─────────────────────────────────────────────────────────────── | |
| - name: Lint | |
| run: npm run lint | |
| # ── 6a. UI tests — Chromium ─────────────────────────────────────────────── | |
| - name: Run UI tests (chromium) | |
| if: > | |
| github.event_name != 'workflow_dispatch' || | |
| inputs.test_suite == 'all' || | |
| inputs.test_suite == 'ui' | |
| run: npx playwright test tests/e2e --project=chromium | |
| continue-on-error: true | |
| env: | |
| CI: 'true' | |
| BASE_URL: https://demoqa.com | |
| # ── 6b. UI tests — Mobile Chrome ───────────────────────────────────────── | |
| - name: Run UI tests (mobile-chrome) | |
| if: > | |
| github.event_name != 'workflow_dispatch' || | |
| inputs.test_suite == 'all' || | |
| inputs.test_suite == 'ui' | |
| run: npx playwright test tests/e2e --project=mobile-chrome | |
| continue-on-error: true | |
| env: | |
| CI: 'true' | |
| BASE_URL: https://demoqa.com | |
| # ── 7. API tests ────────────────────────────────────────────────────────── | |
| - name: Run API tests | |
| if: > | |
| github.event_name != 'workflow_dispatch' || | |
| inputs.test_suite == 'all' || | |
| inputs.test_suite == 'api' | |
| run: npm run test:api | |
| continue-on-error: true | |
| env: | |
| CI: 'true' | |
| BASE_URL: https://demoqa.com | |
| # ── 8. Upload reports artifact ──────────────────────────────────────────── | |
| - name: Upload test reports | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: playwright-reports-${{ github.run_id }} | |
| path: reports/ | |
| retention-days: 30 | |
| # ── 9. Publish JUnit test summary ───────────────────────────────────────── | |
| - name: Publish test results | |
| uses: dorny/test-reporter@v1 | |
| if: always() | |
| with: | |
| name: Playwright Test Results | |
| path: reports/junit/results.xml | |
| reporter: java-junit | |
| fail-on-error: false |