Skip to content

Commit d81568d

Browse files
committed
add ci image build test
Signed-off-by: yangzeyu <532183776@qq.com>
1 parent 35d436e commit d81568d

3 files changed

Lines changed: 39 additions & 16 deletions

File tree

.buildkite/README-NPU-CI.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,46 @@ Three steps run in order:
1212

1313
**`pre-commit-npu`** runs the pre-commit gate on all files, always.
1414

15-
**`image-build-npu`** builds and pushes the NPU test image via buildctl/buildkit.
16-
It only runs when `Dockerfile.npu` has changed (PR trigger) or on a scheduled
17-
build — otherwise the step is skipped and the pre-built default image is used.
15+
**`npu-gate`** is a block step that pauses the pipeline for manual interaction.
16+
It appears only on PR triggers (`build.source != "schedule"`). You select which
17+
NPU suites to run via a multi-select field:
18+
19+
- **`image-build`** — triggers a fresh image build in the `image-build-npu` step;
20+
when selected, `smk` is automatically included and all test steps use the newly
21+
built image instead of the pre-built default.
22+
- **`smk`** — runs the smoke test suite.
23+
- **`nightly`** — runs the nightly test suite.
24+
25+
**`image-build-npu`** the `image-build-npu` step will build and
26+
push a fresh NPU test image tagged with the current commit. When `image-build`
27+
is selected, all test steps generated by `upload-npu-suites` use the newly built
28+
image instead of the pre-built default image.
29+
30+
This allows testing code changes that require an updated NPU environment
31+
(e.g., modifications to `docker/Dockerfile.npu`) before they are merged.
1832

1933
**`upload-npu-suites`** reads the `NPU_SUITES` environment variable (or
2034
`buildkite-agent meta-data get npu-suites` for PR triggers) and generates
2135
individual test jobs via [`npu_suites.py`](./npu_suites.py).
2236

2337
## Triggers
2438

25-
The pipeline supports three trigger modes:
39+
The pipeline supports two trigger modes:
2640

27-
**PR trigger.** On a PR trigger, the pre-built default image is used and
28-
test suites are selected manually via the block step.
41+
**PR trigger.** The `npu-gate` block step appears for manual suite selection.
42+
Suites not selected in the block step are skipped. The `image-build-npu` step
43+
builds a new image only when `image-build` is chosen in the block.
2944

30-
**Schedule trigger.** On a scheduled build, a new image is always built
31-
regardless of file changes. The suites to run are determined by the
45+
**Schedule trigger.** There is no block step — the `npu-gate` step is omitted
46+
entirely. A new image is **always** built, and the suites are determined by the
3247
`NPU_SUITES` environment variable (set in the scheduled build's pipeline
33-
configuration), which selects the corresponding entries from the `SUITES` dict.
48+
configuration), which lists suite names from the `SUITES` dict.
3449

3550
## Adding a test
3651

3752
Suites and test mappings are defined in [`npu_suites.py`](./npu_suites.py). Two
38-
suites are predefined — `smk` (always runs) and `nightly` (runs on schedule or
39-
with the `run-ci-npu-nightly` label).
53+
suites are predefined — `smk` (runs with the `run-ci-npu-smk` label) and `nightly`
54+
(runs on schedule or with the `run-ci-npu-nightly` label).
4055

4156
Each entry is a 4-tuple:
4257

.buildkite/npu_suites.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
IMAGE_REGISTRY = "swr.cn-southwest-2.myhuaweicloud.com/modelfoundry"
2424
IMAGE_NAME = "vime-ci-npu"
2525
VIME_IMAGE_TAG = os.environ.get("BUILDKITE_COMMIT", "latest")
26+
BUILDKITE_SOURCE = os.environ.get("BUILDKITE_SOURCE", "")
2627

2728
# (test_name, resource_class, extra_args, env_overrides)
2829
SUITES = {
@@ -51,7 +52,7 @@ def _read_suite_values() -> list[str]:
5152

5253
def _ci_image() -> str:
5354
values = _read_suite_values()
54-
if "image-build" in values:
55+
if ("image-build" in values) or (BUILDKITE_SOURCE == "schedule"):
5556
return f"{IMAGE_REGISTRY}/{IMAGE_NAME}:{VIME_IMAGE_TAG}"
5657
return DEFAULT_CI_IMAGE
5758

@@ -61,6 +62,9 @@ def selected_suites() -> list:
6162
unknown = [v for v in values if v and v not in SUITES and v != "image-build"]
6263
if unknown:
6364
raise SystemExit(f"unknown suite(s) {unknown}; expected {sorted(SUITES)}")
65+
if "image-build" in values:
66+
# image-build auto-includes smk tests
67+
values.extend("smk")
6468
return [s for s in SUITES if s in values]
6569

6670

@@ -118,7 +122,7 @@ def main() -> None:
118122
steps = [npu_step(suite, *entry) for suite in selected_suites() for entry in SUITES[suite]]
119123
json_str = json.dumps({"steps": steps}, indent=2)
120124

121-
print("--- Generated Pipeline JSON (debug):", file=sys.stderr)
125+
print("--- Generated Pipeline JSON:", file=sys.stderr)
122126
print(json_str, file=sys.stderr)
123127

124128
print(json_str)

.buildkite/pipeline-npu.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ steps:
4545
multiple: true
4646
required: true
4747
options:
48-
- label: "run-npu-ci-image-build (test new image)"
48+
- label: "run-npu-ci-image-build (test new image, auto include smk)"
4949
value: image-build
5050
- label: "run-npu-ci-smk"
5151
value: smk
@@ -104,7 +104,11 @@ steps:
104104
command: |
105105
set -ex
106106
NPU_SUITES=$$(buildkite-agent meta-data get "npu-suites" --default "")
107-
if [[ "$$NPU_SUITES" != *"image-build"* ]]; then
107+
if [[ "$$BUILDKITE_SOURCE" == "schedule" ]]; then
108+
echo "Scheduled build — building the image."
109+
elif [[ "$$NPU_SUITES" == *"image-build"* ]]; then
110+
echo "image-build selected — building the image."
111+
else
108112
echo "Skipping this step because image-build is not present in npu-suites."
109113
exit 0
110114
fi
@@ -150,7 +154,7 @@ steps:
150154
key: upload-npu-suites
151155
depends_on:
152156
- npu-gate
153-
- pre-commit-npu
157+
- image-build-npu
154158
agents:
155159
queue: "ascend-a3"
156160
resource_class: "npu-2"

0 commit comments

Comments
 (0)