Skip to content

Commit ec9ee93

Browse files
authored
[red-knot] mypy_primer: strip ANSI codes (#16604)
## Summary Strip ANSI codes in the mypy_primer diff before uploading. ## Test Plan Successful run here: #16601
1 parent a73548d commit ec9ee93

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

.github/workflows/mypy_primer.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- "crates/ruff_python_ast"
1111
- "crates/ruff_python_parser"
1212
- ".github/workflows/mypy_primer.yaml"
13+
- ".github/workflows/mypy_primer_comment.yaml"
1314

1415
concurrency:
1516
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
@@ -67,7 +68,7 @@ jobs:
6768
--new "$GITHUB_SHA" \
6869
--project-selector '/(mypy_primer|black|pyp|git-revise|zipp|arrow)$' \
6970
--output concise \
70-
--debug | tee mypy_primer.diff
71+
--debug | tee /dev/stdout | sed -e 's/\x1b\[[0-9;]*m//g' > mypy_primer.diff
7172
) || [ $? -eq 1 ]
7273
7374
echo ${{ github.event.number }} > pr-number

.github/workflows/mypy_primer_comment.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ jobs:
6262
echo '<!-- generated-comment mypy_primer -->' >> comment.txt
6363
6464
echo '## `mypy_primer` results' >> comment.txt
65-
echo '```diff' >> comment.txt
66-
cat pr/mypy_primer_diff/mypy_primer.diff >> comment.txt
67-
echo '```' >> comment.txt
65+
if [ -s "pr/mypy_primer_diff/mypy_primer.diff" ]; then
66+
echo '```diff' >> comment.txt
67+
cat pr/mypy_primer_diff/mypy_primer.diff >> comment.txt
68+
echo '```' >> comment.txt
69+
else
70+
echo 'No ecosystem changes detected ✅' >> comment.txt
71+
fi
6872
6973
echo 'comment<<EOF' >> "$GITHUB_OUTPUT"
7074
cat comment.txt >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)