diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..93f0275 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +name: CI + +on: + push: + branches: [main] + paths-ignore: ["**.md", "LICENSE"] # a typo fix should not cost minutes + pull_request: + workflow_dispatch: + +# Least privilege. A called workflow can only reduce this, never add to it. +permissions: + contents: read + +# Concurrency belongs in the CALLER: it owns the trigger, so it owns the +# question of what supersedes what. +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + smoke: + uses: suryakulshreshtha/.github/.github/workflows/python-playwright.yml@v1 + with: + browsers: '["chromium"]' + pytest-args: -m smoke + + # API tests need no browser at all -- saves ~90s of install per run. + api: + uses: suryakulshreshtha/.github/.github/workflows/python-playwright.yml@v1 + with: + needs-browser: false + lint-paths: "" + pytest-args: -m api + + regression: + needs: smoke # fail fast, and fail cheap + uses: suryakulshreshtha/.github/.github/workflows/python-playwright.yml@v1 + with: + browsers: '["chromium"]' + pytest-args: -m "regression and not slow" -n auto diff --git a/.github/workflows/playwright-tests.yml b/.github/workflows/playwright-tests.yml deleted file mode 100644 index 86ba9ad..0000000 --- a/.github/workflows/playwright-tests.yml +++ /dev/null @@ -1,157 +0,0 @@ -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