Playwright Tests CI #50
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 CI | |
| # ───────────────────────────────────────────────────────────────────────────── | |
| # Triggers | |
| # ───────────────────────────────────────────────────────────────────────────── | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main ] | |
| schedule: | |
| # Run smoke tests every day at 6 AM UTC (11:30 AM IST) | |
| - cron: "0 6 * * *" | |
| workflow_dispatch: # allows manual trigger from GitHub Actions UI | |
| inputs: | |
| test_suite: | |
| description: "Which tests to run" | |
| required: false | |
| default: "smoke" | |
| type: choice | |
| options: [ smoke, regression, e2e, api, all ] | |
| browser: | |
| description: "Browser" | |
| required: false | |
| default: "chromium" | |
| type: choice | |
| options: [ chromium, firefox, webkit ] | |
| # ───────────────────────────────────────────────────────────────────────────── | |
| # Jobs | |
| # ───────────────────────────────────────────────────────────────────────────── | |
| jobs: | |
| smoke-tests: | |
| name: Smoke Tests (${{ matrix.browser }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false # continue other browsers if one fails | |
| matrix: | |
| browser: [ chromium ] # add firefox, webkit for cross-browser | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| cache: "pip" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Install Playwright browsers | |
| run: | | |
| playwright install --with-deps ${{ matrix.browser }} | |
| - name: Create reports directory | |
| run: mkdir -p reports screenshots | |
| - name: Run Smoke Tests | |
| env: | |
| ENV: staging | |
| STAGING_URL: https://the-internet.herokuapp.com | |
| TEST_USERNAME: tomsmith | |
| TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }} | |
| CI: true | |
| run: | | |
| pytest -m smoke \ | |
| --browser=${{ matrix.browser }} \ | |
| --headless=true \ | |
| --html=reports/smoke_${{ matrix.browser }}.html \ | |
| --self-contained-html \ | |
| -v | |
| - name: Upload Test Reports | |
| if: always() # upload even if tests failed | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: smoke-report-${{ matrix.browser }} | |
| path: | | |
| reports/ | |
| screenshots/ | |
| retention-days: 30 | |
| regression-tests: | |
| name: Regression Tests | |
| runs-on: ubuntu-latest | |
| needs: smoke-tests # only runs if smoke tests pass | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| cache: "pip" | |
| - name: Install dependencies | |
| run: | | |
| pip install -r requirements.txt | |
| playwright install --with-deps chromium | |
| - name: Run Regression Tests (parallel) | |
| env: | |
| ENV: staging | |
| STAGING_URL: https://the-internet.herokuapp.com | |
| TEST_USERNAME: tomsmith | |
| TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }} | |
| CI: true | |
| run: | | |
| pytest -m "regression and not slow" \ | |
| --browser=chromium \ | |
| --headless=true \ | |
| -n auto \ | |
| --html=reports/regression.html \ | |
| --self-contained-html \ | |
| -v | |
| - name: Upload Regression Report | |
| if: always() | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: regression-report | |
| path: reports/ | |
| retention-days: 30 | |
| api-tests: | |
| name: API Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| cache: "pip" | |
| - run: pip install -r requirements.txt | |
| - run: playwright install chromium --with-deps | |
| - name: Run API Tests | |
| run: | | |
| pytest -m api \ | |
| --html=reports/api.html \ | |
| --self-contained-html \ | |
| -v | |
| - uses: actions/upload-artifact@v5 | |
| if: always() | |
| with: | |
| name: api-report | |
| path: reports/ | |
| retention-days: 30 |