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.
- Find a bad commit
- Binary search through history.
- Stash
- Park uncommitted changes.
git revert <sha>git bisect start; git bisect bad; git bisect good <sha>git stash; git stash popDocker
- 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 compose
- Starts the app, database and test runner together for integration runs.
docker run --rm -v $PWD:/work -w /work image npm testCI 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.