diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..d87e41c6aeac589c96685a045434e2e921897b0e --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,18 @@ +--- +# Using the official Python Docker image as default +image: python + +# Columns of the pipeline +stages: + - static analysis + +# Static code analysis job via MISS_HIT +static analysis: + stage: static analysis + before_script: + - pip install miss_hit + script: + - mh_style . --fix + - mh_metric . --ci + - mh_lint . + allow_failure: false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..822060b2bcf862090285a65529aee810310adf83 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,24 @@ +--- +repos: + - repo: local + hooks: + - id: mh_style + entry: mh_style + name: mh_style + args: [--process-slx, --fix] + files: ^(.*\.(m|slx))$ + language: python + additional_dependencies: [miss_hit_core] + - id: mh_metric + name: mh_metric + entry: mh_metric + args: [--ci] + files: ^(.*\.(m|slx))$ + language: python + additional_dependencies: [miss_hit_core] + - id: mh_lint + name: mh_lint + entry: mh_lint + files: ^(.*\.(m|slx))$ + language: python + additional_dependencies: [miss_hit] diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a6eb214914b5bfceaaf315fd4247015cbae568d..69e56b86eed4ef903afab4f7874b737d87f4aaa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Start using MISS_HIT for style and code analysis. +- ci: Add MISS_HIT job in pipeline +- ci: Add pre-commit hook for miss_hit ### Changed diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 941a97d017f3714c5954897c3561bc32b056cc50..3bdd25ea164ca0d7457655c6565cdfb244b2c816 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -140,6 +140,22 @@ errors. mh_lint . ``` +A more convenient way to use MISS_HIT is to include it in a pre-commit hook. +This can be done with [pre-commit][pre-commit-site]. To install both +dependencies just run: + +```bash +pip3 install -r requirements.txt +``` + +The install the pre-commit hooks using: + +```bash +pre-commit install +``` + +Now the three MISS_HIT checks will be run every time you make a commit. + #### Other Some other conventions can not be currently enforced by MISS_HIT. They should @@ -172,5 +188,6 @@ The following naming convention is adopted: 5. Ensure MISS_HIT is happy 6. Submit your Merge Request. +[pre-commit-site]: https://pre-commit.com/ [miss_hit]: https://github.com/florianschanda/miss_hit [miss_hit_cfg]: https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox/-/blob/master/miss_hit.cfgj:w diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..25b12e3eccf4a7c56f1cab3f8c89f9a0db1f5277 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +miss_hit +pre-commit