Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Add gitlint #590

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/compliance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Compliance

on: pull_request

jobs:
check-gitlint:
name: Run gitlint
runs-on: ubuntu-20.04

steps:
- name: Checkout code including full history
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Install gitlint
run: |
pip3 install gitlint

- name: Check commits with checkpatch
run: |
git branch -a
tools/ci/run_ci.sh --branch-target origin/${{ github.base_ref }} --run-gitlint
12 changes: 12 additions & 0 deletions .gitlint
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[general]
ignore-fixup-commits=false

[title-must-not-contain-word]
words=wip,fixup

# Enforce at least 20 characters (default value) in every commit body
[body-min-length]

# Tags do not count towards the body length
[ignore-body-lines]
regex=^Signed-off-by
34 changes: 34 additions & 0 deletions tools/ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ readonly REPO_ROOT_DIR="${PWD}"
readonly SCRIPT_NAME="$(basename "$0")"

CMAKE_ARGS="-DCMAKE_BUILD_TYPE=RelWithDebInfo"
OPT_BRANCH_SOURCE=
OPT_BRANCH_TARGET=master
OPT_C_EXTENSIONS=""
OPT_C_STANDARD=""
OPT_SANITIZER=""
Expand All @@ -30,13 +32,18 @@ OPT_VERBOSE=0
OPT_WRAPPER_CMD=""
RUN_BUILD=0
RUN_CLEAN=0
RUN_GITLINT=0
RUN_TESTS=0

HELP_MSG="usage: ${SCRIPT_NAME} <OPTIONS>...
Runs build and test steps in CI.
Select steps to execute with --run- options

Options:
--branch-source BRANCH Source branch for MRs
(default: current branch)
--branch-target BRANCH Target branch for MRs
(default: $OPT_BRANCH_TARGET)
--c-extensions ENABLE Whether to allow compiler extensions. Defaults to
ON.
(ENABLE: ON or OFF)
Expand All @@ -56,6 +63,7 @@ Options:
-h, --help Display this help and exit

Available steps (executed by --all):
--run-gitlint Check git commits with gitlint
--run-clean Remove all build artifacts
--run-build Build all targets
--run-tests Build and execute tests
Expand All @@ -72,6 +80,12 @@ function run_clean() {
rm -rf build-wakaama
}

function run_gitlint() {
commits="${OPT_BRANCH_TARGET}...${OPT_BRANCH_SOURCE}"

gitlint --commits "${commits}"
}

function run_build() {
# Existing directory needed by SonarQube build-wrapper
mkdir -p build-wakaama
Expand Down Expand Up @@ -135,11 +149,14 @@ fi

if ! PARSED_OPTS=$(getopt -o vah \
-l all \
-l branch-source: \
-l branch-target: \
-l c-extensions: \
-l c-standard: \
-l help \
-l run-build \
-l run-clean \
-l run-gitlint \
-l run-tests \
-l sanitizer: \
-l scan-build: \
Expand All @@ -155,6 +172,14 @@ eval set -- "${PARSED_OPTS}"

while true; do
case "$1" in
--branch-source)
OPT_BRANCH_SOURCE=$2
shift 2
;;
--branch-target)
OPT_BRANCH_TARGET=$2
shift 2
;;
--c-extensions)
OPT_C_EXTENSIONS=$2
shift 2
Expand All @@ -171,6 +196,10 @@ while true; do
RUN_BUILD=1
shift 1
;;
--run-gitlint)
RUN_GITLINT=1
shift
;;
--run-tests)
RUN_TESTS=1
shift
Expand Down Expand Up @@ -205,6 +234,7 @@ while true; do
;;
-a|--all)
RUN_CLEAN=1
RUN_GITLINT=1
RUN_BUILD=1
RUN_TESTS=1
shift
Expand Down Expand Up @@ -262,6 +292,10 @@ fi

# Run Steps

if [[ $RUN_GITLINT == 1 ]]; then
run_gitlint
fi

if [ "${RUN_CLEAN}" -eq 1 ]; then
run_clean
fi
Expand Down