# Document 1: Buildkite loads only this block on first parse. The next step resolves docs-only skip-ci
# from git diff, then uploads document 2. When docs-only skip applies, image-build still runs for the nightly
# exception in upload_pipeline_with_skip_ci.sh (nightly-test label or main NIGHTLY=1); otherwise upload-nightly
# can be skipped together with test-ready/test-merge. Weekly uploads also depend on image-build.

# Document 2: appended after `---`; same file, read by upload_pipeline_with_skip_ci.sh (not evaluated as a second pipeline by Buildkite). Child uploads include test-ready.yml, test-merge.yml, test-nightly.yml, and test-weekly.yml.
steps:
  - label: ":github: Resolve skip-ci & upload pipeline"
    key: upload-ci-pipeline
    commands:
      - "bash .buildkite/scripts/upload_pipeline_with_skip_ci.sh"
    agents:
      queue: "cpu_queue_premerge"

---
steps:
  - label: ":docker: Build image"
    key: image-build
    if: __IMAGE_BUILD_IF__
    commands:
      - "aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/q9t5s3a7"
      - "docker build --progress=plain --file docker/Dockerfile.ci -t vllm-omni-ci ."
      - "docker tag vllm-omni-ci public.ecr.aws/q9t5s3a7/vllm-ci-test-repo:$BUILDKITE_COMMIT"
      - "docker push public.ecr.aws/q9t5s3a7/vllm-ci-test-repo:$BUILDKITE_COMMIT"
    agents:
      queue: "cpu_queue_premerge"

  # L2 Test
  - label: "Upload Ready Pipeline"
    depends_on: image-build
    key: upload-ready-pipeline
    if: __UPLOAD_READY_IF__
    commands:
      - buildkite-agent pipeline upload .buildkite/test-ready.yml
    agents:
      queue: "cpu_queue_premerge"

  # L3 Test
  - label: "Upload Merge Pipeline"
    depends_on: image-build
    key: upload-merge-pipeline
    if: __UPLOAD_MERGE_IF__
    commands:
      - buildkite-agent pipeline upload .buildkite/test-merge.yml
    agents:
      queue: "cpu_queue_premerge"

  # L4 Test — main+NIGHTLY=1 (scheduled), or PR with specific label (e.g. add label then Rebuild)
  - label: "Upload Nightly Pipeline"
    depends_on: image-build
    key: upload-nightly-pipeline
    if: >-
      (build.branch == "main" && build.env("NIGHTLY") == "1") ||
      (build.branch != "main" && (
        build.pull_request.labels includes "nightly-test" ||
        build.pull_request.labels includes "omni-test" ||
        build.pull_request.labels includes "tts-test" ||
        build.pull_request.labels includes "diffusion-x2iat-test" ||
        build.pull_request.labels includes "diffusion-x2v-test"
      ))
    commands:
      - buildkite-agent pipeline upload .buildkite/test-nightly.yml
    agents:
      queue: "cpu_queue_premerge"

  # L5 Test — main+WEEKLY=1 (scheduled), or PR with weekly-test label
  - label: "Upload Weekly Pipeline"
    depends_on: image-build
    key: upload-weekly-pipeline
    if: >-
      (build.branch == "main" && build.env("WEEKLY") == "1") ||
      (build.branch != "main" && build.pull_request.labels includes "weekly-test")
    commands:
      - buildkite-agent pipeline upload .buildkite/test-weekly.yml
    agents:
      queue: "cpu_queue_premerge"
