mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
ci: Add a job to verify commit messages on MRs
This uses [gitlint] and is based on their linting rules with some minor config so it matches our style pretty well. [gitlint]: https://jorisroovers.com/gitlint/#configuration Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3980>
This commit is contained in:
parent
fb076db1b2
commit
5586511446
5 changed files with 61 additions and 0 deletions
|
@ -34,6 +34,7 @@ variables:
|
|||
|
||||
FEDORA_AMD64_SUFFIX: 'amd64/fedora'
|
||||
INDENT_AMD64_SUFFIX: 'amd64/gst-indent'
|
||||
COMMITLINT_AMD64_SUFFIX: 'amd64/commitlint'
|
||||
WINDOWS_AMD64_SUFFIX: 'amd64/windows'
|
||||
|
||||
WINDOWS_IMAGE: "$CI_REGISTRY_IMAGE/$WINDOWS_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH"
|
||||
|
@ -154,6 +155,22 @@ gst-indent amd64 docker:
|
|||
# Do not depend on the trigger, as we want to run indent always
|
||||
needs: []
|
||||
|
||||
.commitlint image:
|
||||
variables:
|
||||
FDO_DISTRIBUTION_VERSION: '37'
|
||||
FDO_REPO_SUFFIX: "$COMMITLINT_AMD64_SUFFIX"
|
||||
FDO_DISTRIBUTION_TAG: "$LINT_TAG-$GST_UPSTREAM_BRANCH"
|
||||
FDO_DISTRIBUTION_PACKAGES: 'python3-pip git'
|
||||
FDO_DISTRIBUTION_EXEC: 'ci/docker/lint/prepare.sh'
|
||||
|
||||
commitlint docker:
|
||||
extends:
|
||||
- '.commitlint image'
|
||||
- '.fdo.container-build@fedora'
|
||||
stage: 'preparation'
|
||||
# Do not depend on the trigger, as we want to run indent always
|
||||
needs: []
|
||||
|
||||
windows amd64 docker:
|
||||
stage: "preparation"
|
||||
needs:
|
||||
|
@ -205,6 +222,25 @@ gst indent:
|
|||
- if: '$CI_PROJECT_NAMESPACE != "gstreamer" || $CI_COMMIT_BRANCH != $GST_UPSTREAM_BRANCH'
|
||||
when: 'always'
|
||||
|
||||
commitlint:
|
||||
extends:
|
||||
- '.commitlint image'
|
||||
- '.fdo.suffixed-image@fedora'
|
||||
stage: 'preparation'
|
||||
variables:
|
||||
GIT_STRATEGY: fetch
|
||||
GIT_DEPTH: 100
|
||||
needs:
|
||||
- job: 'commitlint docker'
|
||||
artifacts: false
|
||||
script:
|
||||
- echo $CI_MERGE_REQUEST_DIFF_BASE_SHA
|
||||
- gitlint --commits $CI_MERGE_REQUEST_DIFF_BASE_SHA..HEAD
|
||||
rules:
|
||||
# Only run on MR as we need CI_MERGE_REQUEST_DIFF_BASE_SHA to know
|
||||
# what commits to check
|
||||
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
||||
|
||||
#
|
||||
# build setup templates
|
||||
#
|
||||
|
|
|
@ -7,4 +7,5 @@ variables:
|
|||
###
|
||||
FEDORA_TAG: '2022-12-10.0'
|
||||
INDENT_TAG: '2022-03-07.1'
|
||||
LINT_TAG: '2023-02-16.5'
|
||||
WINDOWS_TAG: '2023-01-26.0'
|
||||
|
|
12
.gitlint
Normal file
12
.gitlint
Normal file
|
@ -0,0 +1,12 @@
|
|||
[title-max-length]
|
||||
line-length=100
|
||||
|
||||
[general]
|
||||
ignore=body-is-missing
|
||||
|
||||
[body-max-line-length]
|
||||
line-length=120
|
||||
|
||||
# Ensure every title starts with a prefix
|
||||
[title-match-regex]
|
||||
regex=^\w+:.*
|
4
ci/docker/lint/prepare.sh
Executable file
4
ci/docker/lint/prepare.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
set -eux
|
||||
|
||||
python3 -m pip install gitlint
|
||||
|
|
@ -33,6 +33,14 @@ endif
|
|||
# Install gst-indent pre-commit hook
|
||||
run_command(python3, '-c', 'import shutil; shutil.copy("scripts/git-hooks/multi-pre-commit.hook", ".git/hooks/pre-commit")', check: false)
|
||||
|
||||
|
||||
gitlint = find_program('gitlint', required: false)
|
||||
if gitlint.found()
|
||||
run_command(gitlint, 'install-hook', check: false)
|
||||
else
|
||||
message('gitlint not found, please install it with your package manager or `python3 -m pip install gitlint` to enable the commit message hook')
|
||||
endif
|
||||
|
||||
# On macOS, you have to run "Install Certificates.command" otherwise Python
|
||||
# doesn't have access to the latest SSL CA Certificates, and Meson will fail to
|
||||
# download wrap files from websites that use, for example, Let's Encrypt.
|
||||
|
|
Loading…
Reference in a new issue