Skip to content

Feature/challenge daniel velazco #8

Feature/challenge daniel velazco

Feature/challenge daniel velazco #8

Workflow file for this run

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
permissions:
checks: write
contents: read
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 ───────────────────────────────────────────────
# Each test step uses --reporter=blob so results accumulate in blob-report/
# without overwriting each other. merge-reports combines them at the end.
- 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 --reporter=blob
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 --reporter=blob
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: npx playwright test tests/api --reporter=blob
continue-on-error: true
env:
CI: 'true'
BASE_URL: https://demoqa.com
# ── 8. Merge blobs → single HTML + JUnit report ───────────────────────────
# Combines all blob files from blob-report/ into one unified report.
# Only the test suites that actually ran will appear in the merged output.
- name: Merge test reports
if: always()
run: |
mkdir -p reports/junit
npx playwright merge-reports --reporter=html,junit ./blob-report
env:
PLAYWRIGHT_HTML_OUTPUT_DIR: reports/html
PLAYWRIGHT_JUNIT_OUTPUT_NAME: reports/junit/results.xml
# ── 9. 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
# ── 10. 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