>_ IzzyLab

Hands-on task

This task is step 2 of the course “CI/CD: pipelines and docker compose”

pre-commit config

medium~10 min

Write /root/.pre-commit-config.yaml with one hook repository and at least one hook (structure repos: [{repo, rev, hooks: [{id}]}]). The file must be valid YAML. Write it in the Editor tab: it highlights YAML and broken indentation.

What you'll practise:
  • pre-commit
  • yaml config
  • repos and hooks
  • rev pinning
  • git hooks

Topic breakdown

pre-commit runs checks (linters, formatters) before a commit, and .pre-commit-config.yaml describes where to get them. The top level is a repos: list, where each element is an object with repo (the hook source — a URL or local), rev (a tag/commit for reproducibility, so the config doesn't one day quietly pull a different version) and hooks — a list of specific checks. Each hook requires an id; a common beginner mistake is to move hooks: to the top level instead of nesting it inside a repos element.

What's checked

  1. YAML is valid
  2. Hook with id declared

What it looks like