Skip to content

Commit 00618a6

Browse files
committed
fix: argument list too long
1 parent 1de0585 commit 00618a6

File tree

2 files changed

+41
-16
lines changed

2 files changed

+41
-16
lines changed

.github/scripts/generate-locale-matrix.sh

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/bin/bash
22

33
# Script to generate locale deployment matrix based on trigger type and changes
4-
# Usage: ./generate-locale-matrix.sh <trigger-type> [manual-locales] [changes-json]
4+
# Usage: ./generate-locale-matrix.sh <trigger-type> [manual-locales] [changes-json-file]
55
#
66
# trigger-type: "manual", "auto", or "docs-pr"
77
# manual-locales: comma-separated list of locales (for manual trigger)
8-
# changes-json: JSON output from changed-files action (for auto/docs-pr triggers)
8+
# changes-json-file: File path containing JSON output from changed-files action (for auto/docs-pr triggers)
99

1010
set -e
1111

@@ -20,17 +20,17 @@ LOCALE_CONFIG_FILE="$ROOT_DIR/.github/locales-config.json"
2020

2121
# Function to print usage
2222
usage() {
23-
echo "Usage: $0 <trigger-type> [manual-locales] [changes-json]"
23+
echo "Usage: $0 <trigger-type> [manual-locales] [changes-json-file]"
2424
echo ""
2525
echo "Arguments:"
26-
echo " trigger-type Type of trigger: 'manual', 'auto', or 'docs-pr'"
27-
echo " manual-locales Comma-separated list of locales (optional, for manual trigger)"
28-
echo " changes-json JSON output from changed-files action (for auto/docs-pr triggers)"
26+
echo " trigger-type Type of trigger: 'manual', 'auto', or 'docs-pr'"
27+
echo " manual-locales Comma-separated list of locales (optional, for manual trigger)"
28+
echo " changes-json-file File path containing JSON output from changed-files action (for auto/docs-pr triggers)"
2929
echo ""
3030
echo "Examples:"
3131
echo " $0 manual"
3232
echo " $0 manual 'en,zh-hans'"
33-
echo " $0 docs-pr '{\"core_any_changed\": \"true\", \"en_any_changed\": \"false\"}'"
33+
echo " $0 docs-pr '/tmp/changes.json'"
3434
exit 1
3535
}
3636

@@ -186,7 +186,7 @@ process_auto_trigger() {
186186
main() {
187187
local trigger_type="$1"
188188
local manual_locales="$2"
189-
local changes_json="$3"
189+
local changes_json_file="$3"
190190

191191
# Validate arguments
192192
if [ -z "$trigger_type" ]; then
@@ -231,15 +231,28 @@ main() {
231231
matrix_include="$RESULT_MATRIX_INCLUDE"
232232
has_changes="$RESULT_HAS_CHANGES"
233233
else
234-
# For auto and docs-pr triggers, changes_json is required
235-
if [ -z "$changes_json" ]; then
236-
echo "Error: changes-json is required for auto/docs-pr triggers" >&2
234+
# For auto and docs-pr triggers, changes_json_file is required
235+
if [ -z "$changes_json_file" ]; then
236+
echo "Error: changes-json-file is required for auto/docs-pr triggers" >&2
237237
usage
238238
fi
239239

240+
# Check if changes JSON file exists
241+
if [ ! -f "$changes_json_file" ]; then
242+
echo "Error: Changes JSON file not found: $changes_json_file" >&2
243+
exit 1
244+
fi
245+
246+
# Read changes JSON from file
247+
local changes_json
248+
if ! changes_json=$(cat "$changes_json_file"); then
249+
echo "Error: Failed to read changes JSON file: $changes_json_file" >&2
250+
exit 1
251+
fi
252+
240253
# Validate changes JSON
241254
if ! validate_json "$changes_json"; then
242-
echo "Error: Invalid changes JSON provided" >&2
255+
echo "Error: Invalid changes JSON in file: $changes_json_file" >&2
243256
exit 1
244257
fi
245258

.github/scripts/test-locale-scripts.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,37 +97,49 @@ main() {
9797

9898
print_header "Test 4: Auto Trigger - No Changes"
9999
local no_changes_json='{"core_any_changed": "false", "en_any_changed": "false", "zh-hans_any_changed": "false"}'
100+
local temp_file=$(mktemp)
101+
echo "$no_changes_json" > "$temp_file"
100102
if run_test "Auto trigger (no changes)" \
101-
"$SCRIPT_DIR/generate-locale-matrix.sh auto '' '$no_changes_json'" \
103+
"$SCRIPT_DIR/generate-locale-matrix.sh auto '' '$temp_file'" \
102104
"has-changes=false"; then
103105
((passed_count++))
104106
fi
107+
rm -f "$temp_file"
105108
((test_count++))
106109

107110
print_header "Test 5: Auto Trigger - Core Changes"
108111
local core_changes_json='{"core_any_changed": "true", "en_any_changed": "false", "zh-hans_any_changed": "false"}'
112+
local temp_file=$(mktemp)
113+
echo "$core_changes_json" > "$temp_file"
109114
if run_test "Auto trigger (core changes)" \
110-
"$SCRIPT_DIR/generate-locale-matrix.sh auto '' '$core_changes_json'" \
115+
"$SCRIPT_DIR/generate-locale-matrix.sh auto '' '$temp_file'" \
111116
"has-changes=true"; then
112117
((passed_count++))
113118
fi
119+
rm -f "$temp_file"
114120
((test_count++))
115121

116122
print_header "Test 6: Auto Trigger - Locale Changes"
117123
local locale_changes_json='{"core_any_changed": "false", "en_any_changed": "true", "zh-hans_any_changed": "false"}'
124+
local temp_file=$(mktemp)
125+
echo "$locale_changes_json" > "$temp_file"
118126
if run_test "Auto trigger (locale changes)" \
119-
"$SCRIPT_DIR/generate-locale-matrix.sh auto '' '$locale_changes_json'" \
127+
"$SCRIPT_DIR/generate-locale-matrix.sh auto '' '$temp_file'" \
120128
"has-changes=true"; then
121129
((passed_count++))
122130
fi
131+
rm -f "$temp_file"
123132
((test_count++))
124133

125134
print_header "Test 7: Docs PR Trigger"
135+
local temp_file=$(mktemp)
136+
echo "$core_changes_json" > "$temp_file"
126137
if run_test "Docs PR trigger" \
127-
"$SCRIPT_DIR/generate-locale-matrix.sh docs-pr '' '$core_changes_json'" \
138+
"$SCRIPT_DIR/generate-locale-matrix.sh docs-pr '' '$temp_file'" \
128139
"has-changes=true"; then
129140
((passed_count++))
130141
fi
142+
rm -f "$temp_file"
131143
((test_count++))
132144

133145
print_header "Test 8: Error Handling - Invalid Trigger Type"

0 commit comments

Comments
 (0)