Skip to content

Commit 2f705fa

Browse files
committed
pants: add shfmt to format packaging scripts
disable it for all other scripts that would be reformatted. Someone can reenable it and run it on files later.
1 parent a99117f commit 2f705fa

File tree

21 files changed

+55
-3
lines changed

21 files changed

+55
-3
lines changed

BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ file(
8888

8989
shell_sources(
9090
name="root",
91+
skip_shfmt=True,
9192
)
9293

9394
file(

contrib/core/actions/send_mail/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ st2_shell_sources_and_resources(
22
name="send_mail",
33
sources=["send_mail"],
44
skip_shellcheck=True,
5+
skip_shfmt=True,
56
)

contrib/examples/actions/BUILD

+3
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ python_sources()
33
shell_sources(
44
name="shell",
55
skip_shellcheck=True,
6+
overrides={
7+
"print_to_stdout_and_stderr.sh": dict(skip_shfmt=True),
8+
}
69
)
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
shell_sources()
1+
shell_sources(skip_shfmt=True)

contrib/examples/actions/bash_random/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
shell_sources(
2+
skip_shfmt=True,
23
overrides={
34
"random2.sh": dict(skip_shellcheck=True),
45
},

contrib/linux/actions/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ python_sources()
33
shell_sources(
44
name="shell",
55
skip_shellcheck=True,
6+
skip_shfmt=True,
67
)

pants-plugins/macros.py

+1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ def st2_shell_sources_and_resources(**kwargs):
181181
shell_sources(**kwargs) # noqa: F821
182182

183183
kwargs.pop("skip_shellcheck", None)
184+
kwargs.pop("skip_shfmt", None)
184185

185186
kwargs["name"] += "_resources"
186187
resources(**kwargs) # noqa: F821

pants.toml

+10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ backend_packages = [
2626
# shell
2727
"pants.backend.shell",
2828
"pants.backend.shell.lint.shellcheck",
29+
"pants.backend.shell.lint.shfmt",
2930

3031
# packaging
3132
"pants.backend.experimental.makeself",
@@ -236,6 +237,15 @@ config = "@lint-configs/regex-lint.yaml"
236237
[setuptools]
237238
install_from_resolve = "st2"
238239

240+
[shfmt]
241+
args = [
242+
# https://github.com/mvdan/sh/blob/master/cmd/shfmt/shfmt.1.scd#printer-flags
243+
"--indent",
244+
"4", # default is 0 (use tabs)
245+
"--case-indent",
246+
"--simplify",
247+
]
248+
239249
[test]
240250
extra_env_vars = [
241251
# Use this so that the test system does not require the stanley user.

scripts/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ python_sources()
22

33
shell_sources(
44
name="shell",
5+
skip_shfmt=True,
56
)

scripts/ci/BUILD

+11-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
shell_sources()
1+
shell_sources(
2+
overrides={
3+
(
4+
"add-itest-user-key.sh",
5+
"permissions-workaround.sh",
6+
"run-nightly-make-task-if-exists.sh",
7+
"submit-codecov-coverage.sh",
8+
"time-command.sh",
9+
): dict(skip_shfmt=True),
10+
},
11+
)

scripts/github/BUILD

+8
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,12 @@ files(
88

99
shell_sources(
1010
dependencies=[":assets"],
11+
overrides={
12+
(
13+
"install-apt-packages-use-cache.sh",
14+
"install-mongosh.sh",
15+
"install-virtualenv.sh",
16+
"setup-environment.sh",
17+
): dict(skip_shfmt=True),
18+
},
1119
)

st2actions/bin/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ st2_shell_sources_and_resources(
99
name="shell",
1010
sources=["*.sh"],
1111
skip_shellcheck=True,
12+
skip_shfmt=True,
1213
)

st2common/bin/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ st2_shell_sources_and_resources(
1515
name="shell",
1616
sources=["st2ctl", "st2-self-check", "st2-run-pack-tests"],
1717
skip_shellcheck=True,
18+
skip_shfmt=True,
1819
overrides={
1920
"st2ctl": dict(
2021
dependencies=[

st2common/bin/migrations/v2.1/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ python_sources()
33
shell_sources(
44
name="shell",
55
skip_shellcheck=True,
6+
skip_shfmt=True,
67
)

st2common/tests/fixtures/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ python_sources()
33
st2_shell_sources_and_resources(
44
name="shell",
55
sources=["*.sh"],
6+
skip_shfmt=True,
67
)

st2tests/integration/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ shell_sources(
1212
"st2tests/conf:vagrant_ssh_key",
1313
],
1414
skip_shellcheck=True,
15+
skip_shfmt=True,
1516
)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
st2_shell_sources_and_resources(
22
name="shell",
33
sources=["*.sh"],
4+
skip_shfmt=True,
45
)

st2tests/st2tests/fixtures/packs/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ st2_shell_sources_and_resources(
1818
name="test_content_version_shell",
1919
# do not check across git submodule boundary
2020
skip_shellcheck=True,
21+
skip_shfmt=True,
2122
sources=[
2223
"test_content_version/**/*.sh",
2324
],

st2tests/st2tests/fixtures/ssl_certs/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ python_sources(
1717

1818
shell_sources(
1919
name="util",
20+
skip_shfmt=True,
2021
)
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
shell_sources(skip_shellcheck=True)
1+
shell_sources(skip_shellcheck=True, skip_shfmt=True)

tools/BUILD

+7
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,11 @@ shell_sources(
5151
dependencies=[
5252
"conf:st2_dev_conf",
5353
],
54+
overrides={
55+
(
56+
"db_cleanup.sh",
57+
"launchdev.sh",
58+
"st2-setup-tests",
59+
): dict(skip_shfmt=True),
60+
},
5461
)

0 commit comments

Comments
 (0)