Skip to content

Commit 4ef0d79

Browse files
committed
ci(shfmt): add shfmt code formatting checks (#254)
1 parent 5666b53 commit 4ef0d79

4 files changed

Lines changed: 36 additions & 0 deletions

File tree

.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_style = space
7+
insert_final_newline = true
8+
trim_trailing_whitespace=true
9+
10+
[*.{css,html,js,json,scss,yaml,yml}]
11+
indent_size = 2
12+
13+
[*.{py,sh}]
14+
indent_size = 4
15+
16+
[*.go]
17+
indent_style = tab

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ jobs:
5151
pip install black
5252
./run-tests.sh --format-black
5353
54+
format-shfmt:
55+
runs-on: ubuntu-24.04
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v4
59+
60+
- name: Check shell script code formatting
61+
run: |
62+
sudo apt-get install shfmt
63+
./run-tests.sh --format-shfmt
64+
5465
lint-commitlint:
5566
runs-on: ubuntu-24.04
5667
steps:

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ include *.md
99
include *.sh
1010
include *.yaml
1111
include .dockerignore
12+
include .editorconfig
1213
include .flake8
1314
include LICENSE
1415
include pytest.ini

run-tests.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ format_black() {
5555
black --check .
5656
}
5757

58+
format_shfmt() {
59+
shfmt -d .
60+
}
61+
5862
lint_commitlint() {
5963
from=${2:-master}
6064
to=${3:-HEAD}
@@ -128,6 +132,7 @@ python_tests() {
128132
all() {
129133
docs_sphinx
130134
format_black
135+
format_shfmt
131136
lint_commitlint
132137
lint_flake8
133138
lint_jsonlint
@@ -144,6 +149,7 @@ help() {
144149
echo " --all Perform all checks [default]"
145150
echo " --docs-sphinx Check Sphinx docs build"
146151
echo " --format-black Check formatting of Python code"
152+
echo " --format-shfmt Check formatting of shell scripts"
147153
echo " --help Display this help message"
148154
echo " --lint-commitlint Check linting of commit messages"
149155
echo " --lint-flake8 Check linting of Python code"
@@ -166,6 +172,7 @@ case $arg in
166172
--help) help ;;
167173
--docs-sphinx) docs_sphinx ;;
168174
--format-black) format_black ;;
175+
--format-shfmt) format_shfmt ;;
169176
--lint-commitlint) lint_commitlint "$@" ;;
170177
--lint-flake8) lint_flake8 ;;
171178
--lint-jsonlint) lint_jsonlint ;;

0 commit comments

Comments
 (0)