Skip to content

Latest commit

 

History

History
114 lines (90 loc) · 5.09 KB

git-workflow.md

File metadata and controls

114 lines (90 loc) · 5.09 KB

Git workflow: dev → GitLab merge → main

The rule itself is stated in AGENTS.md ("Branching workflow — not optional"); this document is the how-to. The shape:

 local dev ──commit──▶ local dev ──push──▶ origin/dev ──MR merge──▶ origin/main
                                              ▲                        │
                                              │ CI must pass           ▼
                                              └──────────────   local main (pull only)

Changes are made locally on dev, pushed to the remote dev branch, and reach main only through a merge request on GitLab, once they work. Nothing is ever committed to main directly — not locally, not on the server.

The two branches

Branch Role Local use
dev Where work happens. Long-lived, never deleted. Check out, commit, push.
main Known-good. Every commit on it arrived via a reviewed, CI-green merge. Pull only. git checkout main && git pull after a merge, then go back to dev.

main being known-good is a guarantee, not a habit: a commit landing on it directly — even a one-line fix — means there is now a revision of main that was also the first place the change was tried.

Day to day

git checkout dev          # or: git switch dev
# ... edit, commit as usual ...
make test                 # the suite must pass before pushing
git push                  # dev tracks origin/dev; plain push is enough

Push early and often — dev is allowed to be in progress. The quality gate sits at the merge, not at the push. Every push does trigger CI, so a red pipeline on dev is a nudge, not a crisis.

Merging on GitLab

When the work on dev is ready:

  1. Open (or revisit) the merge request from dev into main. An open MR follows the branch: later pushes to dev join it automatically.
  2. Read the diff once on the MR page. It reads differently than it does in the terminal, and this is the last look before main changes.
  3. Wait for the pipeline to be green. The merge is conditional on it — "it works" is the condition for the merge, not something to discover on main afterwards.
  4. Check the two checkboxes are right:
    • Delete source branch: unchecked. dev is long-lived, not a feature branch.
    • Squash commits: unchecked. The commits on dev are individually meaningful; squashing flattens separate decisions into one blob.
  5. Merge. The project uses the merge commit method (GitLab's default), which is the --no-ff behaviour the AGENTS.md rule asks for: the merge commit records which commits landed together as one unit of work.

After the merge

git checkout main && git pull    # fast-forwards to the merge commit
git checkout dev                 # back to where work happens

Local main exists only to mirror origin/main. If git pull on main ever reports anything other than a fast-forward, something was committed to main directly — stop and untangle that before continuing.

What CI runs

.gitlab-ci.yml runs the same checks pre-commit runs locally, with the same scopes, on python:3.12-slim — the shipped runtime and the mypy target. Green in CI means exactly what a clean local run means.

Job Checks Gates the merge
test pytest (synthetic source trees and throwaway git repositories; no clones and no network needed — git is installed into the slim image for the pull tests) yes
lint black --check, isort --check, flake8, mypy, bandit yes
audit pip-audit on the pinned runtime deps no — allow_failure: true, so a new upstream advisory shows a visible warning on every pipeline without blocking an unrelated merge. Flip it to false in .gitlab-ci.yml for a hard gate.

One pipeline runs per change: a merge-request pipeline while an MR is open, a branch pipeline otherwise — never both for the same commit.

GitLab settings that enforce this

All under the project's Settings on GitLab. These turn the workflow from prose into mechanics:

  • Merge requests → Merge checks → "Pipelines must succeed" — the merge button refuses a red pipeline.
  • Merge requests → Merge method → "Merge commit" — keeps the --no-ff grouping.
  • Merge requests → uncheck "Enable 'Delete source branch' option by default" — new MRs start with the box empty, so dev cannot be deleted by a reflexive click.
  • Repository → Protected branches → main: Allowed to push: No one; Allowed to merge: Maintainers — nobody, including the owner and any agent with push access, can commit to main directly.

Scope notes

  • Two long-lived branches is the whole model. Feature branches off dev are not used; if two unrelated changes are ever in flight at once, that is the moment to add short-lived branches that MR into dev — not before.
  • Nothing merges on a schedule and nothing automerges. The human pressing the merge button, with a green pipeline and the diff read, is the release process.