Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
445
Issues
445
List
Boards
Labels
Service Desk
Milestones
Merge Requests
71
Merge Requests
71
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ISC Open Source Projects
Kea
Commits
8bc8f787
Commit
8bc8f787
authored
Jun 14, 2019
by
Michal Nowikowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[
#672
] added danger for checking commits compliance
parent
67779410
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
5 deletions
+61
-5
.gitlab-ci.yml
.gitlab-ci.yml
+19
-5
Dangerfile
Dangerfile
+42
-0
No files found.
.gitlab-ci.yml
View file @
8bc8f787
variables
:
# Not normally needed, but may be if some script uses `apt-get install`.
DEBIAN_FRONTEND
:
noninteractive
# Locale settings do not affect the build, but might affect tests.
# Locale settings do not affect the build, but might affect tests.
LC_ALL
:
C
CI_REGISTRY_IMAGE
:
registry.gitlab.isc.org/isc-projects/images/bind9
# Disabled warnings:
# SC2039 - complains about local var: In POSIX sh, 'local' is undefined.
# Disabled warnings:
# SC2039 - complains about local var: In POSIX sh, 'local' is undefined.
SHELLCHECK_OPTS
:
"
--exclude=SC2039"
stages
:
...
...
@@ -19,6 +17,7 @@ shellcheck:
stage
:
test
image
:
"
$CI_REGISTRY_IMAGE:debian-stretch-amd64"
before_script
:
-
sudo apt-get update
-
sudo apt-get -y install shellcheck
script
:
-
SCRIPTS="src/bin/keactrl/keactrl.in "
...
...
@@ -27,3 +26,18 @@ shellcheck:
-
SCRIPTS+="tools/cql_config "
-
SCRIPTS+="tools/sysrepo_config "
-
shellcheck ${SCRIPTS} ${SHELLCHECK_OPTS}
danger
:
stage
:
test
image
:
registry.gitlab.isc.org/isc-projects/stork/ci-danger
before_script
:
-
export CI_MERGE_REQUEST_ID=$(git ls-remote -q origin merge-requests\*\head | grep $CI_COMMIT_SHA | sed 's/.*refs\/merge-requests\/\([0-9]*\)\/head/\1/g')
-
export CI_PROJECT_PATH=$CI_PROJECT_ID
#some version of gitlab has problems with searching by project path
-
export DANGER_GITLAB_HOST=gitlab.isc.org
-
export DANGER_GITLAB_API_BASE_URL=https://gitlab.isc.org/api/v4
-
sysctl -w net.ipv6.conf.all.disable_ipv6=1
-
sysctl -w net.ipv6.conf.default.disable_ipv6=1
script
:
-
echo '149.20.48.126 gitlab.isc.org' >> /etc/hosts
-
gem install danger-commit_lint
-
danger --fail-on-errors=true --new-comment
Dangerfile
0 → 100644
View file @
8bc8f787
fail
"Please provide a summary in the Merge Request description to help your colleagues to understand the MR purpose."
if
gitlab
.
mr_body
.
length
<
5
if
git
.
modified_files
.
include?
"Dangerfile"
warn
"This MR modifies Dangerfile! Watch for the rules!"
end
# Checking MR size
if
not
gitlab
.
mr_body
.
include?
(
"#huge-sorry"
)
warn
(
"Split the MR into separate ones. It's really big."
)
if
git
.
lines_of_code
>
3000
fail
(
"Do not submit MRs over 5000 lines of code."
)
if
git
.
lines_of_code
>
5000
end
# Note when MRs don't reference a milestone, make the warning stick around on subsequent runs
has_milestone
=
gitlab
.
mr_json
[
"milestone"
]
!=
nil
warn
(
"This MR does not refer to an existing milestone"
,
sticky:
true
)
unless
has_milestone
# check commits' comments
commit_lint
.
check
warn: :all
# check gitlab issue in commit message
git
.
commits
.
each
do
|
c
|
m
=
c
.
message
.
match
(
/^\[\#(\d+)\]\ (.*)/
)
if
not
m
warn
"No GitLab issue in commit message:
#{
c
}
"
gl_issue_msg
=
nil
else
gl_issue_msg
=
m
.
captures
[
0
]
end
mr_branch
=
gitlab
.
branch_for_head
m
=
mr_branch
.
match
(
/^(\d+).*/
)
if
not
m
warn
"Branch name does not start with GitLab issue:
#{
mr_branch
}
"
gl_issue_br
=
nil
else
gl_issue_br
=
m
.
captures
[
0
]
end
if
gl_issue_msg
and
gl_issue_br
and
gl_issue_msg
!=
gl_issue_br
warn
"GitLab issue #
#{
gl_issue_msg
}
in msg of commit
#{
c
}
and issue #
#{
gl_issue_br
}
from branch
#{
mr_branch
}
do not match"
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment