Skip to content

Commit 9d7b45a

Browse files
committed
Split shell commands into multiple lines for readability
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 and avoiding excessive line lengths. It also improves maintainability by making diffs for changes to these commands more clear. Previously this was done in many commands, but not consistently throughout the project.
1 parent 6088499 commit 9d7b45a

18 files changed

+412
-138
lines changed

.github/workflows/check-certificates.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ jobs:
8888
env:
8989
CERTIFICATE: ${{ secrets[matrix.certificate.certificate-secret] }}
9090
run: |
91-
echo "${{ env.CERTIFICATE }}" | base64 --decode > "${{ env.CERTIFICATE_PATH }}"
91+
echo "${{ env.CERTIFICATE }}" \
92+
| \
93+
base64 \
94+
--decode \
95+
>"${{ env.CERTIFICATE_PATH }}"
9296
9397
- name: Verify certificate
9498
env:
@@ -168,7 +172,9 @@ jobs:
168172
)"
169173
fi
170174
171-
DAYS_BEFORE_EXPIRATION="$((($(date --utc --date="$EXPIRATION_DATE" +%s) - $(date --utc +%s)) / 60 / 60 / 24))"
175+
DAYS_BEFORE_EXPIRATION="$(
176+
(($(date --utc --date="$EXPIRATION_DATE" +%s) - $(date --utc +%s)) / 60 / 60 / 24)
177+
)"
172178
173179
# Display the expiration information in the log.
174180
echo "Certificate expiration date: $EXPIRATION_DATE"

.github/workflows/check-general-formatting-task.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,19 @@ jobs:
7171
- name: Install editorconfig-checker
7272
run: |
7373
cd "${{ env.EC_INSTALL_PATH }}"
74-
tar --extract --file="${{ steps.download.outputs.name }}"
74+
tar \
75+
--extract \
76+
--file="${{ steps.download.outputs.name }}"
7577
# Give the binary a standard name
76-
mv "${{ env.EC_INSTALL_PATH }}/bin/ec-linux-amd64" "${{ env.EC_INSTALL_PATH }}/bin/ec"
78+
mv \
79+
"${{ env.EC_INSTALL_PATH }}/bin/ec-linux-amd64" \
80+
"${{ env.EC_INSTALL_PATH }}/bin/ec"
7781
# Add installation to PATH:
7882
# See: https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#adding-a-system-path
7983
echo "${{ env.EC_INSTALL_PATH }}/bin" >>"$GITHUB_PATH"
8084
8185
- name: Check formatting
82-
run: task --silent general:check-formatting
86+
run: |
87+
task \
88+
--silent \
89+
general:check-formatting

.github/workflows/check-go-dependencies-task.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,21 @@ jobs:
9292
version: 3.x
9393

9494
- name: Update dependencies license metadata cache
95-
run: task --silent general:cache-dep-licenses
95+
run: |
96+
task \
97+
--silent \
98+
general:cache-dep-licenses
9699
97100
- name: Check for outdated cache
98101
id: diff
99102
run: |
100103
git add .
101-
if ! git diff --cached --color --exit-code; then
104+
if
105+
! git diff \
106+
--cached \
107+
--color \
108+
--exit-code
109+
then
102110
echo
103111
echo "::error::Dependency license metadata out of sync. See: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-dependencies-task.md#metadata-cache"
104112
exit 1
@@ -151,4 +159,7 @@ jobs:
151159
version: 3.x
152160

153161
- name: Check for dependencies with unapproved licenses
154-
run: task --silent general:check-dep-licenses
162+
run: |
163+
task \
164+
--silent \
165+
general:check-dep-licenses

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ jobs:
124124
run: task go:fix
125125

126126
- name: Check if any fixes were needed
127-
run: git diff --color --exit-code
127+
run: |
128+
git diff \
129+
--color \
130+
--exit-code
128131
129132
check-style:
130133
name: check-style (${{ matrix.module.path }})
@@ -164,7 +167,10 @@ jobs:
164167
- name: Check style
165168
env:
166169
GO_MODULE_PATH: ${{ matrix.module.path }}
167-
run: task --silent go:lint
170+
run: |
171+
task \
172+
--silent \
173+
go:lint
168174
169175
check-formatting:
170176
name: check-formatting (${{ matrix.module.path }})
@@ -204,7 +210,10 @@ jobs:
204210
run: task go:format
205211

206212
- name: Check formatting
207-
run: git diff --color --exit-code
213+
run: |
214+
git diff \
215+
--color \
216+
--exit-code
208217
209218
check-config:
210219
name: check-config (${{ matrix.module.path }})
@@ -244,4 +253,7 @@ jobs:
244253
run: task go:tidy
245254

246255
- name: Check whether any tidying was needed
247-
run: git diff --color --exit-code
256+
run: |
257+
git diff \
258+
--color \
259+
--exit-code

.github/workflows/check-license.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ jobs:
8080
ruby-version: ruby # Install latest version
8181

8282
- name: Install licensee
83-
run: gem install licensee
83+
run: |
84+
gem install \
85+
licensee
8486
8587
- name: Check license file for ${{ matrix.check-license.path }}
8688
run: |
@@ -92,14 +94,26 @@ jobs:
9294
# See: https://github.com/licensee/licensee
9395
LICENSEE_OUTPUT="$(licensee detect --json --confidence=100)"
9496
95-
DETECTED_LICENSE_FILE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].filename | tr --delete '\r')"
97+
DETECTED_LICENSE_FILE="$(
98+
echo "$LICENSEE_OUTPUT" \
99+
| \
100+
jq .matched_files[0].filename \
101+
| \
102+
tr --delete '\r'
103+
)"
96104
echo "Detected license file: $DETECTED_LICENSE_FILE"
97105
if [ "$DETECTED_LICENSE_FILE" != "\"${{ matrix.check-license.expected-filename }}\"" ]; then
98106
echo "::error file=${DETECTED_LICENSE_FILE}::detected license file $DETECTED_LICENSE_FILE doesn't match expected: ${{ matrix.check-license.expected-filename }}"
99107
EXIT_STATUS=1
100108
fi
101109
102-
DETECTED_LICENSE_TYPE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].matched_license | tr --delete '\r')"
110+
DETECTED_LICENSE_TYPE="$(
111+
echo "$LICENSEE_OUTPUT" \
112+
| \
113+
jq .matched_files[0].matched_license \
114+
| \
115+
tr --delete '\r'
116+
)"
103117
echo "Detected license type: $DETECTED_LICENSE_TYPE"
104118
if [ "$DETECTED_LICENSE_TYPE" != "\"${{ matrix.check-license.expected-type }}\"" ]; then
105119
echo "::error file=${DETECTED_LICENSE_FILE}::detected license type $DETECTED_LICENSE_TYPE doesn't match expected \"${{ matrix.check-license.expected-type }}\""

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,7 @@ jobs:
121121
version: 3.x
122122

123123
- name: Check links
124-
run: task --silent markdown:check-links
124+
run: |
125+
task \
126+
--silent \
127+
markdown:check-links

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ jobs:
7979
version: 3.x
8080

8181
- name: Validate package.json
82-
run: task --silent npm:validate PROJECT_PATH="${{ matrix.project.path }}"
82+
run: |
83+
task \
84+
--silent \
85+
npm:validate \
86+
PROJECT_PATH="${{ matrix.project.path }}"
8387
8488
check-sync:
8589
name: check-sync (${{ matrix.project.path }})
@@ -112,7 +116,13 @@ jobs:
112116
version: 3.x
113117

114118
- name: Install npm dependencies
115-
run: task npm:install-deps PROJECT_PATH="${{ matrix.project.path }}"
119+
run: |
120+
task npm:install-deps \
121+
PROJECT_PATH="${{ matrix.project.path }}"
116122
117123
- name: Check package-lock.json
118-
run: git diff --color --exit-code "${{ matrix.project.path }}/package-lock.json"
124+
run: |
125+
git diff \
126+
--color \
127+
--exit-code \
128+
"${{ matrix.project.path }}/package-lock.json"

.github/workflows/check-prettier-formatting-task.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,7 @@ jobs:
255255
run: task general:format-prettier
256256

257257
- name: Check formatting
258-
run: git diff --color --exit-code
258+
run: |
259+
git diff \
260+
--color \
261+
--exit-code

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,7 @@ jobs:
115115
run: task python:format
116116

117117
- name: Check formatting
118-
run: git diff --color --exit-code
118+
run: |
119+
git diff \
120+
--color \
121+
--exit-code

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ jobs:
105105
- name: Install ShellCheck
106106
run: |
107107
cd "${{ env.INSTALL_PATH }}"
108-
tar --extract --file="${{ steps.download.outputs.name }}"
108+
tar \
109+
--extract \
110+
--file="${{ steps.download.outputs.name }}"
109111
EXTRACTION_FOLDER="$(
110112
basename \
111113
"${{ steps.download.outputs.name }}" \
@@ -167,9 +169,13 @@ jobs:
167169
- name: Install shfmt
168170
run: |
169171
# Executable permissions of release assets are lost
170-
chmod +x "${{ env.SHFMT_INSTALL_PATH }}/${{ steps.download.outputs.name }}"
172+
chmod \
173+
+x \
174+
"${{ env.SHFMT_INSTALL_PATH }}/${{ steps.download.outputs.name }}"
171175
# Standardize binary name
172-
mv "${{ env.SHFMT_INSTALL_PATH }}/${{ steps.download.outputs.name }}" "${{ env.SHFMT_INSTALL_PATH }}/shfmt"
176+
mv \
177+
"${{ env.SHFMT_INSTALL_PATH }}/${{ steps.download.outputs.name }}" \
178+
"${{ env.SHFMT_INSTALL_PATH }}/shfmt"
173179
# Add installation to PATH:
174180
# See: https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#adding-a-system-path
175181
echo "${{ env.SHFMT_INSTALL_PATH }}" >>"$GITHUB_PATH"
@@ -182,7 +188,10 @@ jobs:
182188
SCRIPT_PATH="${{ matrix.script }}"
183189
184190
- name: Check formatting
185-
run: git diff --color --exit-code
191+
run: |
192+
git diff \
193+
--color \
194+
--exit-code
186195
187196
executable:
188197
name: executable (${{ matrix.script }})

0 commit comments

Comments
 (0)