Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SmartDataLab
public
CI-CD components
Python
Commits
054b0403
Unverified
Commit
054b0403
authored
1 year ago
by
Lars Bilke
Browse files
Options
Downloads
Patches
Plain Diff
feat: add black job
Signed-off-by:
Lars Bilke
<
lars.bilke@ufz.de
>
parent
507fb740
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+9
-2
9 additions, 2 deletions
README.md
kicker.json
+6
-0
6 additions, 0 deletions
kicker.json
templates/gitlab-ci-python.yml
+19
-0
19 additions, 0 deletions
templates/gitlab-ci-python.yml
with
34 additions
and
2 deletions
README.md
+
9
−
2
View file @
054b0403
...
...
@@ -4,7 +4,7 @@ This project implements a GitLab CI/CD template to build, test and analyse your
## Usage
This template can be used both as a
[
CI/CD component
](
https://docs.gitlab.com/ee/ci/components/#use-a-component-in-a-cicd-configuration
)
This template can be used both as a
[
CI/CD component
](
https://docs.gitlab.com/ee/ci/components/#use-a-component-in-a-cicd-configuration
)
or using the legacy
[
`include:project`
](
https://docs.gitlab.com/ee/ci/yaml/index.html#includeproject
)
syntax.
### Use as a CI/CD component
...
...
@@ -266,6 +266,14 @@ In addition to logs in the console, this job produces the following reports, kep
| -------------- | ---------------------------------------------------------------------------- | ----------------- |
|
`$PYTHON_PROJECT_DIR/reports/py-sbom.cyclonedx.json`
|
[
CycloneDX JSON
](
https://cyclonedx.org/docs/latest/json/
)
|
[
Security & Compliance integration
](
https://docs.gitlab.com/ee/ci/yaml/artifacts_reports.html#artifactsreportscyclonedx
)
|
### `py-black` job
This job
**disabled by default**
and runs
[
black
](
https://black.readthedocs.io
)
on the repo. It is bound to the build stage.
| Input / Variable | Description | Default value |
| ---------------- | ----------------------------------------------------------------------- | ----------------- |
|
`black-enabled`
/
`PYTHON_BLACK_ENABLED`
| Set to
`true`
to enable black 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:
...
...
@@ -413,7 +421,6 @@ variables:
PIP_EXTRA_INDEX_URL: "${CI_SERVER_PROTOCOL}://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}:${CI_SERVER_PORT}/api/v4/groups/<group-id>/-/packages/pypi/simple"
```
## Variants
The Python template can be used in conjunction with template variants to cover specific cases.
...
...
This diff is collapsed.
Click to expand it.
kicker.json
+
6
−
0
View file @
054b0403
...
...
@@ -240,6 +240,12 @@
"default"
:
"$CI_JOB_TOKEN"
}
]
},
{
"id"
:
"black"
,
"name"
:
"black"
,
"description"
:
"Code formatting based on [black](https://black.readthedocs.io)"
,
"enable_with"
:
"PYTHON_BLACK_ENABLED"
}
],
"variants"
:
[
...
...
This diff is collapsed.
Click to expand it.
templates/gitlab-ci-python.yml
+
19
−
0
View file @
054b0403
...
...
@@ -147,6 +147,10 @@ spec:
_defaults to [GitLab project's packages repository](https://docs.gitlab.com/ee/user/packages/pypi_repository/)_
default
:
${CI_SERVER_URL}/api/v4/projects/${CI_PROJECT_ID}/packages/pypi
black-enabled
:
description
:
Enable black
type
:
boolean
default
:
false
---
# default workflow rules: Merge Request pipelines
workflow
:
...
...
@@ -260,6 +264,8 @@ variables:
PYTHON_SBOM_DISABLED
:
$[[ inputs.sbom-disabled ]]
PYTHON_RELEASE_ENABLED
:
$[[ inputs.release-enabled ]]
PYTHON_BLACK_ENABLED
:
$[[ inputs.black-enabled ]]
.python-scripts
:
&python-scripts
|
# BEGSCRIPT
...
...
@@ -860,6 +866,19 @@ py-compile:
when
:
never
-
!reference
[
.test-policy
,
rules
]
py-black
:
extends
:
.python-base
stage
:
build
script
:
-
install_requirements
-
_pip install black
-
_run black . --check
rules
:
# exclude if $PYTHON_BLACK_ENABLED not set
-
if
:
'
$PYTHON_BLACK_ENABLED
!=
"true"'
when
:
never
-
!reference
[
.test-policy
,
rules
]
###############################################################################################
# test stage #
###############################################################################################
...
...
This diff is collapsed.
Click to expand it.
Benguria Elguezabal, Gorka
@gorka.benguria
mentioned in commit
b786f332
·
11 months ago
mentioned in commit
b786f332
mentioned in commit b786f3329e6c8295e8812b28e3419cc71876624a
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment