name: PR Test (MLU) # Label-gated MLU CI workflow. The PR must carry BOTH `run-ci` (basic-CI # prerequisite) and `run-ci-mlu` (explicit opt-in) for the MLU test job to # run. Without `run-ci-mlu`, the workflow skips the gate and MLU suites. on: # Run the reviewed base-branch workflow, never workflow code from the PR. pull_request_target: branches: [ main ] # `labeled` lets the workflow re-fire when `run-ci-mlu` (or `run-ci`) # is added after the latest push. See call-gate.if for the matching guard # that prevents unrelated label additions from dispatching a full run. types: [opened, synchronize, reopened, labeled] workflow_dispatch: inputs: ref: description: "Git ref (branch, tag, or SHA) to test. If not provided, uses the current ref." required: false type: string default: "" permissions: actions: read contents: read pull-requests: read concurrency: group: pr-test-mlu-${{ github.event.pull_request.number || inputs.ref || github.ref }}-${{ (github.event.action == 'labeled' && github.event.label.name != 'run-ci' && github.event.label.name != 'run-ci-mlu') && github.run_id || 'main' }} cancel-in-progress: true jobs: check-mlu-opt-in: runs-on: ubuntu-latest outputs: enabled: ${{ github.event_name != 'pull_request_target' || steps.labels.outputs.enabled == 'true' }} steps: - name: Check current PR labels if: github.event_name == 'pull_request_target' id: labels uses: actions/github-script@v8 with: script: | const pr = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, pull_number: context.issue.number, }); core.setOutput( "enabled", String(pr.data.labels.some((label) => label.name === "run-ci-mlu")), ); # Filter unrelated label additions, then let the reusable gate enforce # run-ci and the remaining PR policies after opt-in. call-gate: needs: [check-mlu-opt-in] if: | needs.check-mlu-opt-in.outputs.enabled == 'true' && ( github.event_name != 'pull_request_target' || github.event.action != 'labeled' || github.event.label.name == 'run-ci' || github.event.label.name == 'run-ci-mlu' ) uses: ./.github/workflows/pr-gate.yml with: require-run-ci: true require-label: run-ci-mlu secrets: inherit pr-test-mlu: name: MLU / ${{ matrix.suite }} needs: [check-mlu-opt-in, call-gate] if: ${{ !cancelled() && needs.check-mlu-opt-in.outputs.enabled == 'true' && needs.call-gate.result == 'success' }} strategy: fail-fast: false matrix: suite: - pr-test-1-mlu - pr-test-2-mlu runs-on: group: mlu-ci labels: mlu-pr timeout-minutes: 120 steps: # Fetch the helper from the trusted workflow commit, never the PR/test ref. - name: Checkout MLU CI helper uses: actions/checkout@v4 with: repository: ${{ github.repository }} ref: ${{ github.workflow_sha }} path: mlu-ci-workflow persist-credentials: false sparse-checkout: scripts/ci/utils/resolve_mlu_ci_ref.sh sparse-checkout-cone-mode: false - name: Resolve MLU CI ref to commit SHA id: resolve-ref env: INPUT_REF: ${{ inputs.ref }} DEFAULT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} REPO_URL: ${{ github.event.pull_request.head.repo.clone_url || format('{0}/{1}.git', github.server_url, github.repository) }} run: bash mlu-ci-workflow/scripts/ci/utils/resolve_mlu_ci_ref.sh # Do not checkout the PR on this self-hosted runner. Jenkins # receives and executes the immutable PR SHA in its isolated MLU pod. - name: Submit MLU CI task to Cambricon Runner env: SGLANG_MLU_CI_REPO_NAME: sglang SGLANG_MLU_CI_PR_ID: ${{ github.event.pull_request.number || '' }} SGLANG_MLU_CI_REPO_URL: ${{ github.event.pull_request.head.repo.clone_url || format('{0}/{1}.git', github.server_url, github.repository) }} SGLANG_MLU_CI_GIT_REF: ${{ inputs.ref || github.event.pull_request.head.sha || github.ref_name }} SGLANG_MLU_CI_COMMIT_SHA: ${{ steps.resolve-ref.outputs.commit_sha }} SGLANG_MLU_CI_TRIGGER_TYPE: ${{ matrix.suite }} SGLANG_MLU_CI_BRIDGE_URL: http://127.0.0.1:14547 SGLANG_MLU_CI_TIMEOUT_SECONDS: "6600" SGLANG_MLU_CI_LOG_DIR: ${{ runner.temp }}/mlu-ci-logs SGLANG_MLU_CI_OBSERVE_ONLY: ${{ github.event_name == 'pull_request_target' }} run: | if ! command -v sglang-mlu-ci >/dev/null 2>&1; then classification="MLU CI failure classification: type=infrastructure, stage=runner_client" mkdir -p "${SGLANG_MLU_CI_LOG_DIR}" observe_only=false conclusion=failure annotation=error annotation_title="MLU CI infrastructure failure" policy=failure exit_code=1 if [[ "${SGLANG_MLU_CI_OBSERVE_ONLY}" == "true" ]]; then observe_only=true conclusion=success annotation=warning annotation_title="MLU CI infrastructure warning" policy="warning (observe-only; GitHub job remains successful)" exit_code=0 fi echo "::${annotation} title=${annotation_title}::${classification}" { echo "## MLU CI result" echo echo "- Status: \`error\`" echo "- Failure type: \`infrastructure\`" echo "- Failure stage: \`runner_client\`" echo "- GitHub conclusion policy: ${policy}" } >> "${GITHUB_STEP_SUMMARY}" printf '{\n "failure_stage": "runner_client",\n "failure_type": "infrastructure",\n "github_conclusion": "%s",\n "observe_only": %s,\n "status": "error",\n "task_id": "runner-client-%s-%s"\n}\n' \ "${conclusion}" "${observe_only}" "${GITHUB_RUN_ID}" "${GITHUB_RUN_ATTEMPT}" \ > "${SGLANG_MLU_CI_LOG_DIR}/result-runner-client-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}.json" exit "${exit_code}" fi exec sglang-mlu-ci - name: Upload MLU CI result metadata if: always() uses: actions/upload-artifact@v4 with: name: mlu-ci-result-pr-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.suite }} path: ${{ runner.temp }}/mlu-ci-logs/result-*.json retention-days: 30 if-no-files-found: warn - name: Upload MLU Jenkins log if: always() uses: actions/upload-artifact@v4 with: name: mlu-jenkins-log-pr-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.suite }} path: ${{ runner.temp }}/mlu-ci-logs/ if-no-files-found: warn