Skip to content

Commit 6e225bb

Browse files
committed
Avoid excessive indentation in shell commands
The project's GitHub Actions workflows and tasks contain complex shell command lines. With the use of the line continuation operator, these commands can be split into multiple code lines. This improves readability by providing a visualization of the command structure. It also improves maintainability by making diffs for changes to these commands more clear. The readability can be further improved by indentation of the subsequent lines of the command in a manner that visually conveys the structure. Previously, in cases where multiple commands are chained via control or list operators, the subsequent commands were indented relative to the prior command in the chain. Although this did help to visually convey the structure, it also resulted in excessive levels of indentation. It also resulted in some visual ambiguity between indentation used for arguments to a command, and that for subsequent commands in the chain. For these reasons, the determination was made to not indent the subsequent commands in the chain. The structure is communicated by placing the operator linking the commands on a dedicated line.
1 parent 92bcb9c commit 6e225bb

File tree

10 files changed

+101
-93
lines changed

10 files changed

+101
-93
lines changed

.github/workflows/check-npm-task.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,12 @@ jobs:
150150

151151
- name: Fix problems in npm configuration file
152152
run: |
153-
task \
154-
npm:fix-config \
153+
task npm:fix-config \
155154
PROJECT_PATH="${{ matrix.project.path }}"
156155
157156
- name: Check if fixes are needed in npm configuration file
158157
run: |
159-
git \
160-
diff \
161-
--color \
162-
--exit-code \
163-
"${{ matrix.project.path }}/.npmrc"
158+
git diff \
159+
--color \
160+
--exit-code \
161+
"${{ matrix.project.path }}/.npmrc"

.github/workflows/test-install-script.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,11 @@ jobs:
241241
BINDIR: ${{ env.FIRST_BINDIR }}
242242
run: |
243243
mkdir -p "${{ env.BINDIR }}"
244-
"${{ github.workspace }}/${{ env.SCRIPT_NAME }}" | \
245-
grep \
246-
-F \
247-
'${{ env.TOOL_NAME }} not found. You might want to add "${{ env.FIRST_BINDIR }}" to your $PATH'
244+
"${{ github.workspace }}/${{ env.SCRIPT_NAME }}" \
245+
| \
246+
grep \
247+
-F \
248+
'${{ env.TOOL_NAME }} not found. You might want to add "${{ env.FIRST_BINDIR }}" to your $PATH'
248249
249250
- name: Add first installation to PATH
250251
shell: bash
@@ -259,10 +260,11 @@ jobs:
259260
BINDIR: ${{ env.SECOND_BINDIR }}
260261
run: |
261262
mkdir -p "${{ env.BINDIR }}"
262-
"${{ github.workspace }}/${{ env.SCRIPT_NAME }}" | \
263-
grep \
264-
-F \
265-
'${{ env.TOOL_NAME }} was found at ${{ env.FIRST_BINDIR }}/${{ env.TOOL_NAME }}. Please prepend "${{ env.BINDIR }}" to your $PATH'
263+
"${{ github.workspace }}/${{ env.SCRIPT_NAME }}" \
264+
| \
265+
grep \
266+
-F \
267+
'${{ env.TOOL_NAME }} was found at ${{ env.FIRST_BINDIR }}/${{ env.TOOL_NAME }}. Please prepend "${{ env.BINDIR }}" to your $PATH'
266268
267269
# ${{ runner.temp }} is a Windows style path on the windows runner, but the script output uses the equivalent
268270
# POSIX style path.
@@ -274,6 +276,7 @@ jobs:
274276
BINDIR: ${{ env.SECOND_BINDIR }}
275277
run: |
276278
mkdir -p "${{ env.BINDIR }}"
277-
"${{ github.workspace }}/${{ env.SCRIPT_NAME }}" | \
278-
grep \
279-
'${{ env.TOOL_NAME }} was found at .*/${{ env.FIRST_INSTALLATION_FOLDER }}/${{ env.TOOL_NAME }}\. Please prepend ".*/${{ env.SECOND_INSTALLATION_FOLDER }}" to your \$PATH'
279+
"${{ github.workspace }}/${{ env.SCRIPT_NAME }}" \
280+
| \
281+
grep \
282+
'${{ env.TOOL_NAME }} was found at .*/${{ env.FIRST_INSTALLATION_FOLDER }}/${{ env.TOOL_NAME }}\. Please prepend ".*/${{ env.SECOND_INSTALLATION_FOLDER }}" to your \$PATH'

Taskfile.yml

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,14 @@ tasks:
254254
- |
255255
# Add source comment
256256
echo \
257-
"# Source: https://github.com/arduino/tooling-project-assets/tree/main/other/clang-format-configuration" > \
258-
"{{.TARGET_PATH}}"
257+
"# Source: https://github.com/arduino/tooling-project-assets/tree/main/other/clang-format-configuration" \
258+
> "{{.TARGET_PATH}}"
259259
260260
# Dump the effective configuration to the target file
261261
clang-format \
262262
--dump-config \
263-
--style=file:"{{.CLANG_FORMAT_CONFIGURATION_PATH}}" >> \
264-
"{{.TARGET_PATH}}"
263+
--style=file:"{{.CLANG_FORMAT_CONFIGURATION_PATH}}" \
264+
>> "{{.TARGET_PATH}}"
265265
266266
- |
267267
# Correct invalid `BasedOnStyle` key value
@@ -457,11 +457,12 @@ tasks:
457457
sh \
458458
-c \
459459
' \
460-
basename "$0" | \
461-
grep \
462-
--extended-regexp \
463-
--regexp='"'"'([<>:"/\\|?*'"'"'"$(printf "\001-\037")"'"'"'])|(.+\.$)'"'"' \
464-
--silent \
460+
basename "$0" \
461+
| \
462+
grep \
463+
--extended-regexp \
464+
--regexp='"'"'([<>:"/\\|?*'"'"'"$(printf "\001-\037")"'"'"'])|(.+\.$)'"'"' \
465+
--silent \
465466
&& \
466467
echo "$0"
467468
' \
@@ -489,12 +490,13 @@ tasks:
489490
sh \
490491
-c \
491492
' \
492-
basename "$0" | \
493-
grep \
494-
--ignore-case \
495-
--extended-regexp \
496-
--regexp='"'"'^(con|prn|aux|nul|com[0-9]+|lpt[0-9]+)$'"'"' \
497-
--silent \
493+
basename "$0" \
494+
| \
495+
grep \
496+
--ignore-case \
497+
--extended-regexp \
498+
--regexp='"'"'^(con|prn|aux|nul|com[0-9]+|lpt[0-9]+)$'"'"' \
499+
--silent \
498500
&& \
499501
echo "$0"
500502
' \
@@ -765,10 +767,9 @@ tasks:
765767
"{{default .DEFAULT_NPM_PROJECT_PATH .PROJECT_PATH}}"
766768
cmds:
767769
- |
768-
npm \
769-
config \
770-
--location project \
771-
fix
770+
npm config \
771+
--location project \
772+
fix
772773
773774
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-npm-task/Taskfile.yml
774775
npm:validate:
@@ -869,7 +870,7 @@ tasks:
869870
--input-format toml \
870871
--output-format yaml \
871872
'.tool.poetry.dependencies.python' \
872-
< pyproject.toml
873+
< pyproject.toml
873874
)"
874875
875876
echo "Python not found or not in PATH."
@@ -894,7 +895,7 @@ tasks:
894895
--input-format toml \
895896
--output-format yaml \
896897
'.tool.poetry.group.pipx.dependencies.poetry' \
897-
< pyproject.toml
898+
< pyproject.toml
898899
)"
899900
900901
pipx install \

workflow-templates/assets/check-action-metadata-task/Taskfile.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ tasks:
2020
https://json.schemastore.org/github-action
2121
- |
2222
npx \
23-
ajv-cli \
24-
validate \
23+
ajv-cli validate \
2524
--strict=false \
2625
-s "{{.ACTION_METADATA_SCHEMA_PATH}}" \
2726
-d "action.yml"

workflow-templates/assets/check-files-task/Taskfile.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ tasks:
1616
sh \
1717
-c \
1818
' \
19-
basename "$0" | \
20-
grep \
21-
--extended-regexp \
22-
--regexp='"'"'([<>:"/\\|?*'"'"'"$(printf "\001-\037")"'"'"'])|(.+\.$)'"'"' \
23-
--silent \
19+
basename "$0" \
20+
| \
21+
grep \
22+
--extended-regexp \
23+
--regexp='"'"'([<>:"/\\|?*'"'"'"$(printf "\001-\037")"'"'"'])|(.+\.$)'"'"' \
24+
--silent \
2425
&& \
2526
echo "$0"
2627
' \
@@ -48,12 +49,13 @@ tasks:
4849
sh \
4950
-c \
5051
' \
51-
basename "$0" | \
52-
grep \
53-
--ignore-case \
54-
--extended-regexp \
55-
--regexp='"'"'^(con|prn|aux|nul|com[0-9]+|lpt[0-9]+)$'"'"' \
56-
--silent \
52+
basename "$0" \
53+
| \
54+
grep \
55+
--ignore-case \
56+
--extended-regexp \
57+
--regexp='"'"'^(con|prn|aux|nul|com[0-9]+|lpt[0-9]+)$'"'"' \
58+
--silent \
5759
&& \
5860
echo "$0"
5961
' \

workflow-templates/assets/check-npm-task/Taskfile.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ tasks:
1212
"{{default .DEFAULT_NPM_PROJECT_PATH .PROJECT_PATH}}"
1313
cmds:
1414
- |
15-
npm \
16-
config \
17-
--location project \
18-
fix
15+
npm config \
16+
--location project \
17+
fix
1918
2019
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-npm-task/Taskfile.yml
2120
npm:validate:

workflow-templates/assets/poetry-task/Taskfile.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ tasks:
2020
--input-format toml \
2121
--output-format yaml \
2222
'.tool.poetry.dependencies.python' \
23-
< pyproject.toml
23+
< pyproject.toml
2424
)"
2525
2626
echo "Python not found or not in PATH."
@@ -45,7 +45,7 @@ tasks:
4545
--input-format toml \
4646
--output-format yaml \
4747
'.tool.poetry.group.pipx.dependencies.poetry' \
48-
< pyproject.toml
48+
< pyproject.toml
4949
)"
5050
5151
pipx install \

workflow-templates/check-certificates.yml

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ jobs:
101101
-legacy \
102102
-noout \
103103
-passin env:CERTIFICATE_PASSWORD
104-
) || (
104+
) \
105+
|| \
106+
(
105107
echo "::error::Verification of ${{ matrix.certificate.identifier }} failed!!!"
106108
exit 1
107109
)
@@ -125,39 +127,45 @@ jobs:
125127
run: |
126128
if [[ ${{ matrix.certificate.type }} == "pkcs12" ]]; then
127129
EXPIRATION_DATE="$(
128-
(
130+
(
129131
openssl pkcs12 \
130-
-in ${{ env.CERTIFICATE_PATH }} \
131-
-clcerts \
132-
-legacy \
133-
-nodes \
134-
-passin env:CERTIFICATE_PASSWORD
135-
) | (
132+
-in ${{ env.CERTIFICATE_PATH }} \
133+
-clcerts \
134+
-legacy \
135+
-nodes \
136+
-passin env:CERTIFICATE_PASSWORD
137+
) \
138+
| \
139+
(
136140
openssl x509 \
137-
-noout \
138-
-enddate
139-
) | (
141+
-noout \
142+
-enddate
143+
) \
144+
| \
145+
(
140146
grep \
141-
--max-count=1 \
142-
--only-matching \
143-
--perl-regexp \
144-
'notAfter=(\K.*)'
145-
)
147+
--max-count=1 \
148+
--only-matching \
149+
--perl-regexp \
150+
'notAfter=(\K.*)'
151+
)
146152
)"
147153
elif [[ ${{ matrix.certificate.type }} == "x509" ]]; then
148154
EXPIRATION_DATE="$(
149-
(
155+
(
150156
openssl x509 \
151-
-in ${{ env.CERTIFICATE_PATH }} \
152-
-noout \
153-
-enddate
154-
) | (
157+
-in ${{ env.CERTIFICATE_PATH }} \
158+
-noout \
159+
-enddate
160+
) \
161+
| \
162+
(
155163
grep \
156-
--max-count=1 \
157-
--only-matching \
158-
--perl-regexp \
159-
'notAfter=(\K.*)'
160-
)
164+
--max-count=1 \
165+
--only-matching \
166+
--perl-regexp \
167+
'notAfter=(\K.*)'
168+
)
161169
)"
162170
fi
163171

workflow-templates/check-npm-task.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,12 @@ jobs:
150150

151151
- name: Fix problems in npm configuration file
152152
run: |
153-
task \
154-
npm:fix-config \
153+
task npm:fix-config \
155154
PROJECT_PATH="${{ matrix.project.path }}"
156155
157156
- name: Check if fixes are needed in npm configuration file
158157
run: |
159-
git \
160-
diff \
161-
--color \
162-
--exit-code \
163-
"${{ matrix.project.path }}/.npmrc"
158+
git diff \
159+
--color \
160+
--exit-code \
161+
"${{ matrix.project.path }}/.npmrc"

workflow-templates/release-tag.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ jobs:
4848
unzip \
4949
-p \
5050
"${{ steps.download-semver-tool.outputs.file-path }}" \
51-
semver-tool-${{ env.SEMVER_TOOL_VERSION }}/src/semver > \
52-
"${{ env.SEMVER_TOOL_PATH }}"
51+
semver-tool-${{ env.SEMVER_TOOL_VERSION }}/src/semver \
52+
>"${{ env.SEMVER_TOOL_PATH }}"
5353
chmod +x "${{ env.SEMVER_TOOL_PATH }}"
5454
5555
- name: Identify Prerelease

0 commit comments

Comments
 (0)