From 8b7c90d3283bba11824823109ed76716e5c7e919 Mon Sep 17 00:00:00 2001 From: Bart Ribbers Date: Thu, 31 Oct 2019 12:19:39 +0100 Subject: [PATCH] CI: various improvements (!694) * Only run the wiki test, if anything matching device/device-* was modified. * Split testcase linting (flake8) from shellcheck and only run flake8 if .gitlab-ci/* was modified. * Rename .gitlab-ci/static_code_analysis.sh to .gitlab-ci/shellcheck.sh and make it scan all pre/post install/upgrade/deinstall scripts. [ci:skip-vercheck]: other commits in this merge request have several intended version downgrades, such as 3 -> 1.0.0 --- .gitlab-ci.yml | 23 +++++++++++--- ...{static_code_analysis.sh => shellcheck.sh} | 30 +++++++------------ 2 files changed, 29 insertions(+), 24 deletions(-) rename .gitlab-ci/{static_code_analysis.sh => shellcheck.sh} (57%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 070b0056e..87e12c676 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -26,19 +26,34 @@ stages: wiki: stage: first <<: *only-default + only: + changes: + - device/device-* before_script: - apk -q add python3 script: - .gitlab-ci/check_devices_in_wiki.py --booting -# static code analysis -py-sh-static: +# testcases linting +testcases-linting: + stage: first + <<: *only-default + only: + changes: + - .gitlab-ci/* + before_script: + - apk -q add py3-flake8 + script: + - flake8 --ignore E501,F401,E722,W504,W605 + +# shellcheck +shellcheck: stage: first <<: *only-default before_script: - - apk -q add py3-flake8 shellcheck + - apk -q add shellcheck script: - - .gitlab-ci/static_code_analysis.sh + - .gitlab-ci/shellcheck.sh # aports checks (generic) aports-static: diff --git a/.gitlab-ci/static_code_analysis.sh b/.gitlab-ci/shellcheck.sh similarity index 57% rename from .gitlab-ci/static_code_analysis.sh rename to .gitlab-ci/shellcheck.sh index 1cb14dacd..3c7aa7d62 100755 --- a/.gitlab-ci/static_code_analysis.sh +++ b/.gitlab-ci/shellcheck.sh @@ -21,32 +21,22 @@ sh_files=" ./main/postmarketos-mkinitfs-hook-debug-shell/20-debug-shell.sh ./main/postmarketos-update-kernel/update-kernel.sh ./main/mdss-fb-init-hack/mdss-fb-init-hack.sh - ./main/postmarketos-ui-hildon/postmarketos-ui-hildon.post-install - $(find . -path './main/postmarketos-ui-hildon/*.sh') + + $(find . -path './main/postmarketos-ui-*/*.sh') + $(find . -path './main/postmarketos-ui-*/*.pre-install') + $(find . -path './main/postmarketos-ui-*/*.post-install') + $(find . -path './main/postmarketos-ui-*/*.pre-upgrade') + $(find . -path './main/postmarketos-ui-*/*.post-upgrade') + $(find . -path './main/postmarketos-ui-*/*.pre-deinstall') + $(find . -path './main/postmarketos-ui-*/*.post-deinstall') + $(find . -name '*.trigger') $(find . -path './main/devicepkg-dev/*.sh') $(find . -path '.gitlab-ci/*.sh') " -for file in ${sh_files}; do +for file in $sh_files; do echo "Test with shellcheck: $file" cd "$DIR/../$(dirname "$file")" shellcheck -e SC1008 -x "$(basename "$file")" done - -# Python: flake8 -# E501: max line length -# F401: imported, but not used (false positive: add_pmbootstrap_to_import_path) -# E722: do not use bare except -cd "$DIR/.." - -echo "Test with flake8: testcases" -# shellcheck disable=SC2086 -flake8 --ignore E501,F401,E722,W504,W605 $(find . -path "./.gitlab-ci/testcases/*.py") - -echo "Test with flake8: all other Python files" -# shellcheck disable=SC2086 -flake8 --ignore E501,E722,W504,W605 $(find . -not -path './.gitlab-ci/testcases/*' -a -name '*.py') - -# Done -echo "Success!"