Skip to content

Commit b0bf2b1

Browse files
committed
chore: Cleaning up other scripts with shellcheck and shfmt
1 parent 9481189 commit b0bf2b1

47 files changed

Lines changed: 1425 additions & 1390 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/scripts/coverage/compare-coverage.sh

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,28 +71,28 @@ jq -n \
7171
# Generate HTML report
7272
{
7373
cat <<-HEADER
74-
<!DOCTYPE html>
75-
<html><head>
76-
<meta charset="utf-8">
77-
<title>Coverage Comparison</title>
78-
<style>
79-
body { font-family: monospace; margin: 2em; }
80-
table { border-collapse: collapse; width: 100%; }
81-
th, td { border: 1px solid #ccc; padding: 6px 12px; text-align: right; }
82-
th { background: #f5f5f5; }
83-
td:first-child, th:first-child { text-align: left; }
84-
tr.total { font-weight: bold; border-top: 2px solid #333; }
85-
tr.new td, tr.removed td { font-style: italic; }
86-
</style>
87-
</head><body>
88-
<h2>Coverage Comparison</h2>
89-
<table>
90-
<tr><td>Base</td><td>${PREV_REF} (${PREV_COMMIT:0:12})</td><td>${PREV_TS}</td></tr>
91-
<tr><td>Head</td><td>${CURR_REF} (${CURR_COMMIT:0:12})</td><td>${CURR_TS}</td></tr>
92-
</table>
93-
<br>
94-
<table>
95-
<tr><th>Package</th><th>Base %</th><th>Head %</th><th>Delta</th></tr>
74+
<!DOCTYPE html>
75+
<html><head>
76+
<meta charset="utf-8">
77+
<title>Coverage Comparison</title>
78+
<style>
79+
body { font-family: monospace; margin: 2em; }
80+
table { border-collapse: collapse; width: 100%; }
81+
th, td { border: 1px solid #ccc; padding: 6px 12px; text-align: right; }
82+
th { background: #f5f5f5; }
83+
td:first-child, th:first-child { text-align: left; }
84+
tr.total { font-weight: bold; border-top: 2px solid #333; }
85+
tr.new td, tr.removed td { font-style: italic; }
86+
</style>
87+
</head><body>
88+
<h2>Coverage Comparison</h2>
89+
<table>
90+
<tr><td>Base</td><td>${PREV_REF} (${PREV_COMMIT:0:12})</td><td>${PREV_TS}</td></tr>
91+
<tr><td>Head</td><td>${CURR_REF} (${CURR_COMMIT:0:12})</td><td>${CURR_TS}</td></tr>
92+
</table>
93+
<br>
94+
<table>
95+
<tr><th>Package</th><th>Base %</th><th>Head %</th><th>Delta</th></tr>
9696
HEADER
9797

9898
# Total row
@@ -109,8 +109,8 @@ jq -n \
109109
end' <<<"$PACKAGE_COMPARISON"
110110

111111
cat <<-FOOTER
112-
</table>
113-
</body></html>
112+
</table>
113+
</body></html>
114114
FOOTER
115115
} >"$HTML_OUTPUT"
116116

.github/scripts/coverage/download-previous-release.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ mkdir -p "$OUTPUT_DIR"
99

1010
# Paginate all releases to ensure TAG_NAME is in the list
1111
ALL_TAGS=$(gh api --paginate "repos/{owner}/{repo}/releases" \
12-
--jq '[.[] | select(.draft == false and .prerelease == false) | .tag_name]' \
13-
| jq -s 'add // []')
12+
--jq '[.[] | select(.draft == false and .prerelease == false) | .tag_name]' |
13+
jq -s 'add // []')
1414

1515
PREV_TAG=$(jq -r --arg tag "$TAG_NAME" '
1616
index($tag) as $i |

.github/scripts/coverage/generate-summary.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ TOTAL=$(go tool cover -func="$COVER_FILE" | grep '^total:' | awk '{print $NF}' |
1414

1515
# Build per-package JSON: average coverage per package (go tool cover reports per-function)
1616
# awk outputs TSV lines, jq handles JSON escaping safely
17-
PACKAGES_JSON=$(go tool cover -func="$COVER_FILE" \
18-
| grep -v '^total:' \
19-
| awk -F'\t+' '{
17+
PACKAGES_JSON=$(go tool cover -func="$COVER_FILE" |
18+
grep -v '^total:' |
19+
awk -F'\t+' '{
2020
split($1, parts, ":")
2121
file = parts[1]
2222
n = split(file, segs, "/")

.github/scripts/gopls/check-for-changes.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ set -euo pipefail
55
: "${HAS_FIXES:?}"
66

77
if [[ "$HAS_FIXES" != "true" ]]; then
8-
echo "has_changes=false" >> "$GITHUB_OUTPUT"
9-
exit 0
8+
echo "has_changes=false" >>"$GITHUB_OUTPUT"
9+
exit 0
1010
fi
1111

1212
if git diff --staged --quiet; then
13-
echo "has_changes=false" >> "$GITHUB_OUTPUT"
14-
exit 0
13+
echo "has_changes=false" >>"$GITHUB_OUTPUT"
14+
exit 0
1515
fi
1616

17-
echo "has_changes=true" >> "$GITHUB_OUTPUT"
17+
echo "has_changes=true" >>"$GITHUB_OUTPUT"

.github/scripts/gopls/run.sh

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,31 @@ touch "$FAILURES_FILE"
1616
touch "$OUTPUT_FILE"
1717

1818
while IFS= read -r file; do
19-
echo "START: $file" | tee -a "$OUTPUT_FILE"
19+
echo "START: $file" | tee -a "$OUTPUT_FILE"
2020

21-
if gopls codeaction -kind=quickfix -write "$file"; then
22-
echo "SUCCESS: $file" | tee -a "$OUTPUT_FILE"
23-
else
24-
echo "FAILED: $file" | tee -a "$FAILURES_FILE" "$OUTPUT_FILE"
25-
echo "$file" >> "$FIXED_FILES"
26-
fi
21+
if gopls codeaction -kind=quickfix -write "$file"; then
22+
echo "SUCCESS: $file" | tee -a "$OUTPUT_FILE"
23+
else
24+
echo "FAILED: $file" | tee -a "$FAILURES_FILE" "$OUTPUT_FILE"
25+
echo "$file" >>"$FIXED_FILES"
26+
fi
2727

28-
echo "END: $file" | tee -a "$OUTPUT_FILE"
29-
done < gofiles.txt
28+
echo "END: $file" | tee -a "$OUTPUT_FILE"
29+
done <gofiles.txt
3030

3131
printf '\n==== gopls failures (if any) ====\n' | tee -a "$OUTPUT_FILE"
32-
tee -a "$OUTPUT_FILE" < "$FAILURES_FILE" || true
32+
tee -a "$OUTPUT_FILE" <"$FAILURES_FILE" || true
3333

3434
# Check if any files were modified
3535
if [[ -s "$FIXED_FILES" ]]; then
36-
echo "has_fixes=true" >> "$GITHUB_OUTPUT"
37-
echo "Files with fixes:" | tee -a "$OUTPUT_FILE"
38-
tee -a "$OUTPUT_FILE" < "$FIXED_FILES"
36+
echo "has_fixes=true" >>"$GITHUB_OUTPUT"
37+
echo "Files with fixes:" | tee -a "$OUTPUT_FILE"
38+
tee -a "$OUTPUT_FILE" <"$FIXED_FILES"
3939
else
40-
echo "has_fixes=false" >> "$GITHUB_OUTPUT"
41-
echo "No files were modified by gopls quickfixes" | tee -a "$OUTPUT_FILE"
40+
echo "has_fixes=false" >>"$GITHUB_OUTPUT"
41+
echo "No files were modified by gopls quickfixes" | tee -a "$OUTPUT_FILE"
4242
fi
4343

4444
# Output file paths for other steps to use
45-
echo "fixed_files_path=$FIXED_FILES" >> "$GITHUB_OUTPUT"
46-
echo "output_file_path=$OUTPUT_FILE" >> "$GITHUB_OUTPUT"
45+
echo "fixed_files_path=$FIXED_FILES" >>"$GITHUB_OUTPUT"
46+
echo "output_file_path=$OUTPUT_FILE" >>"$GITHUB_OUTPUT"

.github/scripts/release/create-archives.sh

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,46 @@ set -euo pipefail
66
# Usage: create-archives.sh <bin-directory>
77

88
function main {
9-
local -r bin_dir="${1:-bin}"
10-
11-
if [[ ! -d "$bin_dir" ]]; then
12-
echo "ERROR: Directory $bin_dir does not exist" >&2
13-
exit 1
14-
fi
15-
16-
# Use pushd/popd to avoid side effects on caller's working directory
17-
pushd "$bin_dir" || return 1
18-
19-
echo "Creating individual archives for each binary..."
20-
21-
# Create individual ZIP and TAR.GZ archives for each binary (preserving execute permissions)
22-
for binary in terragrunt_*; do
23-
# Skip if it's already an archive file
24-
if [[ "$binary" == *.zip ]] || [[ "$binary" == *.tar.gz ]]; then
25-
continue
26-
fi
27-
28-
# Create ZIP archive
29-
zip "$binary.zip" "$binary"
30-
echo "Created: $binary.zip"
31-
32-
# Create TAR.GZ archive (preserves Unix permissions including +x)
33-
tar -czf "$binary.tar.gz" "$binary"
34-
echo "Created: $binary.tar.gz"
35-
done
36-
37-
echo ""
38-
echo "All individual archives created:"
39-
echo "ZIP archives:"
40-
ls -lh *.zip
41-
echo ""
42-
echo "TAR.GZ archives:"
43-
ls -lh *.tar.gz
44-
45-
# Return to original directory
46-
popd || return 1
47-
48-
return 0
9+
local -r bin_dir="${1:-bin}"
10+
11+
if [[ ! -d "$bin_dir" ]]; then
12+
echo "ERROR: Directory $bin_dir does not exist" >&2
13+
exit 1
14+
fi
15+
16+
# Use pushd/popd to avoid side effects on caller's working directory
17+
pushd "$bin_dir" || return 1
18+
19+
echo "Creating individual archives for each binary..."
20+
21+
# Create individual ZIP and TAR.GZ archives for each binary (preserving execute permissions)
22+
for binary in terragrunt_*; do
23+
# Skip if it's already an archive file
24+
if [[ "$binary" == *.zip ]] || [[ "$binary" == *.tar.gz ]]; then
25+
continue
26+
fi
27+
28+
# Create ZIP archive
29+
zip "$binary.zip" "$binary"
30+
echo "Created: $binary.zip"
31+
32+
# Create TAR.GZ archive (preserves Unix permissions including +x)
33+
tar -czf "$binary.tar.gz" "$binary"
34+
echo "Created: $binary.tar.gz"
35+
done
36+
37+
echo ""
38+
echo "All individual archives created:"
39+
echo "ZIP archives:"
40+
ls -lh -- *.zip
41+
echo ""
42+
echo "TAR.GZ archives:"
43+
ls -lh -- *.tar.gz
44+
45+
# Return to original directory
46+
popd || return 1
47+
48+
return 0
4949
}
5050

5151
main "$@"

.github/scripts/release/generate-checksums.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@ set -euo pipefail
66
# Usage: generate-checksums.sh <bin-directory>
77

88
function main {
9-
local -r bin_dir="${1:-bin}"
9+
local -r bin_dir="${1:-bin}"
1010

11-
if [[ ! -d "$bin_dir" ]]; then
12-
echo "ERROR: Directory $bin_dir does not exist" >&2
13-
exit 1
14-
fi
11+
if [[ ! -d "$bin_dir" ]]; then
12+
echo "ERROR: Directory $bin_dir does not exist" >&2
13+
exit 1
14+
fi
1515

16-
# Use pushd/popd to avoid side effects on caller's working directory
17-
pushd "$bin_dir" || return 1
16+
# Use pushd/popd to avoid side effects on caller's working directory
17+
pushd "$bin_dir" || return 1
1818

19-
# Generate checksums for all files including individual ZIPs and TAR.GZ archives
20-
sha256sum terragrunt_* > SHA256SUMS
19+
# Generate checksums for all files including individual ZIPs and TAR.GZ archives
20+
sha256sum terragrunt_* >SHA256SUMS
2121

22-
echo "SHA256SUMS generated:"
23-
cat SHA256SUMS
22+
echo "SHA256SUMS generated:"
23+
cat SHA256SUMS
2424

25-
echo ""
26-
echo "Total files with checksums: $(wc -l < SHA256SUMS)"
25+
echo ""
26+
echo "Total files with checksums: $(wc -l <SHA256SUMS)"
2727

28-
# Return to original directory
29-
popd || return 1
28+
# Return to original directory
29+
popd || return 1
3030

31-
return 0
31+
return 0
3232
}
3333

3434
main "$@"

.github/scripts/release/generate-upload-summary.sh

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@ set -euo pipefail
1515
source "$(dirname "$0")/lib-release-config.sh"
1616

1717
main() {
18-
require_env_vars VERSION RELEASE_ID IS_DRAFT GITHUB_STEP_SUMMARY
19-
verify_config_file
18+
require_env_vars VERSION RELEASE_ID IS_DRAFT GITHUB_STEP_SUMMARY
19+
verify_config_file
2020

21-
echo "Generating upload summary..."
21+
echo "Generating upload summary..."
2222

23-
local binary_count
24-
binary_count=$(get_binary_count)
25-
local total_count
26-
total_count=$(get_total_file_count)
23+
local binary_count
24+
binary_count=$(get_binary_count)
25+
local total_count
26+
total_count=$(get_total_file_count)
2727

28-
cat >>"$GITHUB_STEP_SUMMARY" <<EOF
28+
{
29+
cat <<EOF
2930
## Release Asset Upload Summary
3031
3132
**Version**: $VERSION
@@ -38,10 +39,10 @@ main() {
3839
|----------|--------------|--------|--------|
3940
EOF
4041

41-
# Generate platform table rows from configuration
42-
generate_platform_table_rows >>"$GITHUB_STEP_SUMMARY"
42+
# Generate platform table rows from configuration
43+
generate_platform_table_rows
4344

44-
cat >>"$GITHUB_STEP_SUMMARY" <<EOF
45+
cat <<EOF
4546
4647
**Archive Files**:
4748
- Individual ZIP archives: $binary_count files (one per binary, with +x permissions)
@@ -52,27 +53,28 @@ EOF
5253
5354
All assets uploaded successfully to existing release!
5455
EOF
56+
} >>"$GITHUB_STEP_SUMMARY"
5557

56-
echo "Upload summary generated successfully"
58+
echo "Upload summary generated successfully"
5759

58-
return 0
60+
return 0
5961
}
6062

6163
require_env_vars() {
62-
local missing=0
64+
local missing=0
6365

64-
for var_name in "$@"; do
65-
if [[ -z "${!var_name:-}" ]]; then
66-
echo "ERROR: Required environment variable $var_name not set." >&2
67-
missing=1
68-
fi
69-
done
66+
for var_name in "$@"; do
67+
if [[ -z "${!var_name:-}" ]]; then
68+
echo "ERROR: Required environment variable $var_name not set." >&2
69+
missing=1
70+
fi
71+
done
7072

71-
if [[ "$missing" -eq 1 ]]; then
72-
exit 1
73-
fi
73+
if [[ "$missing" -eq 1 ]]; then
74+
exit 1
75+
fi
7476

75-
return 0
77+
return 0
7678
}
7779

7880
main "$@"

0 commit comments

Comments
 (0)