Skip to content

Draft: Upgrade GitLab CI Procedures

Daniel Tang requested to merge dtang__gitlab_ci into spiir-O4-EW-development

This merge requests implements #41 (closed).

We use pre-commit to automatically format our code-base before any git commits are made client-side, i.e. on the developer's working environment and not on the remote Git repository (such as GitLab or GitHub). This has the benefit of quickly catching developer errors, ensuring that all code complies with shared standards across the repository, and minimising excessive commit history focused specifically on auto-formatting (server-side hooks are possible but may introduce an additional commit as the developer would have to first commit before pushing).

To do the initial setup, activate your installed Python virtual environment and run the following commands:

# pip install pre-commit  # this is already in requirements.txt, and so not required
pre-commit install
pre-commit run --all-files  # by default pre-commit only runs on git staged files

When a git commit command is called after staging files, pre-commit will be run before the commit is finalised. If the pre-commit checks fail, the commit will be aborted. Additionally, if any changes ARE made to your files according to the rules configured in .pre-commit-config.yaml, files will need to be re-staged as they would have been modified since the initial file staging procedure (git add).

See the documentation at pre-commit for more information, and this page describing client-side and server-side git hooks more generally.

Edited by Daniel Tang

Merge request reports

Loading