I have started a repository with pre-commit hooks for MPS, specificlanguages/pre-commit-hooks, designed for use with pre-commit or prek (preferred).
MPS pre-commit hooks are Python scripts that do not launch MPS but inspect files directly. This makes them complementary to MPS model checks. Hooks are much faster but they cannot check domain logic. Rather, they focus on checking the basic shape of the project for consistency.
For example, hooks can check for:
- zero-length XML files (caused by MPS misresolving deleted/modified conflicts),
- modules present in the repository but missing from the MPS project,
- modules present in the MPS project but missing on disk,
- modules present in the repository but not mentioned in any MPS build script,
- models present on disk but not mentioned in any model root (e.g. leftover generator models),
- modules whose file/directory name does not match their name in MPS,
- path variables used in
modules.xmlorlibraries.xml, - and so on.
I am currently setting up the mbeddr platform build to use them (see PR mbeddr/mbeddr.core#3466). On this repository they only take about a second or so to run, and detect many consistency issues that have accumulated over the years.
If you are interested in trying them out, install prek and add a .pre-commit-config.yaml to
your repository with this contents:
repos:
- repo: https://github.com/specificlanguages/mps-pre-commit-hooks
rev: v0.1.0
hooks:
- id: mps-check-orphan-modules
- id: mps-check-unbuilt-modules
- id: mps-check-missing-modules
- id: mps-check-orphan-models
- id: mps-check-orphan-mpsr-files
- id: mps-check-zero-sized-xmls
- id: mps-check-module-naming
- id: mps-check-path-variables
Then run prek install in the repository to have the hooks run on the files changed in a commit. If you want to run
hooks on all files, run prek run -a.