Module: Mesa
Branch: main
Commit: fc410b024da3634ebb0b10ad14d9513fe6c90944
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fc410b024da3634ebb0b10ad14d9513fe6c90944

Author: David Heidelberg <[email protected]>
Date:   Wed Aug 10 15:27:31 2022 +0200

ci: use shellcheck for .gitlab-ci/container/ directory

It checks our CI shell code in `debian-build-testing` job.

Reviewed-by: Guilherme Gallo <[email protected]>
Signed-off-by: David Heidelberg <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17574>

---

 .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(-)

diff --git a/.gitlab-ci/build/gitlab-ci.yml b/.gitlab-ci/build/gitlab-ci.yml
index 510991285cb..b8e60802ff0 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 479f5d136bc..c03e82abb1e 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 dc6effe067b..b43811543f9 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 00000000000..4be356a11ca
--- /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)

Reply via email to