Module 10 ยท Python for SDETs

CI with
GitHub Actions

The suite runs itself โ€” on every push and pull request

tests.yml start app & wait report artifact required check
AI with Rufat
Tests you must remember to run eventually don't

CI runs the suite for you โ€” automatically

๐Ÿ”

Every change

Runs every test on every push and PR โ€” no "I forgot to run them."

๐Ÿ›‘

Blocks breakage

A failure marks the commit/PR red โ€” and can require green to merge.

๐Ÿ“„

Shareable report

The HTML report is attached to the run for anyone to open.

๐ŸšชThe payoff is a required check: a PR can't merge until the suite passes on CI's clean machine โ€” not just "works on my laptop."
AI with Rufat
One YAML file in .github/workflows/
# .github/workflows/tests.yml
name: tests
on:
push: { branches: [main] }
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps: โ€ฆ
๐ŸงฑA name, an on: trigger, and jobs made of steps.
๐Ÿ”ฉEach step is either uses: (a prebuilt action) or run: (shell commands). Scoping push to main stops a branch push and its PR both running.
AI with Rufat
The shape of the job

Check out โ†’ set up โ†’ start the app โ†’ test โ†’ upload

checkout
โ†’
Python + Node
โ†’
pip install + playwright
โ†’
start app & wait
โ†’
pytest
โ†’
upload report
๐Ÿ“ŒRe-pin requirements.txt after every install (pytest-html, pytest-playwright) โ€” a missing dep fails the --html step on CI.
AI with Rufat
Two details that trip people up
# background the app, then WAIT
npm start &
for i in $(seq 1 30); do
curl -sf localhost:3000/api/products \
&& exit 0
sleep 1
done; exit 1 # never started
โณnpm start & returns immediately โ€” poll a real endpoint until it answers, don't sleep a fixed guess.
๐Ÿงplaywright install --with-deps chromium โ€” the headless runner needs the Linux libs too.
๐Ÿ’พUpload with if: always() โ€” keep the report even when tests fail (that's when you want it).
AI with Rufat
๐Ÿค–

The tests
always ran

Every push checked on a clean machine, the report attached, merges gated on green

โš™๏ธ
Practice
Add tests.yml, push, and watch the run go green in the Actions tab
๐Ÿšช
Require it
Branch protection: require the test job so no red PR reaches main
โžก๏ธ
Module 11
Capstone โ€” a complete API + UI suite tying it all together
AI with Rufat
โ† / โ†’ ยท space