From 74401266e6ea7b0a566030a5e735d6c78115adbd Mon Sep 17 00:00:00 2001 From: Mark Wallace <127216156+markwallace-microsoft@users.noreply.github.com> Date: Tue, 20 Jan 2026 14:05:15 +0000 Subject: [PATCH] Improve PR number handling in workflow (#3302) * Improve PR number handling in workflow Refine PR number extraction and validation method. * Update .github/workflows/python-test-coverage-report.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix error message for invalid PR number --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/python-test-coverage-report.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-test-coverage-report.yml b/.github/workflows/python-test-coverage-report.yml index e09d9c8870..92e13f9168 100644 --- a/.github/workflows/python-test-coverage-report.yml +++ b/.github/workflows/python-test-coverage-report.yml @@ -34,9 +34,16 @@ jobs: # because the workflow_run event does not have access to the PR number # The PR number is needed to post the comment on the PR run: | - PR_NUMBER=$(cat pr_number) - echo "PR number: $PR_NUMBER" - echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV + if [ ! -s pr_number ]; then + echo "PR number file 'pr_number' is missing or empty" + exit 1 + fi + PR_NUMBER=$(head -1 pr_number | tr -dc '0-9') + if [ -z "$PR_NUMBER" ]; then + echo "PR number file 'pr_number' does not contain a valid PR number" + exit 1 + fi + echo "PR_NUMBER=$PR_NUMBER" >> "$GITHUB_ENV" - name: Pytest coverage comment id: coverageComment uses: MishaKav/pytest-coverage-comment@v1.2.0