@@ -241,15 +241,23 @@ jobs:
241241 export PYTHONPATH=$GITHUB_WORKSPACE:${PYTHONPATH:-}
242242 export PATH=${CUDA_HOME:-/usr/local/cuda}/bin:$PATH
243243 export LD_LIBRARY_PATH=${CUDA_HOME:-/usr/local/cuda}/lib:${LD_LIBRARY_PATH:-}
244- # Ensure log directory exists regardless of volume mount state
245- mkdir -p /logs
246-
244+
247245 # check envs before running tests
248246 echo "TE_PATH=$TE_PATH"
249247 echo "TE_LIB_PATH=$TE_LIB_PATH"
250248 echo "PYTHONPATH=$PYTHONPATH"
251249 echo "PATH=$PATH"
252250 echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
251+
252+ # Ensure log directory exists regardless of volume mount state
253+ mkdir -p /logs
254+
255+ # Enable coverage collection for all pytest invocations in test.sh
256+ # PYTEST_ADDOPTS is automatically appended to every pytest call
257+ if [ "${{ inputs.upload_coverage }}" = "true" ]; then
258+ pip3 install pytest-cov 2>/dev/null || true
259+ export PYTEST_ADDOPTS="--cov=transformer_engine --cov-append --cov-report="
260+ fi
253261
254262 if [[ "${{ matrix.test_group.name }}" == *"lint"* ]]; then
255263 export CPP_ONLY=0
@@ -263,8 +271,8 @@ jobs:
263271 bash ${{ matrix.test_group.path }}
264272 timeout-minutes : 60
265273
266- - name : Generate coverage report
267- if : inputs.upload_coverage && always()
274+ - name : Generate Coverage Report
275+ if : inputs.upload_coverage && matrix.test_group.name == 'pytorch_unittest'
268276 working-directory : ${{ github.workspace }}
269277 env :
270278 PLATFORM : ${{ inputs.platform }}
@@ -306,17 +314,17 @@ jobs:
306314 PYEOF
307315 continue-on-error : true
308316
309- - name : Upload coverage report
310- if : inputs.upload_coverage && always()
317+ - name : Upload Coverage Report
318+ if : inputs.upload_coverage && matrix.test_group.name == 'pytorch_unittest'
311319 uses : actions/upload-artifact@v4
312320 with :
313321 name : coverage-${{ inputs.platform }}-${{ inputs.device }}
314322 path : |
315323 coverage-${{ inputs.platform }}-${{ inputs.device }}.json
316324 report-${{ inputs.platform }}-${{ inputs.device }}.json
317325
318- - name : Upload coverage report to FlagCICD
319- if : inputs.upload_coverage && always()
326+ - name : Upload Coverage Report to FlagCICD
327+ if : inputs.upload_coverage && matrix.test_group.name == 'pytorch_unittest'
320328 uses : flagos-ai/FlagOps/actions/post-pytest-report@v2
321329 continue-on-error : true
322330 with :
0 commit comments