feat(python_linting): added ci job, python linting, code quality and scoring
Added a job to lint python files and ouput a code quality report for gitlab MR. A html report is also available within the artifacts. if the badge is used, the badge links to the html code quality report. Changes to be committed: modified: .gitlab-ci.yml new file: python/.gitlab-ci.yml new file: python/README.md new file: python/requirements.txt issue #1
This commit is contained in:
88
python/README.md
Normal file
88
python/README.md
Normal file
@ -0,0 +1,88 @@
|
||||
# Python
|
||||
This folder (`python`) covers jobs for python development
|
||||
|
||||
|
||||
These jobs provides the following badge:
|
||||
|
||||
- `PyLint` - code quality [](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/jobs/artifacts/development/file/artifacts/validation/tests/gl-code-quality-report.html?job=PyLint)
|
||||
|
||||
Use the following MD to add a badge adjusting the variables and ensuring everything is on one line.
|
||||
``` md
|
||||
[](https://gitlab.com/
|
||||
|
||||
{project path}
|
||||
|
||||
/-/jobs/artifacts/
|
||||
|
||||
{branch}
|
||||
|
||||
/file/
|
||||
|
||||
artifacts/validation/tests/gl-code-quality-report.html
|
||||
|
||||
?job=
|
||||
|
||||
{Job Name}
|
||||
)
|
||||
```
|
||||
| Variable | Description |
|
||||
|:----|:----|
|
||||
| `{project path}` | *project path, what's after gitlab.com/* |
|
||||
| `{branch}` | *git branch to fetch the score from* |
|
||||
| `{Job Name}` | *name of the gitlab-ci job for the linting* |
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
- None
|
||||
|
||||
## your .gitlab-ci.yml changes
|
||||
To add the `PyLint` job, add the following to your `.gitlab-ci.yml` file
|
||||
|
||||
``` yaml
|
||||
stages:
|
||||
- validation
|
||||
|
||||
include:
|
||||
- remote: https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/raw/master/python/.gitlab-ci.yml
|
||||
|
||||
PyLint:
|
||||
variables:
|
||||
PYLINT_PATH: "/*/*.py"
|
||||
extends:
|
||||
- .PyLint
|
||||
image: python:3.6-slim
|
||||
```
|
||||
|
||||
|
||||
## CI/CD Variables required
|
||||
|
||||
| var name | Description |
|
||||
|:----:|:----|
|
||||
| PYLINT_PATH | *The path you wish the linter to search for python files* |
|
||||
|
||||
|
||||
## Job Workflow
|
||||
|
||||
- This job will lint any yaml file in the specified directory using the specified rules.
|
||||
|
||||
## Artifacts
|
||||
|
||||
- `$CI_PROJECT_DIR/artifacts` - Root artifact directory
|
||||
- `$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/gl-code-quality-report.json` - Gitlab code quality report (displays in merge request)
|
||||
- `$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/gl-code-quality-report.html` - html code quality report
|
||||
|
||||
## License
|
||||
To view the license for this folder and any sub-folders, refer [here](https://gitlab.com/nofusscomputing/projects/gitlab-ci)
|
||||
Reference in New Issue
Block a user