Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 3702a796 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

CI: Update the CI

- Clean all the generated files and folders, even on failed pipeline
- Add the format checking test at initialization
parent 49590175
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!105Refactor and more
...@@ -12,8 +12,8 @@ stages: ...@@ -12,8 +12,8 @@ stages:
- main - main
- merge_requests - merge_requests
variables: variables:
SRC_DIR: $CI_PROJECT_DIR # Where the sources are SRC_DIR: $CI_PROJECT_DIR # Where the sources are
WORK_DIR: "/home/gitlab-runner/CI_$CI_PIPELINE_ID" # Where we will work, so that it's not erased WORK_DIR: "/home/gitlab-runner/CI_$CI_PIPELINE_ID" # Where we will work, so that it's not erased
.breaking_tests: &breaking_tests .breaking_tests: &breaking_tests
allow_failure: true allow_failure: true
...@@ -29,16 +29,24 @@ env_sanitize: ...@@ -29,16 +29,24 @@ env_sanitize:
<<: *main_tests <<: *main_tests
stage: initialization stage: initialization
script: script:
- cd $CI_PROJECT_DIR
- export # For debug purpose - export # For debug purpose
- scripts/validate.bash --build=gcc --step=prepare - scripts/validate.bash --build=gcc --step=prepare
- scripts/validate.bash --build=clang --step=prepare - scripts/validate.bash --build=clang --step=prepare
- echo "Env is intialized" - echo "Env is intialized"
style_verification:
<<: *main_tests
stage: initialization
script:
- cd $CI_PROJECT_DIR
- scripts/validate.bash --step=format
env_finalize: env_finalize:
<<: *main_tests <<: *main_tests
stage: finalization stage: finalization
allow_failure: true allow_failure: true
when: on_success when: always
script: rm -rf $WORK_DIR script: rm -rf $WORK_DIR
################################################# #################################################
......
#!/bin/sh #!/bin/bash
OPTIONS=' OPTIONS='
--style=linux -s4 --style=linux -s4
--pad-oper --pad-header --pad-comma --pad-oper --pad-header --pad-comma
--align-pointer=name --align-reference=name --align-pointer=name --align-reference=name
--break-one-line-headers --break-one-line-headers
--remove-braces --remove-braces
--break-return-type --break-return-type
--convert-tabs --convert-tabs
--close-templates --close-templates
--max-code-length=101 --max-code-length=101
--mode=c --mode=c
--lineend=linux --lineend=linux
--attach-inlines --attach-inlines
--indent-labels --indent-labels
--indent-col1-comments --indent-col1-comments
--indent-preproc-block --indent-preproc-block'
--quiet'
if [ $# -gt 0 ] && [ "$1" = "--check" ] ; then
astyle $OPTIONS --dry-run -R ./*.c | grep Formatted
[ $? -eq 1 ] && exit 0 || exit 1
fi
find . -iname '*.c' -exec astyle $OPTIONS {} \; find . -name '*.c' -exec astyle $OPTIONS --quiet {} \;
find . -iname '*.h' -exec astyle $OPTIONS {} \; find . -name '*.h' -exec astyle $OPTIONS --quiet {} \;
find . -iname '*.hpp' -exec astyle $OPTIONS {} \; find . -name '*.hpp' -exec astyle $OPTIONS --quiet {} \;
find . -iname '*.cpp' -exec astyle $OPTIONS {} \; find . -name '*.cpp' -exec astyle $OPTIONS --quiet {} \;
find . -iname '*.orig' -exec rm {} \; find . -name '*.orig' -exec rm {} \;
...@@ -25,7 +25,7 @@ LKT_BUILD="" # Build folder of lektor ...@@ -25,7 +25,7 @@ LKT_BUILD="" # Build folder of lektor
function test_simple () function test_simple ()
{ {
check_cd $LKT_INSTALL check_cd $LKT_INSTALL/bin/
./lektord & ./lektord &
local _child_pid=$! local _child_pid=$!
./lkt pwd=hashire adm kil ./lkt pwd=hashire adm kil
...@@ -33,7 +33,7 @@ function test_simple () ...@@ -33,7 +33,7 @@ function test_simple ()
kill $_child_pid kill $_child_pid
wait $_child_pid wait $_child_pid
local _child_sta=$? local _child_sta=$?
[ _child_sta -ne 0 ] && die "The lektord process exited with $_child_sta" [ $_child_sta -ne 0 ] && die "The lektord process exited with $_child_sta"
} }
### Utility functions ######################################################## ### Utility functions ########################################################
...@@ -72,7 +72,8 @@ Usage validate.bash --build=* --step=* [option] ...@@ -72,7 +72,8 @@ Usage validate.bash --build=* --step=* [option]
--help, -h Prints this help message. --help, -h Prints this help message.
--build=comp Specify the compiler. --build=comp Specify the compiler.
--step=AA,BB,.. Specify the steps to do. The list may contains the --step=AA,BB,.. Specify the steps to do. The list may contains the
following items: configure, launch, build. following items: prepare, configure, launch, build,
cleanup, format.
Step configure options: Step configure options:
--debug Perform a debug build. --debug Perform a debug build.
...@@ -135,19 +136,24 @@ function do_steps () ...@@ -135,19 +136,24 @@ function do_steps ()
local _build="" local _build=""
local _configure="" local _configure=""
local _launch="" local _launch=""
local _cleanup=""
local _format=""
for step in $LKT_STEP ; do for step in $LKT_STEP ; do
case "$step" in case "$step" in
build) _build="yes";; build) _build="yes";;
configure) _configure="yes";; configure) _configure="yes";;
launch) _launch="yes";; launch) _launch="yes";;
prepare) _prepare="yes";; prepare) _prepare="yes";;
format) _format="yes";;
esac esac
done done
[ "x$_format" = "xyes" ] && do_format
[ "x$_prepare" = "xyes" ] && do_prepare [ "x$_prepare" = "xyes" ] && do_prepare
[ "x$_configure" = "xyes" ] && do_configure [ "x$_configure" = "xyes" ] && do_configure
[ "x$_build" = "xyes" ] && do_build [ "x$_build" = "xyes" ] && do_build
[ "x$_launch" = "xyes" ] && do_launch [ "x$_launch" = "xyes" ] && do_launch
[ "x$_cleanup" = "xyes" ] && do_cleanup
} }
### PERFORM THE TESTS ######################################################## ### PERFORM THE TESTS ########################################################
...@@ -164,6 +170,22 @@ function do_launch () ...@@ -164,6 +170,22 @@ function do_launch ()
done done
} }
### PERFORM THE FORMAT CHECK #################################################
function do_format ()
{
./scripts/astyle.bash --check
! [ $? -eq 0 ] && die "Format is incorrect, use 'scripts/astyle.bash'"
}
### CLEANUP THE BUILD AND INSTALL FOLDERS ####################################
# Globals: #
# - LKT_WORK The folder in which everything is compiled and #
# installed with tests and others #
function do_cleanup ()
{
rm -rf $LKT_WORK || die "Failed to clean directory $LKT_WORK"
}
### PROCESS ARGS ############################################################# ### PROCESS ARGS #############################################################
# Globals: # # Globals: #
# - LKT_DEBUG Whether or not to build in debug mode # # - LKT_DEBUG Whether or not to build in debug mode #
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter