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
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."
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.
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.
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).
๐ค
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