Cheat sheets / Git, Docker and CI

Git, Docker and CI

The commands and ideas that come up when you say you run tests in CI.

Git

merge vs rebase
Merge keeps history and adds a merge commit; rebase rewrites your commits on top of the target for a linear history. Never rebase shared branches.
Undo safely
revert makes a new commit that undoes one; reset moves the branch pointer and can lose work.
git revert <sha>
Find a bad commit
Binary search through history.
git bisect start; git bisect bad; git bisect good <sha>
Stash
Park uncommitted changes.
git stash; git stash pop

Docker

Image vs container
A read-only template vs a running instance of it.
Run tests in a container
A pinned image keeps browsers and dependencies identical in every run.
docker run --rm -v $PWD:/work -w /work image npm test
docker compose
Starts the app, database and test runner together for integration runs.

CI pipeline

Stages
Build, unit, deploy to test, smoke, regression, report.
Fast feedback
Run the cheap checks first and in parallel; fail early.
Artifacts
Keep reports, screenshots, traces and videos from failed runs.
Secrets
Use the CI secret store; never commit credentials.