Commit 581bc2f3 authored by aparcar's avatar aparcar
Browse files

build: add ci-formal-checks and ci



This does some basic formal testing, just like done for packages.git.
Developers can test their commits locally by running `make
ci-formal-checks`. If working on another branch than `master`, add
`BRANCH=<branch>`. Later compiling of device tree files, checking kmods
or other more specific tests could be done. However this is a first step
to CI.
Signed-off-by: aparcar's avatarPaul Spooren <mail@aparcar.org>
parent d616b2c9
Pipeline #209 failed with stage
in 2 minutes and 26 seconds
version: 2.0
jobs:
build:
environment:
- BRANCH: "master"
steps:
- checkout:
- run:
name: Check changes / verify commits
command: make ci-formal-checks
workflows:
version: 2
buildpr:
jobs:
- build:
filters:
branches:
ignore: master
image: openwrtorg/sdk
formal:
stage: test
variables:
BRANCH: "master"
script:
- make ci-formal-checks
......@@ -93,6 +93,10 @@ diffconfig: FORCE
mkdir -p $(BIN_DIR)
$(SCRIPT_DIR)/diffconfig.sh > $(BIN_DIR)/config.seed
ci-formal-checks:
export BRANCH
$(SCRIPT_DIR)/ci-formal-checks.sh
prepare: .config $(tools/stamp-compile) $(toolchain/stamp-compile)
$(_SINGLE)$(SUBMAKE) -r diffconfig
......
#!/usr/bin/env bash
BRANCH="${BRANCH:-master}"
echo_red() { printf "\033[1;31m$*\033[m\n"; }
echo_green() { printf "\033[1;32m$*\033[m\n"; }
echo_blue() { printf "\033[1;34m$*\033[m\n"; }
RET=0
for commit in $(git rev-list HEAD ^origin/$BRANCH); do
echo_blue "=== Checking commit '$commit'"
if git show --format='%P' -s $commit | grep -qF ' '; then
echo_red "Pull request should not include merge commits"
RET=1
fi
author="$(git show -s --format=%aN $commit)"
if echo $author | grep -q '\S\+\s\+\S\+'; then
echo_green "Author name ($author) seems ok"
else
echo_red "Author name ($author) need to be your real name 'firstname lastname'"
RET=1
fi
subject="$(git show -s --format=%s $commit)"
if echo "$subject" | grep -q -e '^[0-9A-Za-z,+/_-]\+: ' -e '^Revert '; then
echo_green "Commit subject line seems ok ($subject)"
else
echo_red "Commit subject line MUST start with '<area>: ' ($subject)"
RET=1
fi
body="$(git show -s --format=%b $commit)"
sob="$(git show -s --format='Signed-off-by: %aN <%aE>' $commit)"
if echo "$body" | grep -qF "$sob"; then
echo_green "Signed-off-by match author"
else
echo_red "Signed-off-by is missing or doesn't match author (should be '$sob')"
RET=1
fi
done
exit $RET
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment