mirror of https://github.com/zeldaret/mm.git
Hopefully prevent misformatted files from ever entering master again. (#356)
* Added tools/check_format.sh. * Exit nonzero from format.sh if clang-format-11 not installed. * Replace which with command -v. * Fail check_format.sh if format.sh fails. * Improve Jenkinsfile. * Take exit 0 out of else in check_format.sh. * Format flg_set.c to test new Jenkins environment. * Fix formatter failed logic in check_format.sh. * Format all misformatted files in master. * Remove Summarize Problems stage from Jenkins. I didn't realize Jenkins would not a run a subsequent stage if a previous stage errored. This defeats the purpose of summarizing all problems at the end, since this will only happen if there *are* no problems. * Use Post->Failure block to print all logs instead. * Remove spurious semicolon in arms_hook.
This commit is contained in:
parent
ef53ba8261
commit
57a9fb7b34
|
@ -4,6 +4,12 @@ pipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
|
stage('Check formatting') {
|
||||||
|
steps {
|
||||||
|
echo 'Checking formatting...'
|
||||||
|
sh 'bash -c "tools/check_format.sh 2>&1 >(tee tools/check_format.txt)"'
|
||||||
|
}
|
||||||
|
}
|
||||||
stage('Copy ROM') {
|
stage('Copy ROM') {
|
||||||
steps {
|
steps {
|
||||||
echo 'Setting up ROM...'
|
echo 'Setting up ROM...'
|
||||||
|
@ -68,6 +74,9 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
|
failure {
|
||||||
|
sh 'cat tools/check_format.txt tools/warnings_count/warnings_setup_new.txt tools/warnings_count/warnings_disasm_new.txt tools/warnings_count/warnings_build_new.txt'
|
||||||
|
}
|
||||||
always {
|
always {
|
||||||
cleanWs()
|
cleanWs()
|
||||||
}
|
}
|
||||||
|
|
11
format.sh
11
format.sh
|
@ -1,15 +1,22 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
FORMAT_VER="11"
|
||||||
FORMAT_OPTS="-i -style=file"
|
FORMAT_OPTS="-i -style=file"
|
||||||
TIDY_OPTS="-p . --fix --fix-errors"
|
TIDY_OPTS="-p . --fix --fix-errors"
|
||||||
COMPILER_OPTS="-fno-builtin -std=gnu90 -Iinclude -Isrc -D_LANGUAGE_C -DNON_MATCHING"
|
COMPILER_OPTS="-fno-builtin -std=gnu90 -Iinclude -Isrc -D_LANGUAGE_C -DNON_MATCHING"
|
||||||
|
|
||||||
shopt -s globstar
|
shopt -s globstar
|
||||||
|
|
||||||
|
if [ -z `command -v clang-format-${FORMAT_VER}` ]
|
||||||
|
then
|
||||||
|
echo "clang-format-${FORMAT_VER} not found. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if (( $# > 0 )); then
|
if (( $# > 0 )); then
|
||||||
echo "Formatting file(s) $*"
|
echo "Formatting file(s) $*"
|
||||||
echo "Running clang-format..."
|
echo "Running clang-format..."
|
||||||
clang-format-11 ${FORMAT_OPTS} "$@"
|
clang-format-${FORMAT_VER} ${FORMAT_OPTS} "$@"
|
||||||
echo "Running clang-tidy..."
|
echo "Running clang-tidy..."
|
||||||
clang-tidy ${TIDY_OPTS} "$@" -- ${COMPILER_OPTS} &> /dev/null
|
clang-tidy ${TIDY_OPTS} "$@" -- ${COMPILER_OPTS} &> /dev/null
|
||||||
echo "Adding missing final new lines..."
|
echo "Adding missing final new lines..."
|
||||||
|
@ -20,7 +27,7 @@ fi
|
||||||
|
|
||||||
echo "Formatting C files. This will take a bit"
|
echo "Formatting C files. This will take a bit"
|
||||||
echo "Running clang-format..."
|
echo "Running clang-format..."
|
||||||
clang-format-11 ${FORMAT_OPTS} src/**/*.c
|
clang-format-${FORMAT_VER} ${FORMAT_OPTS} src/**/*.c
|
||||||
echo "Running clang-tidy..."
|
echo "Running clang-tidy..."
|
||||||
clang-tidy ${TIDY_OPTS} src/**/*.c -- ${COMPILER_OPTS} &> /dev/null
|
clang-tidy ${TIDY_OPTS} src/**/*.c -- ${COMPILER_OPTS} &> /dev/null
|
||||||
echo "Adding missing final new lines..."
|
echo "Adding missing final new lines..."
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
STATUSOLD=`git status --porcelain`
|
||||||
|
./format.sh
|
||||||
|
if [ $? -ne 0 ]
|
||||||
|
then
|
||||||
|
echo "Formatter failed. Exiting."
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
STATUSNEW=`git status --porcelain`
|
||||||
|
|
||||||
|
if [ "${STATUSOLD}" != "${STATUSNEW}" ];
|
||||||
|
then
|
||||||
|
echo ""
|
||||||
|
echo "Misformatted files found. Run ./format.sh and verify codegen is not impacted."
|
||||||
|
echo ""
|
||||||
|
diff --unified=0 --label "Old git status" <(echo "${STATUSOLD}") --label "New git status" <(echo "${STATUSNEW}")
|
||||||
|
echo ""
|
||||||
|
echo "Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue