Repository navigation
[Verify] Nightly test on main #65538
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| # This file is a part of the vllm-ascend project. | |
| # | |
| name: E2E | |
| on: | |
| pull_request: | |
| # `synchronize` is deliberately absent: pushing a new commit does not start | |
| # E2E, so intermediate commits no longer occupy the NPU runner pool. A | |
| # commit is tested on opened/reopened, when a label is added, or when a | |
| # `/run` comment re-emits the `labeled` event (see pr_run_command.yml). | |
| # `ci-gate` is a required check, so a commit that was never tested stays | |
| # blocked rather than being merged untested. | |
| types: | |
| - opened | |
| - reopened | |
| - labeled | |
| branches: | |
| - 'main' | |
| - '*-dev' | |
| - 'releases/v*' | |
| # NOTE: this workflow must NOT also trigger on `pull_request_review`. A | |
| # review-event run would create a skipped `ci-gate` check-run under the | |
| # same context name on the head SHA, and GitHub treats the latest check by | |
| # name as the verdict - a skipped required check counts as satisfied, which | |
| # lets the PR merge in the window before the real gate rewrites it (see | |
| # pr_refresh_ci_gate.yaml for the standalone review retrigger). | |
| # 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. | |
| # It's used to activate ascend-toolkit environment variables. | |
| defaults: | |
| run: | |
| shell: bash -el {0} | |
| concurrency: | |
| # This workflow only sees pull_request events, so one group per PR is | |
| # enough: a new run (opened / synchronize / labeled) cancels the stale one. | |
| # The review-event retrigger lives in pr_refresh_ci_gate.yaml, which keeps | |
| # its own concurrency group so it never cancels the in-flight CI run here | |
| # (the review retrigger waits for that run to finish before re-running its | |
| # gate jobs). | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| pre-commit: | |
| runs-on: linux-amd64-cpu-8-hk | |
| container: | |
| image: quay.io/ascend-ci/vllm-ascend:lint | |
| outputs: | |
| # Primary vLLM ref for this branch: main / *-dev use the verified vLLM | |
| # main commit, releases/v* use the pinned release tag. | |
| vllm_ref: ${{ steps.vllm.outputs.vllm_ref }} | |
| # Which rule produced vllm_ref: "main" or "release". | |
| target: ${{ steps.vllm.outputs.target }} | |
| # JSON array of the vllm refs to test for the NPU jobs. Defaults to the | |
| # primary ref alone; the main2main label widens main to the release_tag | |
| # as well. | |
| vllm_versions: ${{ steps.vllm.outputs.vllm_versions }} | |
| # JSON array for cpu-ut: both refs on main, the release tag alone on a | |
| # release branch. | |
| cpu_ut_versions: ${{ steps.vllm.outputs.cpu_ut_versions }} | |
| src: ${{ steps.filter.outputs.src }} | |
| ci_pipeline: ${{ steps.filter.outputs.ci_pipeline }} | |
| cpu_ut: ${{ steps.filter.outputs.cpu_ut }} | |
| steps: | |
| - name: Validate PR title prefix | |
| run: | | |
| PR_TITLE=$(curl -sSf -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
| -H "Accept: application/vnd.github.v3+json" \ | |
| "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" \ | |
| | python3 -c "import sys,json; print(json.load(sys.stdin)['title'])") || { | |
| echo "::error::Failed to fetch PR title from GitHub API" | |
| exit 1 | |
| } | |
| if [ -z "$PR_TITLE" ]; then | |
| echo "::error::PR title cannot be empty" | |
| exit 1 | |
| fi | |
| echo "Checking PR title: $PR_TITLE" | |
| VALID_PREFIXES='\[(BugFix|Performance|Test|CI|Feature|Doc|Misc|Community|Refactor)\]' | |
| if ! echo "$PR_TITLE" | grep -iqE "$VALID_PREFIXES"; then | |
| echo "::error::PR title must contain one of the following prefixes: [BugFix], [Performance], [Test], [CI], [Feature], [Doc], [Misc], [Community], [Refactor]" | |
| echo "::error::Example: '[Feature] Add new optimization pass' or 'Add new feature [Feature]'" | |
| exit 1 | |
| fi | |
| echo "✓ PR title prefix is valid" | |
| - name: Checkout vllm-project/vllm-ascend repo | |
| uses: actions/checkout@v7 | |
| with: | |
| # Gitleaks needs the base branch ref and history to scan the PR commits. | |
| fetch-depth: 0 | |
| - name: Prepare CI metadata | |
| id: vllm | |
| env: | |
| # pull_request target branch. main / *-dev track upstream main; | |
| # releases/v* are frozen and must only be tested against the | |
| # matched vLLM release tag. | |
| BASE_REF: ${{ github.base_ref }} | |
| # The main2main label requests a dual-version run: full NPU tests on | |
| # both the verified vLLM main commit and the matched release tag. | |
| HAS_MAIN2MAIN: ${{ contains(github.event.pull_request.labels.*.name, 'main2main') }} | |
| run: | | |
| release_tag="$(tr -d '[:space:]' < .github/vllm-release-tag.commit)" | |
| [[ "${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 "release_tag=${release_tag}" >> "$GITHUB_OUTPUT" | |
| # pre-commit (mypy) checks out this commit on every branch: mypy | |
| # resolves imports statically and cannot evaluate vllm_version_is, | |
| # so its source tree must contain every module the branch references. | |
| main_commit="$(tr -d '[:space:]' < .github/vllm-main-verified.commit)" | |
| [[ "${main_commit}" =~ ^[0-9a-f]{7,40}$ ]] || { | |
| echo "::error file=.github/vllm-main-verified.commit::invalid vLLM main commit: ${main_commit}" | |
| exit 1 | |
| } | |
| if [[ "${BASE_REF}" == releases/* ]]; then | |
| # Release branches are frozen: upstream vLLM main may already be | |
| # incompatible with this branch, so tests only use the release tag. | |
| # The verified main commit is still read above for pre-commit. | |
| target="release" | |
| primary_ref="${release_tag}" | |
| cpu_ut_versions="[\"${release_tag}\"]" | |
| vllm_versions="[\"${release_tag}\"]" | |
| if [ "${HAS_MAIN2MAIN}" = "true" ]; then | |
| echo "::notice::'main2main' is ignored on ${BASE_REF}; release branches test ${release_tag} only." | |
| fi | |
| else | |
| target="main" | |
| primary_ref="${main_commit}" | |
| cpu_ut_versions="[\"${main_commit}\",\"${release_tag}\"]" | |
| if [ "${HAS_MAIN2MAIN}" = "true" ]; then | |
| vllm_versions="[\"${main_commit}\",\"${release_tag}\"]" | |
| else | |
| vllm_versions="[\"${main_commit}\"]" | |
| fi | |
| fi | |
| { | |
| echo "target=${target}" | |
| echo "vllm_ref=${primary_ref}" | |
| echo "lint_vllm_ref=${main_commit}" | |
| echo "vllm_versions=${vllm_versions}" | |
| echo "cpu_ut_versions=${cpu_ut_versions}" | |
| } >> "$GITHUB_OUTPUT" | |
| echo "vLLM target: ${target} (base_ref=${BASE_REF}, test ref=${primary_ref}, lint ref=${main_commit})" | |
| # =========== Copy problem matchers ===================== | |
| echo "::group::Copy problem matchers" | |
| for matcher in actionlint markdownlint mypy; do | |
| cp ".github/workflows/matchers/$matcher.json" "$RUNNER_TEMP/$matcher.json" | |
| done | |
| echo "::endgroup::" | |
| # =========== Calculate pre-commit cache key ============ | |
| echo "::group::Calculate pre-commit cache key" | |
| PRE_COMMIT_HASH=$(sha256sum .pre-commit-config.yaml | awk '{print $1}') | |
| echo "PRE_COMMIT_HASH=$PRE_COMMIT_HASH" >> "$GITHUB_OUTPUT" | |
| echo "::endgroup::" | |
| - name: Checkout vllm-project/vllm repo | |
| uses: actions/checkout@v7 | |
| with: | |
| repository: vllm-project/vllm | |
| path: ./vllm-empty | |
| # Static checking always uses the branch's verified main commit. | |
| ref: ${{ steps.vllm.outputs.lint_vllm_ref }} | |
| - uses: dorny/paths-filter@v4 | |
| id: filter | |
| with: | |
| # Make negated patterns final so Markdown-only changes do not match src. | |
| predicate-quantifier: some-with-excludes | |
| filters: | | |
| lint_tracker: | |
| - 'requirements.txt' | |
| - 'requirements-dev.txt' | |
| - 'requirements-lint.txt' | |
| # Source paths that require precision/full test execution. This | |
| # category is the single source of truth for "does this PR need | |
| # NPU tests" and is consumed by every downstream job. | |
| src: | |
| - 'vllm_ascend/**' | |
| - 'setup.py' | |
| - 'csrc/**' | |
| - 'packages.txt' | |
| - 'requirements.txt' | |
| - 'requirements-dev.txt' | |
| - 'pyproject.toml' | |
| - 'cmake/**' | |
| - 'tests/ut/**' | |
| - 'tests/e2e/pull_request/**' | |
| - 'tests/e2e/*.py' | |
| - 'tests/e2e/*.sh' | |
| - 'tools/**' | |
| - 'CMakeLists.txt' | |
| # Requires a run-enabling label, but stays out of ci_pipeline so | |
| # ready-precise is not escalated to the full suite. | |
| - '.github/workflows/scripts/test_selector.py' | |
| - '!**/*.md' | |
| # CI pipeline files: a PR that touches the test selection or | |
| # execution pipeline itself must run the full suite, because | |
| # the precise-selection result can no longer be trusted. | |
| # estimated_times.yaml is intentionally omitted: it only | |
| # affects load-balanced partitioning, not which tests are | |
| # recommended, so timing-only PRs keep ready-precise. | |
| # test_selector.py is listed under src instead: a label is | |
| # required, and ready-precise keeps the precise path. | |
| ci_pipeline: | |
| - '.github/workflows/pr_test.yaml' | |
| - '.github/workflows/_selected_tests.yaml' | |
| - '.github/workflows/_selected_tests_upstream.yaml' | |
| - '.github/workflows/_ensure_csrc_cache.yaml' | |
| - '.github/workflows/_build_csrc_cache.yaml' | |
| - '.github/workflows/scripts/csrc_cache_targets.json' | |
| - '.github/workflows/scripts/resolve_csrc_cache_targets.py' | |
| - '.github/workflows/scripts/select_tests.py' | |
| - '.github/workflows/scripts/run_selected_tests.sh' | |
| - '.github/workflows/scripts/test_config.yaml' | |
| - '.github/workflows/scripts/runner_label.json' | |
| - '.github/workflows/scripts/coverage.py' | |
| - 'requirements.txt' | |
| - 'requirements-dev.txt' | |
| - 'pyproject.toml' | |
| # Files that can affect CPU UT execution but are covered by neither | |
| # src nor ci_pipeline: everything tests/ut reads from disk, not only | |
| # what it imports from under tests/. That includes shared tests/ | |
| # helpers (e.g. tests/deepseek_v41_utils.py), example scripts that UT | |
| # imports or spawns as subprocesses (e.g. | |
| # examples/disaggregated_prefill_v1/load_balance_proxy_server_example.py, | |
| # examples/rl/rlhf_http_hccl.py), and the specific .github files UT | |
| # inspects: top-level workflow YAMLs (FLA pin checks in | |
| # tests/ut/ops/test_gdn_window_guard.py), workflow scripts and the | |
| # csrc-l1-restore action imported/read by tests/ut/_tools, and the | |
| # pinned vLLM refs that decide which versions the UT matrix runs | |
| # against. Other .github metadata (CODEOWNERS, labeler, templates) | |
| # cannot affect UT and is intentionally left out. | |
| # A cpu_ut-only change runs cpu-ut without requiring a test label. | |
| cpu_ut: | |
| - 'tests/**' | |
| - 'examples/**' | |
| - 'Dockerfile*' | |
| - '.github/vllm-release-tag.commit' | |
| - '.github/vllm-main-verified.commit' | |
| - '!**/*.md' | |
| - name: Install vllm-ascend dev (conditional) | |
| if: steps.filter.outputs.lint_tracker == 'true' | |
| env: | |
| UV_EXTRA_INDEX_URL: "https://repo.huaweicloud.com/ascend/repos/pypi https://repo.huaweicloud.com/ascend/repos/pypi/nightly https://download.pytorch.org/whl/cpu" | |
| UV_INDEX_STRATEGY: unsafe-best-match | |
| UV_NO_CACHE: 1 | |
| UV_SYSTEM_PYTHON: 1 | |
| run: | | |
| pip install uv | |
| git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| uv pip install -r requirements-dev.txt | |
| - name: Install and run Gitleaks Secret Scan | |
| run: | | |
| git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| if [[ -n "${GITHUB_BASE_REF:-}" ]]; then | |
| if [[ "$(git rev-parse --is-shallow-repository)" == "true" ]]; then | |
| git fetch --no-tags --unshallow origin "$(git rev-parse HEAD)" | |
| fi | |
| git fetch --no-tags origin \ | |
| "+refs/heads/${GITHUB_BASE_REF}:refs/remotes/origin/${GITHUB_BASE_REF}" | |
| fi | |
| chmod +x .github/workflows/scripts/gitleaks.sh | |
| .github/workflows/scripts/gitleaks.sh | |
| - name: Restore pre-commit cache | |
| uses: runs-on/cache/restore@v5 | |
| env: | |
| RUNS_ON_S3_BUCKET_CACHE: ascend-ci-cache-hk | |
| RUNS_ON_S3_BUCKET_ENDPOINT: https://obs.ap-southeast-1.myhuaweicloud.com | |
| RUNS_ON_S3_FORCE_PATH_STYLE: "false" | |
| AWS_S3_FORCE_PATH_STYLE: "false" | |
| AWS_REGION: ap-southeast-1 | |
| with: | |
| path: /tmp/pre-commit-cache | |
| key: pre-commit-${{ steps.vllm.outputs.PRE_COMMIT_HASH }} | |
| # Increase the execution interval between the "Copy problem matchers" and "Register problem matchers" steps | |
| # to ensure the runner can successfully receive the target file, lower the chance of missing files. | |
| - name: Register problem matchers | |
| run: | | |
| for matcher in actionlint markdownlint mypy; do | |
| echo "::add-matcher::$RUNNER_TEMP/$matcher.json" | |
| done | |
| - name: Run pre-commit | |
| timeout-minutes: 10 | |
| env: | |
| PRE_COMMIT_HOME: /tmp/pre-commit-cache | |
| PRE_COMMIT_COLOR: always | |
| FORCE_COLOR: "1" | |
| TERM: xterm-256color | |
| SHELLCHECK_OPTS: "--exclude=SC2046,SC2006,SC2086" | |
| # Keep golang-based pre-commit hooks on a domestic module proxy. | |
| GOPROXY: https://repo.huaweicloud.com/repository/goproxy/ | |
| GONOSUMDB: '*' | |
| run: | | |
| git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| pre-commit run --all-files --hook-stage manual --show-diff-on-failure | |
| - name: Run mypy for Python 3.10, 3.11 and 3.12 in parallel | |
| run: | | |
| PYTHONPATH="$PYTHONPATH:$(pwd)/vllm-empty" | |
| export PYTHONPATH | |
| git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| python3 .github/workflows/scripts/run_mypy_parallel.py | |
| cpu-ut: | |
| # Always run tests/ut twice in parallel on main: once on the verified vLLM | |
| # main commit and once on the matched release tag. Independent of the | |
| # main2main label, which only widens the NPU matrix. Release branches only | |
| # run the release tag (see the pre-commit ref resolution). | |
| # Docs-only PRs skip this job: it runs when the diff touches src, | |
| # ci_pipeline, or cpu_ut paths (shared tests/ helpers, example scripts UT | |
| # imports or spawns, the CI files UT inspects, and the pinned vLLM refs), | |
| # or when a run-enabling label (main2main / ready-precise) forces it. The | |
| # labels are required because the run-selected-tests* jobs below require | |
| # cpu-ut success, so cpu-ut must run whenever NPU tests would run. | |
| name: cpu-ut (vllm@${{ matrix.vllm }}) | |
| needs: pre-commit | |
| if: >- | |
| ${{ | |
| needs.pre-commit.result == 'success' && | |
| ( | |
| needs.pre-commit.outputs.src == 'true' || | |
| needs.pre-commit.outputs.ci_pipeline == 'true' || | |
| needs.pre-commit.outputs.cpu_ut == 'true' || | |
| contains(github.event.pull_request.labels.*.name, 'main2main') || | |
| contains(github.event.pull_request.labels.*.name, 'ready-precise') | |
| ) | |
| }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| vllm: ${{ fromJSON(needs.pre-commit.outputs.cpu_ut_versions) }} | |
| uses: ./.github/workflows/_selected_tests.yaml | |
| with: | |
| vllm: ${{ matrix.vllm }} | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| base_ref: ${{ github.base_ref }} | |
| test_groups: >- | |
| [{"partition_name":"cpu-ut","runner":"linux-amd64-cpu-8-hk","image_tag":"9.3.0_20261113161300-910b-ubuntu22.04-py3.12","npu_type":"cpu","num_npus":0,"tests":"tests/ut"}] | |
| enable-coverage: false | |
| recommend-tests: | |
| name: Recommend tests | |
| needs: [pre-commit] | |
| # The recommendation only runs under the ready-precise label. Runs without | |
| # that label skip this job, including main2main alone. | |
| # Prepare E2E tests in parallel with CPU UT after pre-commit succeeds; | |
| # each NPU entry point separately requires CPU UT to succeed. | |
| if: >- | |
| ${{ | |
| needs.pre-commit.result == 'success' && | |
| contains(github.event.pull_request.labels.*.name, 'ready-precise') | |
| }} | |
| runs-on: linux-amd64-cpu-4-hk | |
| outputs: | |
| coverage_paths: ${{ steps.export-paths.outputs.coverage_paths }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| - name: Checkout vllm-ascend scripts | |
| uses: actions/checkout@v7 | |
| with: | |
| sparse-checkout: | | |
| .github/workflows/scripts | |
| sparse-checkout-cone-mode: false | |
| - name: Download test case map and coverage package | |
| env: | |
| BASE_REF: ${{ github.base_ref }} | |
| run: | | |
| set -euo pipefail | |
| OBS="https://vllm-ascend.obs.cn-north-4.myhuaweicloud.com/ci/precision-test" | |
| # coverage_release_branch.txt names the one release branch that has | |
| # its own package, for example releases/v0.30.0. Only a PR into that | |
| # branch uses coverage-v0.30.0.tar. Every other target uses main. | |
| suffix="" | |
| pointer_code=$(curl -sSL --retry 3 --retry-delay 5 \ | |
| -o coverage_release_branch.txt -w "%{http_code}" \ | |
| "${OBS}/coverage_release_branch.txt" || echo "000") | |
| if [ "${pointer_code}" = "200" ] && [ -s coverage_release_branch.txt ]; then | |
| release_branch=$(tr -d '[:space:]' < coverage_release_branch.txt) | |
| echo "Supported release coverage branch: ${release_branch}" | |
| if [ "${BASE_REF}" = "${release_branch}" ] \ | |
| && [[ "${release_branch}" =~ ^releases/(v[0-9][0-9A-Za-z._-]*)$ ]]; then | |
| suffix="${BASH_REMATCH[1]}" | |
| fi | |
| else | |
| echo "No coverage_release_branch.txt on OBS (HTTP ${pointer_code}); using main" | |
| rm -f coverage_release_branch.txt | |
| fi | |
| if [ -n "${suffix}" ]; then | |
| echo "Using coverage-${suffix}.tar for ${BASE_REF}" | |
| curl -fsSL --retry 3 --retry-delay 5 --retry-all-errors \ | |
| "${OBS}/test_case_map-${suffix}.json" -o test_case_map.json | |
| curl -fsSL --retry 3 --retry-delay 5 --retry-all-errors \ | |
| "${OBS}/coverage-${suffix}.tar" -o coverage.tar | |
| echo "COVERAGE_EXTRA_OBJECT=extra_recommended_tests-${suffix}.yaml" >> "${GITHUB_ENV}" | |
| else | |
| echo "Using main coverage package for ${BASE_REF}" | |
| curl -fsSL --retry 3 --retry-delay 5 --retry-all-errors \ | |
| "${OBS}/test_case_map.json" -o test_case_map.json | |
| curl -fsSL --retry 3 --retry-delay 5 --retry-all-errors \ | |
| "${OBS}/coverage.tar" -o coverage.tar | |
| if [ "${BASE_REF}" = "main" ]; then | |
| echo "COVERAGE_EXTRA_OBJECT=extra_recommended_tests.yaml" >> "${GITHUB_ENV}" | |
| fi | |
| fi | |
| du -h test_case_map.json coverage.tar | |
| tar xf coverage.tar vllm-ascend/covstub | |
| test -d vllm-ascend/covstub | |
| echo "Extracted vllm-ascend/covstub" | |
| find vllm-ascend/covstub -maxdepth 2 -type d | head -20 || true | |
| - name: Recommend tests for current PR | |
| run: | | |
| set -euo pipefail | |
| if ! python3 -c "import regex" >/dev/null 2>&1; then | |
| echo "regex not found for $(python3 -V); bootstrapping pip and installing regex" | |
| curl -fsSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py | |
| python3 get-pip.py --break-system-packages | |
| python3 -m pip install --break-system-packages regex | |
| fi | |
| python3 -c "import regex; print('regex ok:', regex.__file__)" | |
| PR_SPEC="${{ github.repository }}#${{ github.event.pull_request.number }}" | |
| echo "Selecting tests for PR: ${PR_SPEC}" | |
| python3 .github/workflows/scripts/test_selector.py \ | |
| --github-pr "${PR_SPEC}" \ | |
| --source-dir ./vllm-ascend/covstub \ | |
| --map-file test_case_map.json | |
| # Extra OBS tests are merged only for main and for the release branch | |
| # named in coverage_release_branch.txt. Other targets skip the list. | |
| # Also skip when the PR has no src paths. Do not skip this job: | |
| # ready-precise requires recommend-tests to succeed. | |
| - name: Merge extra tests from YAML | |
| if: ${{ needs.pre-commit.outputs.src == 'true' }} | |
| run: | | |
| set -euo pipefail | |
| EXTRA_OBJECT="${COVERAGE_EXTRA_OBJECT:-}" | |
| if [ -z "${EXTRA_OBJECT}" ]; then | |
| echo "PR target is not main or the supported release coverage branch; skip extra tests" | |
| exit 0 | |
| fi | |
| if ! python3 -c "import yaml" >/dev/null 2>&1; then | |
| echo "yaml not found for $(python3 -V); bootstrapping pip and installing pyyaml" | |
| curl -fsSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py | |
| python3 get-pip.py --break-system-packages | |
| python3 -m pip install --break-system-packages pyyaml | |
| fi | |
| OBS_EXTRA_URL="https://vllm-ascend.obs.cn-north-4.myhuaweicloud.com/ci/precision-test/${EXTRA_OBJECT}" | |
| http_code=$(curl -sSL --retry 3 --retry-delay 5 -o extra_recommended_tests.obs.yaml -w "%{http_code}" "${OBS_EXTRA_URL}" || echo "000") | |
| if [ "${http_code}" = "200" ] && [ -s extra_recommended_tests.obs.yaml ]; then | |
| echo "Downloaded ${EXTRA_OBJECT} from OBS" | |
| python3 .github/workflows/scripts/merge_extra_recommended_tests.py \ | |
| --list-file recommended_pytest_paths.txt \ | |
| --extra-yaml extra_recommended_tests.obs.yaml | |
| else | |
| echo "No ${EXTRA_OBJECT} on OBS (HTTP ${http_code}); skipped" | |
| rm -f extra_recommended_tests.obs.yaml | |
| fi | |
| - name: Export coverage paths output | |
| id: export-paths | |
| if: ${{ !cancelled() }} | |
| run: | | |
| FILE="recommended_pytest_paths.txt" | |
| if [ -f "$FILE" ]; then | |
| { | |
| echo "coverage_paths<<EOF" | |
| cat "$FILE" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| echo "Exported $(wc -l < "$FILE") recommended paths" | |
| else | |
| echo "coverage_paths=" >> "$GITHUB_OUTPUT" | |
| echo "::notice::recommended_pytest_paths.txt not found" | |
| fi | |
| select-tests: | |
| needs: | |
| - pre-commit | |
| - recommend-tests | |
| # select-tests is the single producer of test_groups / base_sha / has_tests. | |
| # It runs only when a run-enabling label (ready-precise / | |
| # main2main) asks for test execution; unlabeled runs skip it and ci-gate | |
| # decides whether that is allowed (no src paths) or requires a label (src or | |
| # ci_pipeline paths present). !cancelled() allows skipped recommendations | |
| # while the explicit pre-commit success check preserves the first gate. | |
| # Selection and cache preparation can finish even if the parallel CPU UT | |
| # fails; each NPU entry point still requires CPU UT to succeed. | |
| # The src/ci_pipeline path categories are computed by the paths-filter step | |
| # in pre-commit. Modes: | |
| # recommended - recommend job succeeded with coverage paths (ready-precise) | |
| # all - main2main forced, or the PR touches the CI | |
| # pipeline itself | |
| # none - ready-precise on a PR whose diff recommends no tests | |
| if: >- | |
| ${{ | |
| !cancelled() && | |
| needs.pre-commit.result == 'success' && | |
| ( | |
| contains(github.event.pull_request.labels.*.name, 'main2main') || | |
| contains(github.event.pull_request.labels.*.name, 'ready-precise') | |
| ) | |
| }} | |
| runs-on: linux-amd64-cpu-2-hk | |
| container: | |
| image: quay.io/ascend-ci/vllm-ascend:lint | |
| outputs: | |
| has_tests: ${{ steps.scope-rec.outputs.has_tests || steps.scope-all.outputs.has_tests || steps.noop.outputs.has_tests }} | |
| test_groups: ${{ steps.scope-rec.outputs.test_groups || steps.scope-all.outputs.test_groups || steps.noop.outputs.test_groups }} | |
| matched_modules: ${{ steps.scope-rec.outputs.matched_modules || steps.scope-all.outputs.matched_modules || steps.noop.outputs.matched_modules }} | |
| csrc_cache_target_ids: ${{ steps.cache-targets.outputs.target_ids }} | |
| base_sha: ${{ steps.source-snapshot.outputs.base_sha }} | |
| # source reports which path produced the tests: "recommended", "all", or "none". | |
| source: ${{ steps.decide.outputs.mode }} | |
| has_tests_a5: ${{ steps.scope-a5.outputs.has_tests || steps.noop-a5.outputs.has_tests }} | |
| test_groups_a5: ${{ steps.scope-a5.outputs.test_groups || steps.noop-a5.outputs.test_groups }} | |
| steps: | |
| - name: Checkout vllm-project/vllm-ascend repo | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| fetch-depth: 0 | |
| - name: Resolve source snapshot | |
| id: source-snapshot | |
| env: | |
| BASE_REF: ${{ github.base_ref }} | |
| EVENT_BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| run: | | |
| # Resolve the moving base branch once so test selection, cache | |
| # production, and cache consumption all receive one immutable SHA. | |
| git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| cd "$GITHUB_WORKSPACE" | |
| git config user.name "vllm-ascend-ci" | |
| git config user.email "vllm-ascend-ci@users.noreply.github.com" | |
| git fetch origin "$BASE_REF" | |
| BASE_SHA=$(git rev-parse FETCH_HEAD) | |
| # The workflow graph was loaded when the event was created. If its | |
| # cache control files changed on the base branch since then, pairing | |
| # the old graph with the new helpers could produce incompatible keys. | |
| # A rerun reloads the workflow and helpers from a consistent revision. | |
| if ! git diff --quiet "$EVENT_BASE_SHA" "$BASE_SHA" -- \ | |
| .github/workflows/_ensure_csrc_cache.yaml \ | |
| .github/workflows/_build_csrc_cache.yaml \ | |
| .github/workflows/scripts/csrc_cache_targets.json \ | |
| .github/workflows/scripts/resolve_csrc_cache_targets.py; then | |
| echo "::error::CSRC build workflows changed on $BASE_REF, please rebase the code." | |
| echo "::error::Trigger a new PR workflow run." | |
| exit 1 | |
| fi | |
| git rebase "$BASE_SHA" | |
| echo "base_sha=$BASE_SHA" >> "$GITHUB_OUTPUT" | |
| - name: Validate test coverage config | |
| run: | | |
| pip install pyyaml | |
| python3 .github/workflows/scripts/coverage.py | |
| - name: Decide test selection mode | |
| id: decide | |
| env: | |
| HAS_MAIN2MAIN: ${{ contains(github.event.pull_request.labels.*.name, 'main2main') }} | |
| HAS_READY_PRECISE: ${{ contains(github.event.pull_request.labels.*.name, 'ready-precise') }} | |
| # Reported by the paths-filter step in the pre-commit job; this job | |
| # does not run its own filter. Both are diagnostic only here (they | |
| # decide which modes are *allowed* in ci-gate), the labels above | |
| # decide which mode *runs*. | |
| SRC: ${{ needs.pre-commit.outputs.src }} | |
| CI_PIPELINE: ${{ needs.pre-commit.outputs.ci_pipeline }} | |
| RECOMMEND_RESULT: ${{ needs.recommend-tests.result }} | |
| COVERAGE_PATHS: ${{ needs.recommend-tests.outputs.coverage_paths }} | |
| run: | | |
| set -euo pipefail | |
| if [ "${HAS_MAIN2MAIN}" = "true" ]; then | |
| # The main2main label requests the full suite on both the verified | |
| # vLLM main commit and the release tag, so the coverage-based | |
| # recommendation cannot be used: select the whole suite instead. | |
| MODE="all" | |
| elif [ "${CI_PIPELINE}" = "true" ]; then | |
| # The PR changes the test selection/execution pipeline itself, | |
| # so the precise recommendation can no longer be trusted even | |
| # though ready-precise was set. Escalate to the full suite. | |
| MODE="all" | |
| elif [ "${HAS_READY_PRECISE}" = "true" ]; then | |
| if [ "${RECOMMEND_RESULT}" != "success" ]; then | |
| echo "::error::Coverage test recommendation did not succeed (result: ${RECOMMEND_RESULT}); not falling back to all tests" | |
| exit 1 | |
| fi | |
| if [ -n "${COVERAGE_PATHS// /}" ]; then | |
| MODE="recommended" | |
| else | |
| MODE="none" | |
| fi | |
| else | |
| echo "::error::select-tests ran without a run-enabling label; this is a workflow bug" | |
| exit 1 | |
| fi | |
| echo "mode=${MODE}" >> "$GITHUB_OUTPUT" | |
| echo "Selection mode: ${MODE} (src=${SRC:-unknown} ci_pipeline=${CI_PIPELINE:-unknown})" | |
| - name: Select tests from coverage recommendations | |
| id: scope-rec | |
| if: steps.decide.outputs.mode == 'recommended' | |
| env: | |
| COVERAGE_PATHS: ${{ needs.recommend-tests.outputs.coverage_paths }} | |
| run: | | |
| git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| pip install regex pyyaml -q | |
| LIST_FILE="$RUNNER_TEMP/recommended_from_coverage.txt" | |
| printf '%s\n' "${COVERAGE_PATHS}" > "$LIST_FILE" | |
| echo "Recommended paths from coverage:" | |
| cat "$LIST_FILE" | |
| python3 .github/workflows/scripts/select_tests.py \ | |
| --test-list-file "$LIST_FILE" \ | |
| --skip-cpu-ut \ | |
| --skip-a5 | |
| - name: Select all tests | |
| id: scope-all | |
| if: steps.decide.outputs.mode == 'all' | |
| run: | | |
| git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| pip install regex | |
| python3 .github/workflows/scripts/select_tests.py \ | |
| --all-tests \ | |
| --skip-cpu-ut \ | |
| --skip-a5 | |
| - name: Set no-tests output when no tests selected | |
| id: noop | |
| if: steps.decide.outputs.mode == 'none' | |
| run: | | |
| { | |
| echo "has_tests=false" | |
| echo "test_groups=[]" | |
| echo "matched_modules=" | |
| echo "csrc_cache_target_ids=[]" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Select A5 tests | |
| id: scope-a5 | |
| # Temporarily keep A5 allocation opt-in while runner capacity is limited. | |
| if: contains(github.event.pull_request.labels.*.name, 'ready-a5') && needs.pre-commit.outputs.src == 'true' | |
| run: | | |
| git config --global --add safe.directory /__w/vllm-ascend/vllm-ascend | |
| pip install regex | |
| python3 .github/workflows/scripts/select_tests.py \ | |
| --curated a5 \ | |
| --runner-label-override linux-aarch64-a5-4 | |
| - name: Set no-tests output for A5 when not requested or source paths unchanged | |
| id: noop-a5 | |
| if: ${{ !contains(github.event.pull_request.labels.*.name, 'ready-a5') || needs.pre-commit.outputs.src != 'true' }} | |
| run: | | |
| { | |
| echo "has_tests=false" | |
| echo "test_groups=[]" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Add upstream test cache target | |
| id: cache-targets | |
| env: | |
| SELECTED_TARGET_IDS: ${{ steps.scope-rec.outputs.csrc_cache_target_ids || steps.scope-all.outputs.csrc_cache_target_ids || steps.noop.outputs.csrc_cache_target_ids }} | |
| run: | | |
| python3 - <<'PY' | |
| import json | |
| import os | |
| target_ids = json.loads(os.environ["SELECTED_TARGET_IDS"]) | |
| target_ids = sorted(set(target_ids) | {"a2-arm64-ubuntu"}) | |
| with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output: | |
| print("target_ids=" + json.dumps(target_ids, separators=(",", ":")), file=output) | |
| PY | |
| prepare-csrc-cache: | |
| needs: | |
| - select-tests | |
| # !cancelled() is required: select-tests depends on recommend-tests, | |
| # which is skipped under main2main. Without a status check | |
| # function, the skipped need propagates transitively and skips this job | |
| # even when select-tests succeeded. | |
| if: >- | |
| ${{ | |
| !cancelled() && | |
| needs.select-tests.result == 'success' && | |
| ( | |
| contains(github.event.pull_request.labels.*.name, 'main2main') || | |
| contains(github.event.pull_request.labels.*.name, 'ready-precise') || | |
| contains(github.event.pull_request.labels.*.name, 'ready-a5') | |
| ) | |
| }} | |
| uses: ./.github/workflows/_ensure_csrc_cache.yaml | |
| with: | |
| target_ids: ${{ needs.select-tests.outputs.csrc_cache_target_ids }} | |
| source_ref: ${{ github.event.pull_request.head.sha }} | |
| base_ref: ${{ github.base_ref }} | |
| base_sha: ${{ needs.select-tests.outputs.base_sha }} | |
| run-selected-tests: | |
| needs: | |
| - pre-commit | |
| - cpu-ut | |
| - select-tests | |
| - prepare-csrc-cache | |
| # Require both CPU UT versions before allocating NPU runners. | |
| # !cancelled() overrides transitive skip-propagation from recommend-tests | |
| # (skipped under main2main) through select-tests, without | |
| # running after workflow cancel. | |
| if: >- | |
| ${{ | |
| !cancelled() && | |
| needs.pre-commit.result == 'success' && | |
| needs.cpu-ut.result == 'success' && | |
| needs.select-tests.result == 'success' && | |
| needs.prepare-csrc-cache.result == 'success' && | |
| ( | |
| contains(github.event.pull_request.labels.*.name, 'main2main') || | |
| contains(github.event.pull_request.labels.*.name, 'ready-precise') | |
| ) && | |
| needs.select-tests.outputs.has_tests == 'true' | |
| }} | |
| name: run-selected-tests (vllm@${{ matrix.vllm_version }}) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # vllm_version keeps the full ref (it becomes the checkout ref in | |
| # _selected_tests.yaml). The pre-commit job emits the primary ref alone | |
| # by default (main commit on main/dev, release tag on releases/v*) and | |
| # appends the release tag under the main2main label. | |
| vllm_version: ${{ fromJSON(needs.pre-commit.outputs.vllm_versions) }} | |
| uses: ./.github/workflows/_selected_tests.yaml | |
| with: | |
| vllm: ${{ matrix.vllm_version }} | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| base_ref: ${{ github.base_ref }} | |
| base_sha: ${{ needs.select-tests.outputs.base_sha }} | |
| test_groups: ${{ needs.select-tests.outputs.test_groups }} | |
| run-selected-tests-upstream: | |
| needs: | |
| - pre-commit | |
| - cpu-ut | |
| - select-tests | |
| - prepare-csrc-cache | |
| # Require both CPU UT versions before allocating NPU runners. | |
| # !cancelled() overrides transitive skip-propagation from recommend-tests | |
| # (recommend-tests is skipped without ready-precise) through select-tests, without running after workflow cancel. | |
| if: >- | |
| ${{ | |
| !cancelled() && | |
| needs.pre-commit.result == 'success' && | |
| needs.cpu-ut.result == 'success' && | |
| needs.select-tests.result == 'success' && | |
| needs.prepare-csrc-cache.result == 'success' && | |
| contains(github.event.pull_request.labels.*.name, 'ready-precise') && | |
| needs.select-tests.outputs.has_tests == 'true' | |
| }} | |
| name: run-selected-tests-upstream (vllm@${{ matrix.vllm_version }}) | |
| strategy: | |
| matrix: | |
| vllm_version: | |
| - ${{ needs.pre-commit.outputs.vllm_ref }} | |
| uses: ./.github/workflows/_selected_tests_upstream.yaml | |
| with: | |
| vllm: ${{ matrix.vllm_version }} | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| base_ref: ${{ github.base_ref }} | |
| base_sha: ${{ needs.select-tests.outputs.base_sha }} | |
| test_groups: ${{ needs.select-tests.outputs.test_groups }} | |
| run-selected-tests-a5: | |
| needs: [pre-commit, cpu-ut, select-tests] | |
| # Require both CPU UT versions before allocating NPU runners. | |
| # !cancelled() overrides transitive skip-propagation from recommend-tests | |
| # (recommend-tests is skipped without ready-precise) through select-tests, without running after workflow cancel. | |
| if: >- | |
| ${{ | |
| !cancelled() && | |
| needs.pre-commit.result == 'success' && | |
| needs.cpu-ut.result == 'success' && | |
| needs.select-tests.result == 'success' && | |
| needs.select-tests.outputs.has_tests_a5 == 'true' && | |
| contains(github.event.pull_request.labels.*.name, 'ready-a5') | |
| }} | |
| name: run-selected-tests-a5 (vllm@${{ matrix.vllm_version }}) | |
| strategy: | |
| matrix: | |
| vllm_version: | |
| - ${{ needs.pre-commit.outputs.vllm_ref }} | |
| uses: ./.github/workflows/_selected_tests.yaml | |
| with: | |
| vllm: ${{ matrix.vllm_version }} | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| base_ref: ${{ github.base_ref }} | |
| test_groups: ${{ needs.select-tests.outputs.test_groups_a5 }} | |
| upload-pr-context: | |
| # Post-coverage-comment context bridge. The workflow_run-triggered | |
| # post_fork_coverage_comment.yaml sees an empty pull_requests[] payload | |
| # for fork PRs, so the PR number must travel through this run's | |
| # artifacts instead. Runs regardless of test outcomes because the | |
| # comment workflow fires on any completed run. | |
| if: ${{ !cancelled() && needs.pre-commit.outputs.src == 'true' }} | |
| needs: pre-commit | |
| runs-on: linux-amd64-cpu-1-hk | |
| steps: | |
| - name: Write PR context | |
| run: | | |
| mkdir -p ./pr-context | |
| printf '{"pr_number": %s, "head_sha": "%s"}\n' \ | |
| "${{ github.event.number }}" \ | |
| "${{ github.event.pull_request.head.sha }}" \ | |
| > ./pr-context/pr_context.json | |
| cat ./pr-context/pr_context.json | |
| - name: Upload PR context | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: pr-context | |
| path: ./pr-context/pr_context.json | |
| if-no-files-found: error | |
| retention-days: 14 | |
| # Summary gate job — use this single, stable name as the required status check | |
| # in GitHub branch protection rules instead of tracking individual matrix job names. | |
| ci-gate: | |
| needs: [pre-commit, cpu-ut, select-tests, run-selected-tests, run-selected-tests-a5] | |
| # The only producer of the required `ci-gate` check. Review events | |
| # re-evaluate the gate by re-running this job inside the original | |
| # pull_request run (see pr_refresh_ci_gate.yaml), so the required check | |
| # flips in place - and no second check-run under this name is ever | |
| # created: a skipped same-name check would shadow the real verdict and | |
| # let the PR merge before the gate rewrites it. `!cancelled()` is what | |
| # makes the gate run even when a needed job failed - without it, the | |
| # default success() would skip ci-gate, and a skipped required check | |
| # counts as satisfied on GitHub. | |
| # | |
| # The CODEOWNERS gate (approval + coverage health) lives inside this job | |
| # as steps, evaluated last among the gate checks: it is a cheap API | |
| # check, and running it at the end of the workflow means reviews | |
| # submitted while the tests run are already visible when it judges - so | |
| # a mid-CI approval turns the gate green without any re-run. | |
| if: ${{ !cancelled() }} | |
| runs-on: linux-amd64-cpu-2-hk | |
| timeout-minutes: 360 | |
| permissions: | |
| # Post/delete the gate-failure PR comment (issue comments), and read | |
| # the PR's reviews and changed files for the CODEOWNERS gate. | |
| issues: write | |
| pull-requests: write | |
| # /ignore-owner re-validates the command author with | |
| # GET /collaborators/{user}/permission, which requires read access to | |
| # repository metadata that unspecified scopes do not grant. | |
| contents: read | |
| env: | |
| HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| steps: | |
| - name: Checkout the base branch | |
| # Only needed for the CODEOWNERS gate steps below. The base branch, | |
| # never the merge ref: this checkout enforces the owner gate, so both | |
| # the gate script and CODEOWNERS must come from a tree the PR cannot | |
| # alter - otherwise a PR could weaken the gate script or list itself | |
| # as an owner and approve its own changes. CODEOWNERS edits made by | |
| # a PR take effect once it merges. | |
| # Skipped on lint-failed runs on purpose: a lint failure forces a new | |
| # push that re-runs everything anyway, and the gate reports | |
| # pre-commit before the owner gate, so running the owner check there | |
| # would only burn API calls it cannot influence. | |
| if: ${{ needs.pre-commit.result == 'success' }} | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event.pull_request.base.ref }} | |
| persist-credentials: false | |
| # The gate only needs the gate script and CODEOWNERS, both under | |
| # .github/: skip the rest of the tree to keep this job off the CPU | |
| # pool as briefly as possible. | |
| sparse-checkout: .github | |
| fetch-depth: 1 | |
| - name: CODEOWNERS coverage check | |
| id: codeowners-coverage | |
| # Lightweight CODEOWNERS health gate: every changed file needs an | |
| # approval from one of its CODEOWNERS owners. Owners without org | |
| # membership or write access count as approvers on purpose (this is | |
| # why the native require_code_owner_review is not used). | |
| if: ${{ needs.pre-commit.result == 'success' }} | |
| env: | |
| COVERAGE_ERRORS_OUT: ${{ runner.temp }}/coverage_errors.txt | |
| run: python3 .github/workflows/scripts/codeowner_gate.py check-coverage | |
| - name: CODEOWNERS approval check | |
| id: codeowners-approvals | |
| if: ${{ needs.pre-commit.result == 'success' }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| UNCLAIMED_OUT: ${{ runner.temp }}/unclaimed_files.txt | |
| SELF_OWNED_OUT: ${{ runner.temp }}/self_owned_files.txt | |
| APPROVAL_FAILURES_OUT: ${{ runner.temp }}/approval_failures.txt | |
| IGNORED_OUT: ${{ runner.temp }}/ignored_files.txt | |
| run: | | |
| python3 .github/workflows/scripts/codeowner_gate.py check-approvals \ | |
| --pr "${{ github.event.pull_request.number }}" | |
| - name: Check all required jobs | |
| # always()-style execution is essential now that the CODEOWNERS gate | |
| # steps live in this job: a failing approval check must not short- | |
| # circuit this step, or the packaged gate result loses the reason | |
| # (empty reason -> the comment bot posts its generic fallback). | |
| if: ${{ !cancelled() }} | |
| id: check | |
| env: | |
| HAS_MAIN2MAIN_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'main2main') }} | |
| HAS_READY_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'ready-precise') }} | |
| HAS_READY_A5_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'ready-a5') }} | |
| SELECTION_SOURCE: ${{ needs.select-tests.outputs.source }} | |
| MATCHED_MODULES: ${{ needs.select-tests.outputs.matched_modules }} | |
| # The in-job CODEOWNERS gate steps above; 'skipped' on lint-failed | |
| # runs or when an earlier step aborted the job. | |
| CODEOWNERS_COVERAGE_OUTCOME: ${{ steps.codeowners-coverage.outcome }} | |
| CODEOWNERS_APPROVALS_OUTCOME: ${{ steps.codeowners-approvals.outcome }} | |
| run: | | |
| set -euo pipefail | |
| # Aggregate EVERY gate problem before deciding: ci-gate is the merge | |
| # gate's last checkpoint, so one push should surface all its issues | |
| # at once (lint + UT + missing owner approval + ...) instead of | |
| # revealing them one rerun at a time. Each check appends a reason; | |
| # the verdict is made once, at the end. Checks whose inputs are | |
| # meaningless because an upstream job never ran (e.g. cpu-ut | |
| # skipped because lint failed) are guarded so they only report | |
| # real failures, not cascade noise. | |
| FAILURE_FILE="${RUNNER_TEMP}/ci_gate_failure_reason.txt" | |
| rm -f "${FAILURE_FILE}" | |
| REASONS=() | |
| # shellcheck disable=SC2317 # add() is only invoked conditionally | |
| add() { | |
| REASONS+=("$1") | |
| echo "::error::${1}" | |
| } | |
| PRE_COMMIT_RESULT="${{ needs.pre-commit.result }}" | |
| CPU_UT_RESULT="${{ needs.cpu-ut.result }}" | |
| SELECT_TESTS_RESULT="${{ needs.select-tests.result }}" | |
| HAS_TESTS="${{ needs.select-tests.outputs.has_tests == 'true' }}" | |
| HAS_TESTS_A5="${{ needs.select-tests.outputs.has_tests_a5 == 'true' }}" | |
| # Path categories from the pre-commit paths-filter, read once so the | |
| # cpu-ut check and the select-tests skip branch below share them. | |
| SRC_FILTER="${{ needs.pre-commit.outputs.src }}" | |
| CI_PIPELINE_FILTER="${{ needs.pre-commit.outputs.ci_pipeline }}" | |
| CPU_UT_FILTER="${{ needs.pre-commit.outputs.cpu_ut }}" | |
| echo "=== CI Gate Summary ===" | |
| echo "pre-commit: ${PRE_COMMIT_RESULT}" | |
| echo "cpu-ut: ${CPU_UT_RESULT}" | |
| echo "src filter: ${{ needs.pre-commit.outputs.src }}" | |
| echo "ci_pipeline filter: ${{ needs.pre-commit.outputs.ci_pipeline }}" | |
| echo "vllm target: ${{ needs.pre-commit.outputs.target }} (ref: ${{ needs.pre-commit.outputs.vllm_ref }})" | |
| echo "select-tests: ${SELECT_TESTS_RESULT} (source: ${SELECTION_SOURCE:-unknown})" | |
| echo "has_tests: ${HAS_TESTS}" | |
| echo "has_tests_a5: ${HAS_TESTS_A5}" | |
| echo "labels: main2main=${HAS_MAIN2MAIN_LABEL} ready-precise=${HAS_READY_LABEL} ready-a5=${HAS_READY_A5_LABEL}" | |
| if [ "${SELECT_TESTS_RESULT}" = "success" ] && [ -n "${MATCHED_MODULES// /}" ]; then | |
| echo "matched_modules: ${MATCHED_MODULES}" | |
| fi | |
| if [ "${PRE_COMMIT_RESULT}" != "success" ]; then | |
| add "pre-commit failed (lint / markdownlint / mypy / gitleaks). Open the failed 'pre-commit' job above, fix the reported issues in your PR, and push again. No test label is needed for this failure." | |
| fi | |
| # Downstream jobs are skipped when lint failed; their results are | |
| # meaningless then and are not reported. | |
| if [ "${PRE_COMMIT_RESULT}" = "success" ]; then | |
| # cpu-ut is skipped on purpose for docs-only PRs (no src, | |
| # ci_pipeline, or cpu_ut paths, no run-enabling label). Any other | |
| # skip is a workflow bug and must fail the gate. | |
| if [ "${CPU_UT_RESULT}" = "skipped" ] && [ "${SRC_FILTER}" != "true" ] \ | |
| && [ "${CI_PIPELINE_FILTER}" != "true" ] && [ "${CPU_UT_FILTER}" != "true" ] \ | |
| && [ "${HAS_MAIN2MAIN_LABEL}" != "true" ] && [ "${HAS_READY_LABEL}" != "true" ]; then | |
| echo "::notice::cpu-ut skipped: PR changes no src/ci_pipeline/cpu_ut paths and carries no run-enabling label" | |
| elif [ "${CPU_UT_RESULT}" != "success" ]; then | |
| add "cpu-ut failed. Open the failed 'cpu-ut' job above, fix the failing test(s) and push again." | |
| fi | |
| fi | |
| # The CODEOWNERS gate runs unconditionally (including /run-triggered | |
| # runs): ci-gate is the merge gate's last checkpoint, so a missing | |
| # owner approval must surface here no matter how the run was | |
| # requested - a green gate without owner sign-off would let the PR | |
| # merge through the required check. Reported after pre-commit/cpu-ut | |
| # so a lint or UT failure does not drown it in the same rerun | |
| # cycle (PR #22133). | |
| if [ "${PRE_COMMIT_RESULT}" = "success" ]; then | |
| if [ "${CODEOWNERS_COVERAGE_OUTCOME}" != "success" ] || [ "${CODEOWNERS_APPROVALS_OUTCOME}" != "success" ]; then | |
| add "CODEOWNERS approval gate failed: at least one changed file has no approval from its owner(s). Open the 'CODEOWNERS' steps above to see which files are missing approvals and who can approve." | |
| fi | |
| fi | |
| if [ "${PRE_COMMIT_RESULT}" = "success" ]; then | |
| if [ "${SELECT_TESTS_RESULT}" = "skipped" ]; then | |
| # select-tests only runs under a run-enabling label | |
| # (ready-precise / main2main). An unlabeled run | |
| # passes the gate when (and only when) the paths-filter in | |
| # pre-commit found no src or ci_pipeline paths in the diff. | |
| if [ "${SRC_FILTER}" != "true" ] && [ "${CI_PIPELINE_FILTER}" != "true" ]; then | |
| echo "::notice::No source paths changed; precision tests are not required for this PR." | |
| else | |
| add "This PR touches source code (src=${SRC_FILTER}, ci_pipeline=${CI_PIPELINE_FILTER}), so precision/full tests are required before merge. Fix: a maintainer adds the 'ready-precise' label; the workflow reruns automatically once the label is added." | |
| fi | |
| elif [ "${SELECT_TESTS_RESULT}" != "success" ]; then | |
| add "select-tests failed. Open the failed 'select-tests' job above to see which step failed (checkout/rebase, coverage config validation, or test selection)." | |
| fi | |
| if [ "${SELECT_TESTS_RESULT}" = "success" ]; then | |
| # Even after successful test selection, only explicit true/false | |
| # values are valid. A missing output must not mean no tests. | |
| if [ "${HAS_TESTS}" != "true" ] && [ "${HAS_TESTS}" != "false" ]; then | |
| add "Invalid or missing has_tests output: '${HAS_TESTS}'" | |
| fi | |
| if [ "${HAS_TESTS_A5}" != "true" ] && [ "${HAS_TESTS_A5}" != "false" ]; then | |
| add "Invalid or missing has_tests_a5 output: '${HAS_TESTS_A5}'" | |
| fi | |
| if [ "${HAS_TESTS}" = "true" ]; then | |
| TESTS_RESULT="${{ needs.run-selected-tests.result }}" | |
| echo "run-selected-tests: ${TESTS_RESULT}" | |
| if [ "${HAS_MAIN2MAIN_LABEL}" != "true" ] && [ "${HAS_READY_LABEL}" != "true" ]; then | |
| add "This PR touches source code (test selection source: ${SELECTION_SOURCE:-unknown}), so precision/full tests are required before merge.${MATCHED_MODULES:+ Affected modules: ${MATCHED_MODULES}.} Fix: a maintainer adds the 'ready-precise' label." | |
| fi | |
| if [ "${TESTS_RESULT}" = "failure" ]; then | |
| if [ "${HAS_MAIN2MAIN_LABEL}" = "true" ]; then | |
| add "The 'main2main' dual-version E2E suite failed. Open the failed job(s) inside the run-selected-tests matrix above (one per vLLM version) and fix the failing test(s) or the code change that broke them." | |
| else | |
| add "The 'ready-precise' selected tests failed. Open the failed job(s) inside the run-selected-tests matrix above and fix the failing test(s) or the code change that broke them." | |
| fi | |
| fi | |
| fi | |
| if [ "${HAS_TESTS_A5}" = "true" ]; then | |
| TESTS_A5_RESULT="${{ needs.run-selected-tests-a5.result }}" | |
| echo "run-selected-tests-a5: ${TESTS_A5_RESULT}" | |
| if [ "${TESTS_A5_RESULT}" = "skipped" ] && [ "${HAS_READY_A5_LABEL}" != "true" ]; then | |
| echo "::notice::run-selected-tests-a5 was skipped because ready-a5 is not set" | |
| elif [ "${TESTS_A5_RESULT}" = "failure" ]; then | |
| add "The A5 test suite failed. Open the failed run-selected-tests-a5 job above for details." | |
| elif [ "${TESTS_A5_RESULT}" = "skipped" ] && [ "${HAS_READY_A5_LABEL}" = "true" ]; then | |
| add "run-selected-tests-a5 was skipped although the ready-a5 label is set. Open the run-selected-tests-a5 job above for why it was skipped." | |
| fi | |
| fi | |
| fi | |
| fi | |
| if [ "${#REASONS[@]}" -gt 0 ]; then | |
| # One comment lists every problem; the step below posts (or | |
| # updates) it on the PR. | |
| printf '%s\n' "${REASONS[@]}" > "${FAILURE_FILE}" | |
| echo "=== CI Gate: FAILED (${#REASONS[@]} problem(s)) ===" | |
| exit 1 | |
| fi | |
| echo "=== CI Gate: PASSED ===" | |
| - name: Upload gate details for the comment bot | |
| # Per-PR details for the failure comment: which files lack an owner | |
| # (no approval required) and which files are missing owner approvals | |
| # (with the exact owners to ask). Always uploaded so the bot can read | |
| # empty lists too. Skipped steps leave no files behind, so the bot | |
| # simply omits those sections (download uses continue-on-error). | |
| if: ${{ always() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: codeowner-details-${{ github.run_id }} | |
| retention-days: 1 | |
| # 'warn', not 'error': the CODEOWNERS steps are skipped on | |
| # lint-failed runs, leaving no detail files. | |
| if-no-files-found: warn | |
| path: | | |
| ${{ runner.temp }}/unclaimed_files.txt | |
| ${{ runner.temp }}/self_owned_files.txt | |
| ${{ runner.temp }}/approval_failures.txt | |
| ${{ runner.temp }}/ignored_files.txt | |
| ${{ runner.temp }}/coverage_errors.txt | |
| - name: Package gate result | |
| if: ${{ always() }} | |
| env: | |
| CHECK_OUTCOME: ${{ steps.check.outcome }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: | | |
| python3 - <<'PY' | |
| import json | |
| import os | |
| result_dir = os.path.join(os.environ["RUNNER_TEMP"], "ci-gate-result") | |
| os.makedirs(result_dir, exist_ok=True) | |
| reason_file = os.path.join( | |
| os.environ["RUNNER_TEMP"], "ci_gate_failure_reason.txt") | |
| try: | |
| with open(reason_file) as f: | |
| reason = f.read().strip() | |
| except OSError: | |
| reason = "" | |
| result = { | |
| "conclusion": os.environ["CHECK_OUTCOME"], | |
| "reason": reason, | |
| "pr": int(os.environ["PR_NUMBER"]), | |
| "head_sha": os.environ["HEAD_SHA"], | |
| } | |
| with open(os.path.join(result_dir, "ci-gate-result.json"), "w") as f: | |
| json.dump(result, f) | |
| PY | |
| - name: Upload gate result for the comment bot | |
| # The PR comment is posted by bot_ci_gate_comment.yml (workflow_run) | |
| # in the base repo context: fork PRs get a read-only GITHUB_TOKEN | |
| # here, so this job must not depend on write access. The bot never | |
| # touches PR code, so its write token is safe. | |
| if: ${{ always() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ci-gate-result-${{ github.run_id }} | |
| retention-days: 1 | |
| if-no-files-found: error | |
| path: ${{ runner.temp }}/ci-gate-result/ci-gate-result.json | |