Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/_selected_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ on:
required: false
default: false
description: 'Continue running the job even if tests fail'
enable-coverage:
type: boolean
required: false
default: false
description: 'Whether to run tests with coverage enabled.'

# Bash shells do not use ~/.profile or ~/.bashrc so these shells need to be explicitly
# declared as "shell: bash -el {0}" on steps that need to be properly activated.
Expand Down Expand Up @@ -223,8 +228,12 @@ jobs:
continue-on-error: ${{ inputs.continue_on_error }}
env:
VLLM_WORKER_MULTIPROC_METHOD: spawn
ENABLE_COVERAGE: ${{ inputs.enable-coverage}}
run: |
. /usr/local/Ascend/ascend-toolkit/set_env.sh
if [ "${{ inputs.enable-coverage }}" = "true" ]; then
export ENABLE_COVERAGE=true
fi
TIMING_FLAG=""
if [ "${{ inputs.upload_timing }}" = "true" ]; then
TIMING_FLAG="--timing"
Expand All @@ -242,7 +251,11 @@ jobs:
env:
VLLM_WORKER_MULTIPROC_METHOD: spawn
TORCH_DEVICE_BACKEND_AUTOLOAD: 0
ENABLE_COVERAGE: ${{ inputs.enable-coverage}}
run: |
if [ "${{ inputs.enable-coverage }}" = "true" ]; then
export ENABLE_COVERAGE=true
fi
.github/workflows/scripts/run_selected_tests.sh \
"${{ matrix.group.npu_type }}" \
"${{ matrix.group.num_npus }}" \
Expand All @@ -259,6 +272,17 @@ jobs:
if-no-files-found: ignore
retention-days: 7

- name: Upload coverage data
if: ${{ always() && inputs.enable-coverage }}
continue-on-error: true
uses: actions/upload-artifact@v7
with:
name: selected-test-coverage-vllm-${{ inputs.vllm }}-${{ matrix.group.npu_type }}-${{ matrix.group.num_npus }}card
path: tests/outputs/**/covdata/**
if-no-files-found: ignore
retention-days: 14
compression-level: 0

- name: Upload selected test logs
if: always()
continue-on-error: true
Expand Down
87 changes: 86 additions & 1 deletion .github/workflows/pr_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ on:
- 'main'
- '*-dev'
- 'releases/v*'
schedule:
- cron: "0 2 * * *"
workflow_dispatch:
inputs:
vllm_ascend_ref:
description: "vllm-ascend ref (branch, tag, or SHA)"
required: false
default: "main"
type: string
vllm_version:
description: "vllm version (commit hash or tag)"
required: false
default: "v0.20.2"
type: string

# Bash shells do not use ~/.profile or ~/.bashrc so these shells need to be explicitly
# declared as "shell: bash -el {0}" on steps that need to be properly activated.
Expand All @@ -42,7 +56,7 @@ concurrency:

jobs:
lint-and-select-tests:
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'ready' }}
if: ${{ github.event_name == 'pull_request' && (github.event.action != 'labeled' || github.event.label.name == 'ready') }}
runs-on: linux-amd64-cpu-8-hk
container:
image: quay.io/ascend-ci/vllm-ascend:lint
Expand Down Expand Up @@ -213,3 +227,74 @@ jobs:
vllm: ${{ matrix.vllm_version }}
ref: ${{ github.event.pull_request.head.sha }}
test_groups: ${{ needs.lint-and-select-tests.outputs.test_groups }}

# ─── Schedule/Dispatch path: full tests ────────────────────────────────────────

select-full-tests:
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
runs-on: linux-amd64-cpu-8-hk
container:
image: quay.io/ascend-ci/vllm-ascend:lint
outputs:
has_tests: ${{ steps.full-scope.outputs.has_tests }}
test_groups: ${{ steps.full-scope.outputs.test_groups }}
matched_modules: ${{ steps.full-scope.outputs.matched_modules }}
vllm_ascend_ref: ${{ steps.resolve-refs.outputs.vllm_ascend_ref }}
vllm_version: ${{ steps.resolve-refs.outputs.vllm_version }}
main_commit: ${{ steps.resolve-refs.outputs.main_commit }}
release_tag: ${{ steps.resolve-refs.outputs.release_tag }}
steps:
- name: Checkout vllm-project/vllm-ascend repo
uses: actions/checkout@v6
with:
ref: ${{ inputs.vllm_ascend_ref || 'main' }}
fetch-depth: 0

- name: Resolve refs
id: resolve-refs
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "vllm_ascend_ref=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_OUTPUT"
else
echo "vllm_ascend_ref=${{ inputs.vllm_ascend_ref || 'main' }}" >> "$GITHUB_OUTPUT"
fi
echo "vllm_version=${{ inputs.vllm_version || 'v0.21.0' }}" >> "$GITHUB_OUTPUT"
main_commit="$(tr -d '[:space:]' < .github/vllm-main-verified.commit)"
release_tag="$(tr -d '[:space:]' < .github/vllm-release-tag.commit)"
[[ "${main_commit}" =~ ^[0-9a-f]{7,40}$ ]] || {
echo "::error file=.github/vllm-main-verified.commit::invalid vLLM main commit: ${main_commit}"
exit 1
}
[[ "${release_tag}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-].*)?$ ]] || {
echo "::error file=.github/vllm-release-tag.commit::invalid vLLM release tag: ${release_tag}"
exit 1
}
{
echo "main_commit=${main_commit}"
echo "release_tag=${release_tag}"
} >> "$GITHUB_OUTPUT"

- name: Select all tests
id: full-scope
run: |
pip install regex pyyaml
git config --global --add safe.directory /__w/vllm-ascend/vllm-ascend
python3 .github/workflows/scripts/select_tests.py \
--changed-files vllm_ascend/dummy.py \
--run-all-modules

run-full-tests:
needs: select-full-tests
if: ${{ needs.select-full-tests.outputs.has_tests == 'true' }}
strategy:
fail-fast: false
matrix:
vllm_version:
# - ${{ needs.select-full-tests.outputs.main_commit }}
- ${{ needs.select-full-tests.outputs.release_tag }}
uses: ./.github/workflows/_selected_tests.yaml
with:
vllm: ${{ matrix.vllm_version }}
ref: ${{ needs.select-full-tests.outputs.vllm_ascend_ref }}
test_groups: ${{ needs.select-full-tests.outputs.test_groups }}
enable-coverage: true
54 changes: 49 additions & 5 deletions .github/workflows/scripts/run_selected_tests.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
#!/usr/bin/env bash
set -euo pipefail

enable_coverage=false
if [ "${ENABLE_COVERAGE:-}" = "true" ]; then
enable_coverage=true
fi

while [ "$#" -gt 0 ]; do
case "$1" in
--enable-coverage)
enable_coverage=true
shift
;;
*)
break
;;
esac
done

if [ "$#" -lt 4 ]; then
echo "Usage: $0 <npu_type> <num_npus> <with-device|without-device> [--timing] <test> [test ...]"
echo "Usage: $0 [--enable-coverage] <npu_type> <num_npus> <with-device|without-device> [--timing] <test> [test ...]"
exit 1
fi

Expand All @@ -28,16 +45,29 @@ test_results=()
failed_logs=()
timing_entries=()
test_index=0
overall_status=0
pytest_log_dir="${RUNNER_TEMP:-/tmp}/selected-tests-${npu_type}-${num_npus}card"
project_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"

mkdir -p "${pytest_log_dir}"

setup_coverage() {
local target="$1"
local test_basename="${target%.py}"
test_basename="${test_basename//\//__}"
local covdata_dir="${project_root}/tests/outputs/${test_basename}/covdata"
mkdir -p "${covdata_dir}"
export COVERAGE_FILE="${covdata_dir}/coverage"
echo -e " \033[33mCOVERAGE_FILE:\033[0m ${COVERAGE_FILE}"
}

print_test_info() {
echo -e "\033[1;34m=== TEST INFO ===\033[0m"
echo -e " \033[33mDevice:\033[0m ${npu_type}"
if [ "${npu_type}" != "cpu" ]; then
echo -e " \033[33mNPU count:\033[0m ${num_npus}"
fi
echo -e " \033[33mCoverage:\033[0m ${enable_coverage}"
echo -e " \033[33mTargets:\033[0m"
for target in "${targets[@]}"; do
echo -e " \033[32m-\033[0m ${target}"
Expand Down Expand Up @@ -77,8 +107,14 @@ run_pytest_target() {
if [ "${record_timing}" = true ]; then
start_time=$(date +%s%N)
fi
set +e
pytest -sv --color=yes "${target}" 2>&1 | tee "${log_file}"
if [ "${enable_coverage}" = "true" ]; then
setup_coverage "${target}"
set +e
python -m coverage run --rcfile="${project_root}/tests/coveragerc" -m pytest -sv --color=yes "${target}" 2>&1 | tee "${log_file}"
else
set +e
pytest -sv --color=yes "${target}" 2>&1 | tee "${log_file}"
fi
local status=${PIPESTATUS[0]}
set -e
if [ "${record_timing}" = true ]; then
Expand Down Expand Up @@ -112,8 +148,15 @@ run_pytest_batch() {
if [ "${record_timing}" = true ]; then
start_time=$(date +%s%N)
fi
set +e
pytest -sv --color=yes "${batch_targets[@]}" 2>&1 | tee "${log_file}"
if [ "${enable_coverage}" = "true" ]; then
echo "DEBUG: 进入【覆盖率分支】"
setup_coverage "cpu-ut"
set +e
python -m coverage run --rcfile="${project_root}/tests/coveragerc" -m pytest -sv --color=yes "${batch_targets[@]}" 2>&1 | tee "${log_file}"
else
set +e
pytest -sv --color=yes "${batch_targets[@]}" 2>&1 | tee "${log_file}"
fi
local status=${PIPESTATUS[0]}
set -e
if [ "${record_timing}" = true ]; then
Expand Down Expand Up @@ -178,3 +221,4 @@ fi

print_timing_json
print_summary
exit "${overall_status}"
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ mindstudio-probe>=8.3.0
xlite==0.1.0rc11.dev210
uc-manager
ninja
coverage
39 changes: 39 additions & 0 deletions tests/coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[run]
branch = True
# 指定覆盖数据中文件路径采用绝对路径,便于后续分析时路径匹配
relative_files = False
# 指定产生的覆盖数据文件基础名称,可采用绝对路径
data_file = /mnt/share/s00837289/covdata/coverage

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The data_file path is hardcoded to a specific user's directory (/mnt/share/s00837289/covdata/coverage). This will cause coverage collection to fail on other environments or CI systems where this path does not exist or is not writable. Please use a relative path or a generic directory to ensure portability.

data_file = .coverage_data/coverage

# 对覆盖数据文件增加进程ID等标识
parallel = True
# 项目使用的并发库,默认thread。若代码采用了multiprocessing, gevent, greenlet, 或eventlet等并发库,则需显示指定。如任务调度框架celery可采用单进程模式,使用了multiprocessing库,则此选项需追加multiprocessing
concurrency = thread,multiprocessing
# 注册信号15,以便“kill pid”杀进程前可导出覆盖数据,若业务代码本身注册了15处理函数,则应关闭。默认关闭
sigterm = False
# debug配置,方便定位可能的异常。按需开启
# debug=pid,dataio,dataop
# debug_file=/opt/coveragepy_debug.out
# 禁用coverage.py警告打印
disable_warnings=no-data-collected,module-not-python
# 配置可采集覆盖数据的源码文件列表,支持通配符*匹配,支持通过逗号分隔多个值。根据实际调整
include =
*/vllm_ascend/*
# 目录usr下任何格式python代码
/vllm_ascend/*

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The include path /vllm_ascend/* specifies an absolute path starting from the root directory. This will likely fail to match the source files unless they are located at the filesystem root. Consider using a relative path pattern like vllm_ascend/* instead.

    vllm_ascend/*

# 配置需排除覆盖数据采集的文件列表,作用于include配置处理之后。语法同include
omit = */.local/*
/usr/*
utils/tirefire.py
# agent配置常驻进程覆盖采集执行机。2025年3月所出烛龙版本7.5.4a0.dev2新增配置项
# 是否开启执行机覆盖数据收取接口服务,默认False
#agent_enable=False
# 指定收取服务使用端口,默认8088。可配置为0以采用随机端口
#agent_port=8088
# 是否开启收取日志信息打印,默认False
#agent_debug=False
# 开始日志打印是,收取服务日志文件绝对路径
#agent_debug_file=/path/to/coverage_agent.log
# 指定导出数据超时配置,默认3秒
#agent_dump_timeout=3
# 导出数据是否采用API方式,默认True。True:调用dump方法方式;False:kill -34方式
#agent_dump_in_api=True
Loading