Skip to content
Snippets Groups Projects
Unverified Commit e8e068ba authored by Lars Bilke's avatar Lars Bilke
Browse files

feat: add isort job


Signed-off-by: default avatarLars Bilke <lars.bilke@ufz.de>
parent 054b0403
No related branches found
No related tags found
No related merge requests found
......@@ -274,6 +274,15 @@ This job **disabled by default** and runs [black](https://black.readthedocs.io)
| ---------------- | ----------------------------------------------------------------------- | ----------------- |
| `black-enabled` / `PYTHON_BLACK_ENABLED` | Set to `true` to enable black job | _none_ (disabled) |
### `py-isort` job
This job **disabled by default** and runs [isort](https://pycqa.github.io/isort/) on the repo. It is bound to the build stage.
| Input / Variable | Description | Default value |
| ---------------- | ----------------------------------------------------------------------- | ----------------- |
| `isort-enabled` / `PYTHON_ISORT_ENABLED` | Set to `true` to enable isort job | _none_ (disabled) |
### SonarQube analysis
If you're using the SonarQube template to analyse your Python code, here is a sample `sonar-project.properties` file:
......
......@@ -246,6 +246,12 @@
"name": "black",
"description": "Code formatting based on [black](https://black.readthedocs.io)",
"enable_with": "PYTHON_BLACK_ENABLED"
},
{
"id": "isort",
"name": "isort",
"description": "Check imports order with [isort](https://pycqa.github.io/isort)",
"enable_with": "PYTHON_ISORT_ENABLED"
}
],
"variants": [
......
......@@ -151,6 +151,10 @@ spec:
description: Enable black
type: boolean
default: false
isort-enabled:
description: Enable isort
type: boolean
default: false
---
# default workflow rules: Merge Request pipelines
workflow:
......@@ -265,6 +269,7 @@ variables:
PYTHON_RELEASE_ENABLED: $[[ inputs.release-enabled ]]
PYTHON_BLACK_ENABLED: $[[ inputs.black-enabled ]]
PYTHON_ISORT_ENABLED: $[[ inputs.isort-enabled ]]
.python-scripts: &python-scripts |
......@@ -879,6 +884,19 @@ py-black:
when: never
- !reference [.test-policy, rules]
py-isort:
extends: .python-base
stage: build
script:
- install_requirements
- _pip install isort
- _run isort . --check-only
rules:
# exclude if $PYTHON_ISORT_ENABLED not set
- if: '$PYTHON_ISORT_ENABLED != "true"'
when: never
- !reference [.test-policy, rules]
###############################################################################################
# test stage #
###############################################################################################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment