about summary refs log tree commit diff
path: root/ops/ci/shellcheck.nix
blob: c862a87ac36847f26cb6fa0c02bc3d88f514dcdd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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}";
    };
}