4747 required : false
4848 default : false
4949 description : ' Continue running the job even if tests fail'
50+ enable-coverage :
51+ type : boolean
52+ required : false
53+ default : false
54+ description : ' Whether to run tests with coverage enabled.'
55+ secrets :
56+ OBS_ACCESS_KEY_PRECISION :
57+ required : false
58+ OBS_SECRET_ACCESS_KEY_PRECISION :
59+ required : false
60+
5061
5162# Bash shells do not use ~/.profile or ~/.bashrc so these shells need to be explicitly
5263# declared as "shell: bash -el {0}" on steps that need to be properly activated.
@@ -244,8 +255,12 @@ jobs:
244255 continue-on-error : ${{ inputs.continue_on_error }}
245256 env :
246257 VLLM_WORKER_MULTIPROC_METHOD : spawn
258+ ENABLE_COVERAGE : ${{ inputs.enable-coverage}}
247259 run : |
248260 . /usr/local/Ascend/ascend-toolkit/set_env.sh
261+ if [ "${{ inputs.enable-coverage }}" = "true" ]; then
262+ export ENABLE_COVERAGE=true
263+ fi
249264 TIMING_FLAG=""
250265 if [ "${{ inputs.upload_timing }}" = "true" ]; then
251266 TIMING_FLAG="--timing"
@@ -263,7 +278,11 @@ jobs:
263278 env :
264279 VLLM_WORKER_MULTIPROC_METHOD : spawn
265280 TORCH_DEVICE_BACKEND_AUTOLOAD : 0
281+ ENABLE_COVERAGE : ${{ inputs.enable-coverage}}
266282 run : |
283+ if [ "${{ inputs.enable-coverage }}" = "true" ]; then
284+ export ENABLE_COVERAGE=true
285+ fi
267286 .github/workflows/scripts/run_selected_tests.sh \
268287 "${{ matrix.group.npu_type }}" \
269288 "${{ matrix.group.num_npus }}" \
@@ -280,6 +299,17 @@ jobs:
280299 if-no-files-found : ignore
281300 retention-days : 7
282301
302+ - name : Upload coverage data
303+ if : ${{ always() && inputs.enable-coverage }}
304+ continue-on-error : true
305+ uses : actions/upload-artifact@v7
306+ with :
307+ name : selected-test-coverage-vllm-${{ inputs.vllm }}-${{ matrix.group.npu_type }}-${{ matrix.group.num_npus }}card-${{ matrix.group.partition }}
308+ path : tests/outputs/**/covdata/**
309+ if-no-files-found : ignore
310+ retention-days : 14
311+ compression-level : 0
312+
283313 - name : Upload selected test logs
284314 if : always()
285315 continue-on-error : true
@@ -290,3 +320,112 @@ jobs:
290320 if-no-files-found : ignore
291321 retention-days : 14
292322 compression-level : 0
323+
324+ upload-coverage-to-obs :
325+ if : ${{ always() && inputs.enable-coverage }}
326+ needs : selected-tests
327+ runs-on : ubuntu-latest
328+ continue-on-error : true
329+ env :
330+ OBS_ACCESS_KEY : ${{ secrets.OBS_ACCESS_KEY_PRECISION }}
331+ OBS_SECRET_KEY : ${{ secrets.OBS_SECRET_ACCESS_KEY_PRECISION }}
332+ steps :
333+ - name : Checkout vllm-ascend source code
334+ uses : actions/checkout@v6
335+ with :
336+ ref : ${{ inputs.ref || github.ref }}
337+
338+ - name : Download all coverage artifacts
339+ uses : actions/download-artifact@v5
340+ with :
341+ path : all-coverage
342+ pattern : selected-test-coverage-*
343+ merge-multiple : true
344+
345+ - name : Debug - List downloaded coverage files
346+ run : |
347+ echo "=== all-coverage top level ==="
348+ find all-coverage -maxdepth 1 2>/dev/null | head -20 || echo "all-coverage directory not exist"
349+ echo ""
350+ echo "=== all-coverage total file count ==="
351+ find all-coverage -type f 2>/dev/null | wc -l
352+ echo "=== sample covdata dirs ==="
353+ find all-coverage -type d -name covdata 2>/dev/null | head -10
354+ echo "=== sample files ==="
355+ find all-coverage -path '*/covdata/*' -type f 2>/dev/null | head -10
356+
357+ - name : Assemble and compress coverage files
358+ run : |
359+ set -euo pipefail
360+ TASK_DATE=$(date +%Y%m%d%H)
361+ TASK_NAME="VLLM-ASCEND@task_${TASK_DATE}"
362+ COVERAGE_PKG_DIR="coverage/vllm-ascend"
363+ TASK_DIR="${COVERAGE_PKG_DIR}/${TASK_NAME}"
364+ mkdir -p "${TASK_DIR}" "${COVERAGE_PKG_DIR}/covstub/vllm_ascend"
365+
366+ COVERAGE_FILE_COUNT=0
367+ while IFS= read -r f; do
368+ rel="${f#all-coverage/}"
369+ case "${rel}" in
370+ selected-test-coverage-*/*) rel="${rel#*/}" ;;
371+ esac
372+ dest="${TASK_DIR}/${rel}"
373+ mkdir -p "$(dirname "${dest}")"
374+ cp "${f}" "${dest}"
375+ COVERAGE_FILE_COUNT=$((COVERAGE_FILE_COUNT + 1))
376+ done < <(find all-coverage -path '*/covdata/*' -type f 2>/dev/null)
377+
378+ echo "Copied ${COVERAGE_FILE_COUNT} coverage files to ${TASK_DIR}"
379+ if [ "${COVERAGE_FILE_COUNT}" -eq 0 ]; then
380+ echo "::error::No coverage files found under all-coverage/*/covdata/"
381+ exit 1
382+ fi
383+
384+ cp -r vllm_ascend/. "${COVERAGE_PKG_DIR}/covstub/vllm_ascend/"
385+ cp tests/coverage_settingInfo.xml "${COVERAGE_PKG_DIR}/settingInfo.xml"
386+ echo "${TASK_NAME}" > coverage_version.txt
387+
388+ echo "=== package top level ==="
389+ find "${COVERAGE_PKG_DIR}" -maxdepth 1 2>/dev/null | head -20 || true
390+ echo "=== task dir file count ==="
391+ find "${TASK_DIR}" -type f | wc -l
392+
393+ tar cf coverage.tar -C coverage vllm-ascend
394+ echo "Packed coverage/vllm-ascend into coverage.tar"
395+ du -h coverage.tar
396+ echo "=== tar contents (sample) ==="
397+ tar tf coverage.tar | head -20 || true
398+ echo "=== tar task file count ==="
399+ tar tf coverage.tar | grep -c "vllm-ascend/${TASK_NAME}/" || true
400+
401+ {
402+ echo "TASK_DATE=${TASK_DATE}"
403+ echo "TASK_NAME=${TASK_NAME}"
404+ } >> "${GITHUB_ENV}"
405+
406+ - name : Upload coverage to OBS
407+ run : |
408+ pip install esdk-obs-python --quiet
409+ python3 - <<'EOF'
410+ import os
411+ from obs import ObsClient
412+
413+ OBS_BUCKET = 'vllm-ascend'
414+ OBS_PREFIX = 'ci/precision-test'
415+ client = ObsClient(
416+ access_key_id=os.environ['OBS_ACCESS_KEY'],
417+ secret_access_key=os.environ['OBS_SECRET_KEY'],
418+ server='https://obs.cn-north-4.myhuaweicloud.com'
419+ )
420+
421+ uploads = [
422+ ('coverage.tar', f'{OBS_PREFIX}/coverage.tar'),
423+ ('coverage_version.txt', f'{OBS_PREFIX}/coverage_version.txt'),
424+ ]
425+ for local_path, obs_path in uploads:
426+ resp = client.putFile(OBS_BUCKET, obs_path, local_path)
427+ if resp.status < 300:
428+ print(f'Uploaded: {local_path} -> {obs_path}')
429+ else:
430+ raise Exception(f'Failed to upload {local_path}: {resp.errorMessage}')
431+ EOF
0 commit comments