Skip to content

Commit 448d398

Browse files
committed
Annotate build with failed genestrings messages
1 parent 66d8818 commit 448d398

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

.buildkite/commands/lint-localized-strings-format.sh

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,33 @@ mkdir -pv ~/.configure/wordpress-ios/secrets
1111
cp -v fastlane/env/project.env-example ~/.configure/wordpress-ios/secrets/project.env
1212

1313
echo "--- Lint Localized Strings Format"
14-
bundle exec fastlane generate_strings_file_for_glotpress skip_commit:true
14+
LOGS=logs.txt
15+
set +e
16+
set -o pipefail
17+
bundle exec fastlane generate_strings_file_for_glotpress skip_commit:true | tee $LOGS
18+
EXIT_CODE=$?
19+
set -e
20+
21+
echo $EXIT_CODE
22+
23+
if [[ $EXIT_CODE -ne 0 ]]; then
24+
# Strings generation finished with errors, extract the errors in an easy-to-find section
25+
echo "--- Report genstrings errors"
26+
ERRORS=errors.txt
27+
echo "Found errors when trying to run \`genstrings\` to generate the \`.strings\` files from \`*LocalizedStrings\` calls:" | tee $ERRORS
28+
echo '' >> $ERRORS
29+
# Print the errors inline.
30+
#
31+
# Notice the second `sed` call that removes the ANSI escape sequences that
32+
# Fastlane uses to color the output.
33+
grep -e "\[.*\].*genstrings:" $LOGS \
34+
| sed -e 's/\[.*\].*genstrings: error: /- /' \
35+
| sed -e $'s/\x1b\[[0-9;]*m//g' \
36+
| sort \
37+
| uniq \
38+
| tee -a $ERRORS
39+
# Annotate the build with the errors
40+
cat $ERRORS | buildkite-agent annotate --style error --context genstrings
41+
fi
42+
43+
exit $EXIT_CODE

0 commit comments

Comments
 (0)