From 463ae5d805f6d758cb21365a212b244e79855d1a Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Fri, 10 Jun 2022 13:47:16 -0700 Subject: 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 --- ops/ci/shellcheck.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 ops/ci/shellcheck.nix (limited to 'ops') 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}"; + }; +} -- cgit 1.4.1