Skip to content

Commit

Permalink
Update lint-and-sample-feature-check.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
jbigel authored Aug 1, 2024
1 parent a6d0503 commit 87b85d2
Showing 1 changed file with 36 additions and 27 deletions.
63 changes: 36 additions & 27 deletions .github/workflows/lint-and-sample-feature-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,35 +101,44 @@ jobs:
id: comment
run: |
if grep -q "Build failed" sampleRunOutput.txt; then
grep -A 5 "Build failed" sampleRunOutput.txt > buildErrors.txt
cat buildErrors.txt
# Extract build errors
grep -A 10 "Build failed" sampleRunOutput.txt > buildErrors.txt
# Prepare the comment
{
echo 'Build error occurred while running sample test with the following errors:'
echo ''
echo '```'
cat buildErrors.txt
echo '```'
echo ''
echo 'For more information on our testing policies, please see our [Testing-Guide](../tree/dev/Testing-Guide.md).'
echo ''
} > pr_comment.txt
# Verify the content
echo 'Build error occurred while running sample test with the following errors:' > pr_comment.txt
echo '\n' >> pr_comment.txt
echo '```' >> pr_comment.txt
cat buildErrors.txt >> pr_comment.txt
echo '```' >> pr_comment.txt
echo '\n' >> pr_comment.txt
echo 'For more information on our testing policies, please see our [Testing-Guide](../tree/dev/Testing-Guide.md).' >> pr_comment.txt
echo '\n' >> pr_comment.txt
cat pr_comment.txt

# Escape newlines and set the output
pr_comment=$(<pr_comment.txt)
pr_comment="${pr_comment//'%'/'%25'}"
pr_comment="${pr_comment//$'\n'/'%0A'}"
pr_comment="${pr_comment//$'\r'/'%0D'}"
echo "PR_COMMENT=$pr_comment" >> "$GITHUB_OUTPUT"

# Verify the output variable
echo "PR_COMMENT=$pr_comment"

escaped_comment=$(awk '{printf "%s\\n", $0}' pr_comment.txt)
echo $escaped_comment
# awk '{printf "%s\\n", $0}' pr_comment.txt > test.txt
# cat test.txt
echo "PR_COMMENT=$escaped_comment" >> "$GITHUB_OUTPUT"
echo "$GITHUB_OUTPUT"
# {
# echo 'PR_COMMENT<<EOF'
# echo -n 'Build error occured while running sample test with the following errors:\n'
# echo -n '```\n'
# awk '{printf "%s\\n", $0}' buildErrors.txt
# echo -n '```\n'
# echo -n '\n'
# echo 'For more information on our testing policies, please see our [Testing-Guide](../tree/dev/Testing-Guide.md).\n'
# echo '\n'
# echo 'EOF'
# } >> "$GITHUB_OUTPUT"
echo "made it here"
# echo "$GITHUB_OUTPUT"
exit 1
fi
Expand Down

0 comments on commit 87b85d2

Please sign in to comment.