about summary refs log tree commit diff
path: root/ops/ci
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-06-10 13:47:16 -0700
committerFranck Cuny <franck@fcuny.net>2022-06-10 13:55:14 -0700
commit463ae5d805f6d758cb21365a212b244e79855d1a (patch)
tree12869c2fec87d41f357ba8a7a8880ad5b7b35f8a /ops/ci
parentfix(flake): install nixpkgs-fmt by default (diff)
downloadworld-463ae5d805f6d758cb21365a212b244e79855d1a.tar.gz
ci(shellcheck): add a script to check shell scripts
The script uses shellcheck to validates that the shell scripts are
correct.

This is not used by anything yet.

Change-Id: Ia96b132143fa0824eaf23420a72e5b518d618250
Reviewed-on: https://cl.fcuny.net/c/world/+/407
Tested-by: CI
Reviewed-by: Franck Cuny <franck@fcuny.net>
Diffstat (limited to 'ops/ci')
-rw-r--r--ops/ci/shellcheck.nix24
1 files changed, 24 insertions, 0 deletions
diff --git a/ops/ci/shellcheck.nix b/ops/ci/shellcheck.nix
new file mode 100644
index 0000000..c862a87
--- /dev/null
+++ b/ops/ci/shellcheck.nix
@@ -0,0 +1,24 @@
+{ pkgs, ... }: rec {
+  mkShellCheckScript = src:
+    let
+      script = pkgs.writeScript "shellcheck" ''
+        EXIT_STATUS=0
+        while IFS= read -r -d ''' i
+        do
+          if ${pkgs.shellcheck}/bin/shellcheck -x "$i"
+          then
+            echo "$i [ PASSED ]"
+          else
+            echo "$i [ FAILED ]"
+            EXIT_STATUS=$(($EXIT_STATUS+1))
+          fi
+        done <  <(find -name '*.sh' -print0)
+        echo Total Failed Files: $EXIT_STATUS
+        exit "$EXIT_STATUS"
+      '';
+    in
+    {
+      type = "app";
+      program = "${script}";
+    };
+}