Skip to content

Commit

Permalink
lint: use git ls-files for shellcheck (#4040)
Browse files Browse the repository at this point in the history
Use `git ls-files` to generate the list of files to run through shellcheck.
In addition to a huge performance improvement (shellcheck linter runs 6-7x faster),
this ignores files in submodules and files specified in .gitignore.

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
  • Loading branch information
mr-cal authored Feb 17, 2023
1 parent 46791aa commit ce9c24e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 2 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,8 @@ commands =
description = Check spelling with shellcheck
labels = lint
skip_install = true
allowlist_externals = bash
commands =
bash -c "find . \( -name .git -o -name gradlew -o -name .tox -o -name .ruff_cache -o \
-path ./tests/spread/tools/snapd-testing-tools \) -prune -o -print0 | xargs -0 file -N \
| grep shell.script | cut -f1 -d: | xargs shellcheck"
allowlist_externals = bash, git
commands = bash -c "git ls-files | file --mime-type -Nnf- | grep shellscript | cut -f1 -d: | xargs shellcheck"

[testenv:spread-shellcheck]
description = Run shellcheck on spread's test.yaml files using spread-shellcheck.py
Expand Down
2 changes: 2 additions & 0 deletions tests/spread/plugins/v1/gradle/snaps/gradlew-hello/gradlew
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

# shellcheck disable=all

##############################################################################
##
## Gradle start up script for UN*X
Expand Down

0 comments on commit ce9c24e

Please sign in to comment.