Commit c7c20c4b authored by Philip Chimento's avatar Philip Chimento 🚮

Merge branch 'tweaks' into 'master'

More tweaks

See merge request !136
parents b27223ba 417be665
Pipeline #10722 passed with stages
in 43 minutes and 24 seconds
......@@ -17,10 +17,7 @@ stages:
- $(pwd)/.cache/jhbuild/build/gjs/Makefile
- $(pwd)/.cache/jhbuild/build/gjs/configure
- $(pwd)/coverage/
- $(pwd)/cppcheck/
- $(pwd)/cpplint/
- $(pwd)/eslint/
- $(pwd)/tokei/
- $(pwd)/analysis/
- $(pwd)/gjs-1.*/_build/sub/test-suite.log
- $(pwd)/*.log
- $(pwd)/Makefile
......@@ -36,36 +33,44 @@ stages:
echo;
'
# Run static code analysis OR
# Build dependencies and 'make' gjs
# GitLab is keeping some files between jobs. Remove them.
- rm -rf configure Makefile *.log analysis
# Run static code analysis OR
# Build GJS
- 'if [[ -n "${CODECHECK}" ]]; then
$(pwd)/test/test-ci.sh "$CODECHECK";
else
$(pwd)/test/test-ci.sh GJS;
fi'
fi
'
# Run extra tests
# Run installed extra tests
- 'if [[ $BUILD_OPTS == *"--enable-installed-tests"* ]]; then
$(pwd)/test/test-ci.sh GJS_EXTRA;
fi'
fi
'
# Run code coverage tests
- 'if [[ $BUILD_OPTS == *"--enable-code-coverage"* ]]; then
$(pwd)/test/test-ci.sh GJS_COVERAGE;
fi'
fi
'
# Run valgrind
- 'if [[ $BUILD_OPTS == *"--enable-valgrind"* ]]; then
$(pwd)/test/test-ci.sh VALGRIND;
fi'
fi
'
- 'echo;
echo "*********************************************";
echo "*** See you soon ***";
echo "*********************************************";
'
#############################################
# Able to test despite of any Docker image changes
# Run a test despite of any Docker image change
#############################################
fedora:
<<: *build
......
#!/bin/bash -e
function do_Print_Labels(){
if [[ -n "${1}" ]]; then
label_len=${#1}
span=$(((54 - $label_len) / 2))
echo
echo "= ======================================================== ="
printf "%s %${span}s %s %${span}s %s\n" "=" "" "$1" "" "="
echo "= ======================================================== ="
else
echo "= ========================= Done ========================= ="
echo
fi
}
function do_Set_Env(){
echo
echo '-- Set Environment --'
do_Print_Labels 'Set Environment '
#Save cache on $pwd (required by artifacts)
mkdir -p "$(pwd)"/.cache
......@@ -24,18 +40,18 @@ function do_Set_Env(){
export DISPLAY=":0"
fi
echo '-- Done --'
do_Print_Labels
}
function do_Done(){
# Done. De-initializes whatever is needed
echo
echo '-- FINISHED --'
do_Print_Labels 'FINISHED'
}
function do_Build_Package_Dependencies(){
echo
echo "-- Building Dependencies for $1 --"
do_Print_Labels "Building Dependencies for $1"
jhbuild list "$1"
# Build package dependencies
......@@ -44,29 +60,29 @@ function do_Build_Package_Dependencies(){
function do_Show_Info(){
echo '--------------------------------'
echo '-----------------------------------------'
echo 'Useful build system information'
echo -n "Processors: "; grep -c ^processor /proc/cpuinfo
grep ^MemTotal /proc/meminfo
id; uname -a
printenv
echo '--------------------------------'
echo '-----------------------------------------'
cat /etc/*-release
echo '--------------------------------'
echo '-----------------------------------------'
if [[ ! -z $CC ]]; then
echo 'Compiler version'
$CC --version
echo '--------------------------------'
echo '-----------------------------------------'
$CC -dM -E -x c /dev/null
echo '--------------------------------'
echo '-----------------------------------------'
fi
}
function do_Get_Upstream_Master(){
if [[ "$CI_BUILD_REF_SLUG" == "master" && "$CI_PROJECT_PATH_SLUG" == "gnome-gjs" ]]; then
echo '--------------------------------'
echo '-----------------------------------------'
echo 'Running against upstream master'
echo "=> $1 Nothing to do"
......@@ -74,17 +90,17 @@ function do_Get_Upstream_Master(){
exit 0
fi
echo '--------------------------------'
echo '-----------------------------------------'
echo 'Cloning upstream master'
mkdir -p ~/tmp-upstream; cd ~/tmp-upstream || exit 1
git clone --depth 1 https://gitlab.gnome.org/GNOME/gjs.git; cd gjs || exit 1
echo '--------------------------------'
echo '-----------------------------------------'
}
function do_Compare_With_Upstream_Master(){
echo '--------------------------------'
echo '-----------------------------------------'
echo 'Compare the working code with upstream master'
NEW_WARNINGS=$(comm -13 <(sort < /cwd/master-report.txt) <(sort < /cwd/current-report.txt) | wc -l)
......@@ -102,12 +118,30 @@ function do_Compare_With_Upstream_Master(){
fi
}
function do_Create_Artifacts_Folder(){
# Create the artifacts folders
save_dir="$(pwd)"
if [[ $1 == "GJS_COVERAGE" ]]; then
mkdir -p "$save_dir"/coverage; touch "$save_dir"/coverage/doing-"$1"
fi
mkdir -p "$save_dir"/analysis; touch "$save_dir"/analysis/doing-"$1"
}
function do_Get_Commit_Message(){
# Allow CI to skip jobs. Its goal is to simplify housekeeping.
# Disable tasks using the commit message. Possibilities are (and/or):
# [skip eslint] [skip cpplint] [skip cppcheck]
#
# Just add the "code" anywhere inside the commit message.
log_message=$(git log -n 1)
}
function do_Check_Warnings(){
echo '-----------------------------------------'
cat compilation.log | grep "warning:" | awk '{total+=1}END{print "Total number of warnings: "total}'
echo '-----------------------------------------'
}
# ----------- Run the Tests -----------
......@@ -123,18 +157,8 @@ echo "Doing: $1"
source test/extra/do_jhbuild.sh
# Create the artifacts folders
save_dir="$(pwd)"
mkdir -p "$save_dir"/coverage; touch "$save_dir"/coverage/doing-"$1"
mkdir -p "$save_dir"/cppcheck; touch "$save_dir"/cppcheck/doing-"$1"
mkdir -p "$save_dir"/cpplint; touch "$save_dir"/cpplint/doing-"$1"
mkdir -p "$save_dir"/eslint; touch "$save_dir"/eslint/doing-"$1"
mkdir -p "$save_dir"/tokei; touch "$save_dir"/tokei/doing-"$1"
# Allow CI to skip jobs. Its goal is to simplify housekeeping.
# Disable tasks using the commit message. Possibilities are (and/or):
# [skip eslint] [skip cpplint] [skip cppcheck]
log_message=$(git log -n 1)
do_Create_Artifacts_Folder "$1"
do_Get_Commit_Message
if [[ $1 == "GJS" ]]; then
do_Set_Env
......@@ -153,13 +177,10 @@ if [[ $1 == "GJS" ]]; then
# Build and test the latest commit (merged or from a merge/pull request) of
# Javascript Bindings for GNOME (gjs)
echo
echo '-- gjs status --'
do_Print_Labels 'Show GJS git information'
git log --pretty=format:"%h %cd %s" -1
echo
echo '-- gjs build --'
echo
do_Print_Labels 'Do the GJS build'
if [[ "$DEV" != "devel" ]]; then
cp -r ./ ~/jhbuild/checkout/gjs
......@@ -184,17 +205,15 @@ if [[ $1 == "GJS" ]]; then
fi
if [[ $WARNINGS == "count" ]]; then
echo
echo '-- Warnings Report --'
do_Print_Labels 'Warnings Report '
do_Check_Warnings
do_Print_Labels
fi
elif [[ $1 == "GJS_EXTRA" ]]; then
# Extra testing. It doesn't (re)build, just run the 'Installed Tests'
echo
echo '-- Installed GJS tests --'
# It doesn't (re)build, just run the 'Installed Tests'
do_Print_Labels 'Run GJS installed tests'
do_Set_Env
PATH=$PATH:~/.local/bin
if [[ "$DEV" != "devel" ]]; then
xvfb-run -a --server-args="-screen 0 1024x768x24" jhbuild run dbus-run-session -- gnome-desktop-testing-runner gjs
......@@ -203,80 +222,76 @@ elif [[ $1 == "GJS_EXTRA" ]]; then
fi
elif [[ $1 == "VALGRIND" ]]; then
# Run Valgrind. It doesn't (re)build, just run the 'Valgrind Tests'
echo
echo '-- Valgrind Report --'
# It doesn't (re)build, just run the 'Valgrind Tests'
do_Print_Labels 'Valgrind Report'
do_Set_Env
PATH=$PATH:~/.local/bin
make check-valgrind
elif [[ $1 == "GJS_COVERAGE" ]]; then
# Code coverage test. It doesn't (re)build, just run the 'Coverage Tests'
echo
echo '-- Code Coverage Report --'
# It doesn't (re)build, just run the 'Coverage Tests'
do_Print_Labels 'Code Coverage Report'
do_Set_Env
PATH=$PATH:~/.local/bin
jhbuild run --in-builddir=gjs make check-code-coverage
cp "$(pwd)"/.cache/jhbuild/build/gjs/gjs-?.*.*-coverage.info "$save_dir"/coverage/
cp -r "$(pwd)"/.cache/jhbuild/build/gjs/gjs-?.*.*-coverage/* "$save_dir"/coverage/
echo '-----------------------------------------------------------------'
echo '-----------------------------------------'
sed -e 's/<[^>]*>//g' "$(pwd)"/coverage/index.html | tr -d ' \t' | grep -A3 -P '^Lines:$' | tr '\n' ' '; echo
echo '-----------------------------------------------------------------'
echo '-----------------------------------------'
elif [[ $1 == "CPPCHECK" && "$log_message" != *'[skip cppcheck]'* ]]; then
echo
echo '-- Static code analyzer report --'
do_Print_Labels 'Static code analyzer report '
cppcheck --inline-suppr --enable=warning,performance,portability,information,missingInclude --force -q . 2>&1 | \
tee "$save_dir"/cppcheck/current-report.txt | sed -E 's/:[0-9]+]/:LINE]/' > /cwd/current-report.txt
cat "$save_dir"/cppcheck/current-report.txt
tee "$save_dir"/analysis/current-report.txt | sed -E 's/:[0-9]+]/:LINE]/' > /cwd/current-report.txt
cat "$save_dir"/analysis/current-report.txt
echo
# Get the code committed at upstream master
do_Get_Upstream_Master "cppCheck"
cppcheck --inline-suppr --enable=warning,performance,portability,information,missingInclude --force -q . 2>&1 | \
tee "$save_dir"/cppcheck/master-report.txt | sed -E 's/:[0-9]+]/:LINE]/' > /cwd/master-report.txt
tee "$save_dir"/analysis/master-report.txt | sed -E 's/:[0-9]+]/:LINE]/' > /cwd/master-report.txt
echo
# Compare the report with master and fail if new warnings are found
do_Compare_With_Upstream_Master "cppCheck"
elif [[ $1 == "CPPLINT" && "$log_message" != *'[skip cpplint]'* ]]; then
echo
echo '-- Lint report --'
do_Print_Labels 'C/C++ Linter report '
cpplint --quiet $(find . -name \*.cpp -or -name \*.c -or -name \*.h | sort) 2>&1 | \
tee "$save_dir"/cpplint/current-report.txt | sed -E 's/:[0-9]+:/:LINE:/' > /cwd/current-report.txt
cat "$save_dir"/cpplint/current-report.txt
tee "$save_dir"/analysis/current-report.txt | sed -E 's/:[0-9]+:/:LINE:/' > /cwd/current-report.txt
cat "$save_dir"/analysis/current-report.txt
echo
# Get the code committed at upstream master
do_Get_Upstream_Master "cppLint"
cpplint --quiet $(find . -name \*.cpp -or -name \*.c -or -name \*.h | sort) 2>&1 | \
tee "$save_dir"/cpplint/master-report.txt | sed -E 's/:[0-9]+:/:LINE:/' > /cwd/master-report.txt
tee "$save_dir"/analysis/master-report.txt | sed -E 's/:[0-9]+:/:LINE:/' > /cwd/master-report.txt
echo
# Compare the report with master and fail if new warnings are found
do_Compare_With_Upstream_Master "cppLint"
elif [[ $1 == "ESLINT" && "$log_message" != *'[skip eslint]'* ]]; then
do_Print_Labels 'Javascript Linter report'
tmp_path=$(dirname "$CI_PROJECT_DIR")
echo
echo '-- Javascript linter report --'
eslint examples installed-tests modules --format unix 2>&1 | \
tee "$save_dir"/eslint/current-report.txt | \
tee "$save_dir"/analysis/current-report.txt | \
sed -E -e 's/:[0-9]+:[0-9]+:/:LINE:COL:/' -e 's/[0-9]+ problems//' -e 's/\/root\/tmp-upstream//' -e "s,$tmp_path,," \
> /cwd/current-report.txt
cat "$save_dir"/eslint/current-report.txt
cat "$save_dir"/analysis/current-report.txt
echo
# Get the code committed at upstream master
do_Get_Upstream_Master "esLint"
cp "$save_dir"/.eslint* .
eslint examples installed-tests modules --format unix 2>&1 | \
tee "$save_dir"/eslint/master-report.txt | \
tee "$save_dir"/analysis/master-report.txt | \
sed -E -e 's/:[0-9]+:[0-9]+:/:LINE:COL:/' -e 's/[0-9]+ problems//' -e 's/\/root\/tmp-upstream//' -e "s,$tmp_path,," \
> /cwd/master-report.txt
echo
......@@ -285,11 +300,9 @@ elif [[ $1 == "ESLINT" && "$log_message" != *'[skip eslint]'* ]]; then
do_Compare_With_Upstream_Master "esLint"
elif [[ $1 == "TOKEI" ]]; then
echo
echo '-- Project statistics --'
echo
do_Print_Labels 'Project statistics'
tokei . | tee "$save_dir"/tokei/report.txt
tokei . | tee "$save_dir"/analysis/report.txt
fi
# Releases stuff and finishes
......
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