From fc410b024da3634ebb0b10ad14d9513fe6c90944 Mon Sep 17 00:00:00 2001 From: David Heidelberg Date: Wed, 10 Aug 2022 15:27:31 +0200 Subject: [PATCH] ci: use shellcheck for .gitlab-ci/container/ directory It checks our CI shell code in `debian-build-testing` job. Reviewed-by: Guilherme Gallo Signed-off-by: David Heidelberg Part-of: --- .gitlab-ci/build/gitlab-ci.yml | 1 + .gitlab-ci/container/debian/x86_build.sh | 1 + .gitlab-ci/image-tags.yml | 14 +++++++------- .gitlab-ci/run-shellcheck.sh | 23 +++++++++++++++++++++++ 4 files changed, 32 insertions(+), 7 deletions(-) create mode 100755 .gitlab-ci/run-shellcheck.sh diff --git a/.gitlab-ci/build/gitlab-ci.yml b/.gitlab-ci/build/gitlab-ci.yml index 5109912..b8e6080 100644 --- a/.gitlab-ci/build/gitlab-ci.yml +++ b/.gitlab-ci/build/gitlab-ci.yml @@ -171,6 +171,7 @@ debian-build-testing: -D tools=drm-shim,etnaviv,freedreno,glsl,intel,intel-ui,nir,nouveau,xvmc,lima,panfrost,asahi script: - .gitlab-ci/lava/lava-pytest.sh + - .gitlab-ci/run-shellcheck.sh - .gitlab-ci/meson/build.sh - .gitlab-ci/run-shader-db.sh diff --git a/.gitlab-ci/container/debian/x86_build.sh b/.gitlab-ci/container/debian/x86_build.sh index 479f5d1..c03e82a 100644 --- a/.gitlab-ci/container/debian/x86_build.sh +++ b/.gitlab-ci/container/debian/x86_build.sh @@ -48,6 +48,7 @@ apt-get install -y --no-remove \ python3-pytest \ procps \ spirv-tools \ + shellcheck \ strace \ time \ zstd diff --git a/.gitlab-ci/image-tags.yml b/.gitlab-ci/image-tags.yml index dc6effe..b438115 100644 --- a/.gitlab-ci/image-tags.yml +++ b/.gitlab-ci/image-tags.yml @@ -1,21 +1,21 @@ variables: DEBIAN_X86_BUILD_BASE_IMAGE: "debian/x86_build-base" - DEBIAN_BASE_TAG: "2022-08-22-drop-llvm9" + DEBIAN_BASE_TAG: "2022-08-25-shellcheck" DEBIAN_X86_BUILD_IMAGE_PATH: "debian/x86_build" - DEBIAN_BUILD_TAG: "2022-08-23-mold" + DEBIAN_BUILD_TAG: "2022-08-25-shellcheck" DEBIAN_X86_BUILD_MINGW_IMAGE_PATH: "debian/x86_build-mingw" - DEBIAN_BUILD_MINGW_TAG: "2022-08-17-bump" + DEBIAN_BUILD_MINGW_TAG: "2022-08-25-shellcheck" DEBIAN_X86_TEST_BASE_IMAGE: "debian/x86_test-base" DEBIAN_X86_TEST_IMAGE_PATH: "debian/x86_test-gl" - DEBIAN_X86_TEST_GL_TAG: "2022-08-17-bump" - DEBIAN_X86_TEST_VK_TAG: "2022-08-17-bump" + DEBIAN_X86_TEST_GL_TAG: "2022-08-25-shellcheck" + DEBIAN_X86_TEST_VK_TAG: "2022-08-25-shellcheck" - FEDORA_X86_BUILD_TAG: "2022-08-23-mold" - KERNEL_ROOTFS_TAG: "2022-08-17-bump" + FEDORA_X86_BUILD_TAG: "2022-08-25-shellcheck" + KERNEL_ROOTFS_TAG: "2022-08-25-shellcheck" WINDOWS_X64_VS_PATH: "windows/x64_vs" WINDOWS_X64_VS_TAG: "2022-08-17-bump" diff --git a/.gitlab-ci/run-shellcheck.sh b/.gitlab-ci/run-shellcheck.sh new file mode 100755 index 0000000..4be356a --- /dev/null +++ b/.gitlab-ci/run-shellcheck.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +CHECKPATH=".gitlab-ci/container" # TODO: expand to cover whole .gitlab-ci/ + +is_bash() { + [[ $1 == *.sh ]] && return 0 + [[ $1 == */bash-completion/* ]] && return 0 + [[ $(file -b --mime-type "$1") == text/x-shellscript ]] && return 0 + return 1 +} + +while IFS= read -r -d $'' file; do + if is_bash "$file" ; then + shellcheck -x -W0 -s bash "$file" + rc=$? + if [ "${rc}" -eq 0 ] + then + continue + else + exit 1 + fi + fi +done < <(find $CHECKPATH -type f \! -path "./.git/*" -print0) -- 2.7.4