From ec9ee93d68e887830507e9d674be9e4131648a05 Mon Sep 17 00:00:00 2001 From: David Peter Date: Mon, 10 Mar 2025 17:32:01 +0100 Subject: [PATCH] [red-knot] mypy_primer: strip ANSI codes (#16604) ## Summary Strip ANSI codes in the mypy_primer diff before uploading. ## Test Plan Successful run here: https://github.com/astral-sh/ruff/pull/16601 --- .github/workflows/mypy_primer.yaml | 3 ++- .github/workflows/mypy_primer_comment.yaml | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mypy_primer.yaml b/.github/workflows/mypy_primer.yaml index 77366c5684..42333f7978 100644 --- a/.github/workflows/mypy_primer.yaml +++ b/.github/workflows/mypy_primer.yaml @@ -10,6 +10,7 @@ on: - "crates/ruff_python_ast" - "crates/ruff_python_parser" - ".github/workflows/mypy_primer.yaml" + - ".github/workflows/mypy_primer_comment.yaml" concurrency: group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }} @@ -67,7 +68,7 @@ jobs: --new "$GITHUB_SHA" \ --project-selector '/(mypy_primer|black|pyp|git-revise|zipp|arrow)$' \ --output concise \ - --debug | tee mypy_primer.diff + --debug | tee /dev/stdout | sed -e 's/\x1b\[[0-9;]*m//g' > mypy_primer.diff ) || [ $? -eq 1 ] echo ${{ github.event.number }} > pr-number diff --git a/.github/workflows/mypy_primer_comment.yaml b/.github/workflows/mypy_primer_comment.yaml index 1c24ece195..f44fbfe1d1 100644 --- a/.github/workflows/mypy_primer_comment.yaml +++ b/.github/workflows/mypy_primer_comment.yaml @@ -62,9 +62,13 @@ jobs: echo '' >> comment.txt echo '## `mypy_primer` results' >> comment.txt - echo '```diff' >> comment.txt - cat pr/mypy_primer_diff/mypy_primer.diff >> comment.txt - echo '```' >> comment.txt + if [ -s "pr/mypy_primer_diff/mypy_primer.diff" ]; then + echo '```diff' >> comment.txt + cat pr/mypy_primer_diff/mypy_primer.diff >> comment.txt + echo '```' >> comment.txt + else + echo 'No ecosystem changes detected ✅' >> comment.txt + fi echo 'comment<> "$GITHUB_OUTPUT" cat comment.txt >> "$GITHUB_OUTPUT"