File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed
Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 8686
8787 inherit ( pkgs )
8888 nixpkgs-fmt
89- shfmt ;
89+ shfmt
90+ shellcheck ;
9091
9192 inherit ( pkgs . python3Packages )
9293 mpmath sympy black pyparsing pyyaml ;
Original file line number Diff line number Diff line change @@ -41,7 +41,11 @@ if ! command -v shfmt 2>&1 >/dev/null; then
4141 error " shfmt not found. Are you running in a nix shell? See BUILDING.md."
4242 exit 1
4343fi
44- shfmt -s -w -l -i 2 -ci -fn $( shfmt -f $( git grep -l ' ' :/) )
44+
45+ # Find all scripts in the repo
46+ ALL_FILES=$( git grep -l ' ' :/)
47+ SHELL_SCRIPTS=$( echo " $ALL_FILES " | xargs shfmt -f)
48+ shfmt -s -l -i 2 -ci -fn $SHELL_SCRIPTS
4549
4650info " Formatting python scripts"
4751if ! command -v black 2>&1 > /dev/null; then
Original file line number Diff line number Diff line change @@ -106,15 +106,36 @@ gh_error_simple()
106106 fi
107107}
108108
109+ run-shellcheck ()
110+ {
111+ if ! command -v shellcheck > /dev/null; then
112+ gh_error_simple " Shellcheck missing" " shellcheck is not installed"
113+ error " Lint shellcheck"
114+ SUCCESS=false
115+ gh_summary_failure " Lint shellcheck"
116+ return 0
117+ fi
118+
119+ checkerr " Lint shellcheck" " $( shellcheck --severity=warning $SHELL_SCRIPTS ) "
120+ }
121+
109122# Formatting
110123SUCCESS=true
111124
125+ # Get list of shell scripts for linting
126+ ALL_FILES=$( git grep -l ' ' :/)
127+ SHELL_SCRIPTS=$( echo " $ALL_FILES " | xargs shfmt -f)
128+
112129gh_group_start " Linting nix files with nixpkgs-fmt"
113130checkerr " Lint nix" " $( nixpkgs-fmt --check " $ROOT " ) "
114131gh_group_end
115132
116133gh_group_start " Linting shell scripts with shfmt"
117- checkerr " Lint shell" " $( shfmt -s -l -i 2 -ci -fn $( shfmt -f $( git grep -l ' ' :/) ) ) "
134+ checkerr " Lint shell" " $( echo $SHELL_SCRIPTS | xargs shfmt -s -l -i 2 -ci -fn) "
135+ gh_group_end
136+
137+ gh_group_start " Linting shell scripts with shellcheck"
138+ run-shellcheck
118139gh_group_end
119140
120141gh_group_start " Linting python scripts with black"
You can’t perform that action at this time.
0 commit comments