From 964c9677de38fbb7d8e7c3c4c626a595f022225c Mon Sep 17 00:00:00 2001 From: Derrick Williams Date: Fri, 6 Feb 2026 22:40:36 +0000 Subject: [PATCH 1/8] update coverage details to improve reporting --- sdks/python/.coveragerc | 1 + sdks/python/scripts/run_pytest.sh | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sdks/python/.coveragerc b/sdks/python/.coveragerc index 52f97cdff789..b014f740097d 100644 --- a/sdks/python/.coveragerc +++ b/sdks/python/.coveragerc @@ -16,4 +16,5 @@ # [run] +parallel = True omit = target/* \ No newline at end of file diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index ec1cc2547fef..21a431fe4442 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -150,6 +150,14 @@ fi if [[ $status1 != 0 && $status1 != 5 ]]; then exit $status1 fi -if [[ $status2 != 0 && $status2 != 5 ]]; then - exit $status2 +# Combine coverage data if parallel was used. +if [ -f .coveragerc ] && grep -q "parallel = True" .coveragerc; then + echo "Combining coverage data..." + coverage combine + if [[ $pytest_args == *"--cov-report=xml"* ]]; then + echo "Generating XML report..." + coverage xml + fi fi + +exit 0 From f9570485eda40cbf17b7fc658ad79d3621fb3686 Mon Sep 17 00:00:00 2001 From: Derrick Williams Date: Sat, 7 Feb 2026 04:16:37 +0000 Subject: [PATCH 2/8] try to address the 429 error and update logic --- .../workflows/beam_PreCommit_Python_Coverage.yml | 6 ++++-- sdks/python/scripts/run_pytest.sh | 14 ++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/beam_PreCommit_Python_Coverage.yml b/.github/workflows/beam_PreCommit_Python_Coverage.yml index a0e0db3bf9b0..7fc6f7b152cd 100644 --- a/.github/workflows/beam_PreCommit_Python_Coverage.yml +++ b/.github/workflows/beam_PreCommit_Python_Coverage.yml @@ -127,10 +127,12 @@ jobs: '-m (not require_docker_in_docker)' || '-m require_docker_in_docker' }}" - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v5 with: flags: python - directory: sdks/python + files: "sdks/python/**/coverage.xml" + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true - name: Archive Python Test Results uses: actions/upload-artifact@v4 if: failure() diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index 21a431fe4442..41536441075a 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -25,7 +25,6 @@ # $2 - additional arguments not parsed by tox (typically module names or # '-k keyword') # $3 - optional arguments to pytest -#!/bin/bash envname=${1?First argument required: suite base name} posargs=$2 @@ -151,12 +150,19 @@ if [[ $status1 != 0 && $status1 != 5 ]]; then exit $status1 fi # Combine coverage data if parallel was used. -if [ -f .coveragerc ] && grep -q "parallel = True" .coveragerc; then +# If .coveragerc is not found locally, look for it in the directory of the script or sdk root. +COVERAGERC_PATH=".coveragerc" +if [ ! -f "$COVERAGERC_PATH" ]; then + COVERAGERC_PATH="$(dirname "$0")/../.coveragerc" +fi + +if [ -f "$COVERAGERC_PATH" ] && grep -q "parallel = True" "$COVERAGERC_PATH"; then echo "Combining coverage data..." - coverage combine + # coverage combine will use the .coveragerc to find data files. + coverage combine --rcfile="$COVERAGERC_PATH" if [[ $pytest_args == *"--cov-report=xml"* ]]; then echo "Generating XML report..." - coverage xml + coverage xml --rcfile="$COVERAGERC_PATH" fi fi From 35b5e2207124b4c4ac68e2dd4bd12dbc378e2e39 Mon Sep 17 00:00:00 2001 From: Derrick Williams Date: Sat, 7 Feb 2026 16:59:27 +0000 Subject: [PATCH 3/8] fix token --- .github/workflows/beam_PreCommit_Python_Coverage.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/beam_PreCommit_Python_Coverage.yml b/.github/workflows/beam_PreCommit_Python_Coverage.yml index 7fc6f7b152cd..330df4354bc9 100644 --- a/.github/workflows/beam_PreCommit_Python_Coverage.yml +++ b/.github/workflows/beam_PreCommit_Python_Coverage.yml @@ -130,9 +130,13 @@ jobs: - uses: codecov/codecov-action@v5 with: flags: python - files: "sdks/python/**/coverage.xml" + files: "**/sdks/python/**/coverage.xml" token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true + verbose: true + directory: sdks/python + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - name: Archive Python Test Results uses: actions/upload-artifact@v4 if: failure() From 64f9a3faf1345a32f2b95928c6225337bb4d99c9 Mon Sep 17 00:00:00 2001 From: Derrick Williams Date: Sat, 7 Feb 2026 22:19:32 +0000 Subject: [PATCH 4/8] another try --- .../beam_PreCommit_Python_Coverage.yml | 19 ++++++++++++------- sdks/python/tox.ini | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/beam_PreCommit_Python_Coverage.yml b/.github/workflows/beam_PreCommit_Python_Coverage.yml index 330df4354bc9..7729b141ab1d 100644 --- a/.github/workflows/beam_PreCommit_Python_Coverage.yml +++ b/.github/workflows/beam_PreCommit_Python_Coverage.yml @@ -127,16 +127,21 @@ jobs: '-m (not require_docker_in_docker)' || '-m require_docker_in_docker' }}" - - uses: codecov/codecov-action@v5 + - name: Find Coverage Report + id: find-coverage + run: | + # Locate the actual coverage.xml, ignoring JUnit XMLs + REPORT=$(find sdks/python -name "coverage.xml" | grep -v "pytest_" | head -n 1) + if [ -z "$REPORT" ]; then + echo "No coverage.xml found" + exit 1 + fi + echo "REPORT_PATH=$REPORT" >> $GITHUB_OUTPUT + - uses: codecov/codecov-action@v3 with: flags: python - files: "**/sdks/python/**/coverage.xml" - token: ${{ secrets.CODECOV_TOKEN }} + file: ${{ steps.find-coverage.outputs.REPORT_PATH }} fail_ci_if_error: true - verbose: true - directory: sdks/python - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - name: Archive Python Test Results uses: actions/upload-artifact@v4 if: failure() diff --git a/sdks/python/tox.ini b/sdks/python/tox.ini index a86111a45c63..c27dfce925b0 100644 --- a/sdks/python/tox.ini +++ b/sdks/python/tox.ini @@ -173,7 +173,7 @@ setenv = TC_SLEEP_TIME = {env:TC_SLEEP_TIME:1} # NOTE: we could add ml_test to increase the collected code coverage metrics, but it would make the suite slower. -extras = test,hadoop,gcp,interactive,dataframe,aws,redis +extras = test,hadoop,gcp,interactive,dataframe,aws,redis,ml_test commands = bash {toxinidir}/scripts/run_pytest.sh {envname} "{posargs}" "--cov-report=xml --cov=. --cov-append" From 5377df0ae9362c9c3be13d92be87bfe31f61c525 Mon Sep 17 00:00:00 2001 From: Derrick Williams Date: Sun, 8 Feb 2026 00:58:09 +0000 Subject: [PATCH 5/8] reverting some changes --- sdks/python/.coveragerc | 8 +++++++- sdks/python/tox.ini | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sdks/python/.coveragerc b/sdks/python/.coveragerc index b014f740097d..323a405b92a0 100644 --- a/sdks/python/.coveragerc +++ b/sdks/python/.coveragerc @@ -17,4 +17,10 @@ [run] parallel = True -omit = target/* \ No newline at end of file +omit = target/* +source = apache_beam + +[paths] +source = + apache_beam + **/site-packages/apache_beam \ No newline at end of file diff --git a/sdks/python/tox.ini b/sdks/python/tox.ini index c27dfce925b0..a86111a45c63 100644 --- a/sdks/python/tox.ini +++ b/sdks/python/tox.ini @@ -173,7 +173,7 @@ setenv = TC_SLEEP_TIME = {env:TC_SLEEP_TIME:1} # NOTE: we could add ml_test to increase the collected code coverage metrics, but it would make the suite slower. -extras = test,hadoop,gcp,interactive,dataframe,aws,redis,ml_test +extras = test,hadoop,gcp,interactive,dataframe,aws,redis commands = bash {toxinidir}/scripts/run_pytest.sh {envname} "{posargs}" "--cov-report=xml --cov=. --cov-append" From cefdf6a9bb9dc9e6e71900c6e2e494017931f2f8 Mon Sep 17 00:00:00 2001 From: Derrick Williams Date: Sun, 8 Feb 2026 01:24:57 +0000 Subject: [PATCH 6/8] change coveragerc --- sdks/python/.coveragerc | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/sdks/python/.coveragerc b/sdks/python/.coveragerc index 323a405b92a0..b014f740097d 100644 --- a/sdks/python/.coveragerc +++ b/sdks/python/.coveragerc @@ -17,10 +17,4 @@ [run] parallel = True -omit = target/* -source = apache_beam - -[paths] -source = - apache_beam - **/site-packages/apache_beam \ No newline at end of file +omit = target/* \ No newline at end of file From 31dc6bae7b2498da569288d250adf3a3e5405472 Mon Sep 17 00:00:00 2001 From: Derrick Williams Date: Sun, 8 Feb 2026 02:16:40 +0000 Subject: [PATCH 7/8] another try --- .github/workflows/beam_PreCommit_Python_Coverage.yml | 2 ++ sdks/python/.coveragerc | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/beam_PreCommit_Python_Coverage.yml b/.github/workflows/beam_PreCommit_Python_Coverage.yml index 7729b141ab1d..945c95aacfda 100644 --- a/.github/workflows/beam_PreCommit_Python_Coverage.yml +++ b/.github/workflows/beam_PreCommit_Python_Coverage.yml @@ -138,9 +138,11 @@ jobs: fi echo "REPORT_PATH=$REPORT" >> $GITHUB_OUTPUT - uses: codecov/codecov-action@v3 + if: steps.find-coverage.outputs.REPORT_PATH != '' with: flags: python file: ${{ steps.find-coverage.outputs.REPORT_PATH }} + token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true - name: Archive Python Test Results uses: actions/upload-artifact@v4 diff --git a/sdks/python/.coveragerc b/sdks/python/.coveragerc index b014f740097d..d61ded45feaa 100644 --- a/sdks/python/.coveragerc +++ b/sdks/python/.coveragerc @@ -17,4 +17,10 @@ [run] parallel = True -omit = target/* \ No newline at end of file +omit = target/* + +[paths] +source = + apache_beam + **/site-packages/apache_beam + **/build/srcs/sdks/python/apache_beam \ No newline at end of file From 5fb031a08d81c397fb8725b85fe3285e5decec8b Mon Sep 17 00:00:00 2001 From: Derrick Williams Date: Sun, 8 Feb 2026 03:09:31 +0000 Subject: [PATCH 8/8] another try --- .../beam_PreCommit_Python_Coverage.yml | 1 - sdks/python/scripts/run_pytest.sh | 20 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/beam_PreCommit_Python_Coverage.yml b/.github/workflows/beam_PreCommit_Python_Coverage.yml index 945c95aacfda..3f733a9ab569 100644 --- a/.github/workflows/beam_PreCommit_Python_Coverage.yml +++ b/.github/workflows/beam_PreCommit_Python_Coverage.yml @@ -142,7 +142,6 @@ jobs: with: flags: python file: ${{ steps.find-coverage.outputs.REPORT_PATH }} - token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true - name: Archive Python Test Results uses: actions/upload-artifact@v4 diff --git a/sdks/python/scripts/run_pytest.sh b/sdks/python/scripts/run_pytest.sh index 41536441075a..df0486021441 100755 --- a/sdks/python/scripts/run_pytest.sh +++ b/sdks/python/scripts/run_pytest.sh @@ -133,22 +133,21 @@ echo "Running parallel tests with: pytest -m \"$marker_for_parallel_tests\" $pyt pytest -v -rs -o junit_suite_name=${envname} \ --junitxml=pytest_${envname}.xml -m "$marker_for_parallel_tests" -n 6 --import-mode=importlib ${pytest_args} ${pytest_command_args} status1=$? +echo "Parallel tests finished with status $status1" # Run tests sequentially. echo "Running sequential tests with: pytest -m \"$marker_for_sequential_tests\" $pytest_command_args" pytest -v -rs -o junit_suite_name=${envname}_no_xdist \ --junitxml=pytest_${envname}_no_xdist.xml -m "$marker_for_sequential_tests" --import-mode=importlib ${pytest_args} ${pytest_command_args} status2=$? +echo "Sequential tests finished with status $status2" # Exit with error if no tests were run in either suite (status code 5). if [[ $status1 == 5 && $status2 == 5 ]]; then exit $status1 fi -# Exit with error if one of the statuses has an error that's not 5. -if [[ $status1 != 0 && $status1 != 5 ]]; then - exit $status1 -fi +# Combine coverage data if parallel was used. # Combine coverage data if parallel was used. # If .coveragerc is not found locally, look for it in the directory of the script or sdk root. COVERAGERC_PATH=".coveragerc" @@ -157,7 +156,7 @@ if [ ! -f "$COVERAGERC_PATH" ]; then fi if [ -f "$COVERAGERC_PATH" ] && grep -q "parallel = True" "$COVERAGERC_PATH"; then - echo "Combining coverage data..." + echo "Combining coverage data from $COVERAGERC_PATH..." # coverage combine will use the .coveragerc to find data files. coverage combine --rcfile="$COVERAGERC_PATH" if [[ $pytest_args == *"--cov-report=xml"* ]]; then @@ -166,4 +165,15 @@ if [ -f "$COVERAGERC_PATH" ] && grep -q "parallel = True" "$COVERAGERC_PATH"; th fi fi +# Exit with error if any of the statuses has an error that's not 5. +if [[ $status1 != 0 && $status1 != 5 ]]; then + echo "Exiting with status1: $status1" + exit $status1 +fi +if [[ $status2 != 0 && $status2 != 5 ]]; then + echo "Exiting with status2: $status2" + exit $status2 +fi + +echo "Exiting with success" exit 0