Manuals / Playwright with Python / Chapter 34

Part 5 · CI/CD & Reporting · advanced · ~50 min · Chapter 34 of 61

25. CI/CD Integration

GitHub Actions workflow setup A GitHub Actions workflow is a YAML file living in .github/workflows/ that defines when tests run (e.g., on every pull request) and what steps to execute. # .github/workflows/playwright.yml name: Playwright Tests on: push: branches: [main] pull_request: branches: [main] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@

Path progress
55%

Step 1 of 3

GitHub Actions workflow setup

A GitHub Actions workflow is a YAML file living in .github/workflows/ that defines when tests run (e.g., on every pull request) and what steps to execute. push: branches: [main] pull_request: branches: [main] test: runs-on: ubuntu-latest with: python-version: '3.11' - name: Install dependencies - name: Run tests What it does: Defines which events cause the workflow to run. Types/params: Pointers: Running on pull_request is the most common setup for catching regressions before merge; schedule is useful for a nightly full-regression run separate from a fast pull_request smoke-test run. What it does: Installs browser binaries plus the OS-level system dependencies (fonts, libraries) those browsers need to actually run on a fresh CI machine. Types/params: No required params; --with-deps is the key flag for CI environments specifically. Pointers: On a fresh CI runner (unlike your local dev machine), the OS-level dependencies genuinely aren't present — skipping --with-deps is a very common cause of "works locally, fails in CI" browser launch errors.

  • push (dict, optional) — runs on pushes to specified branches
  • pull_request (dict, optional) — runs when a PR is opened/updated against specified branches
  • schedule (list, optional) — cron-based scheduled runs, e.g. nightly regression suites
GitHub Actions workflow setupDrag stickies · tap for tips
Study mapDrag stickies · tap for tipsKeep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Assert the UIdrag · tap →Retry wiselydrag · tap →Seed datadrag · tap →Close the loopdrag · tap →Keep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Pathwise hackdrag · tap →Page under testdrag · tap →Multi-browserdrag · tap →Automation pathdrag · tap →Tooling nodedrag · tap →

Try it

Run / study this snippet

run: |
Was this step clear?
Chapter learning outcomes
  • GitHub Actions workflow setup
  • Jenkins pipeline basics
  • Running headless in CI

Clear these before you leave

Side quest

25. CI/CD Integration deliverable

Apply one idea from “GitHub Actions workflow setup” in a small script or note.