Skip to content

Commit b29e297

Browse files
[CI] allow CI skip test & clean ci logic (#2771)
* [CI] add skip to allow CI skip it * [CI] merge xpu check into no gpu check step * [CI] fix KeyError: 'group not found: tests/models/awq'
1 parent ea5a84a commit b29e297

3 files changed

Lines changed: 32 additions & 41 deletions

File tree

.github/scripts/ci_workflow.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ def parse_test_config_for_path(
8989
scoped_test_name = None
9090
if index == len(candidate_groups) - 1:
9191
scoped_test_name = leaf_name
92-
scoped = parse_test_config(yaml_file, candidate_group, scoped_test_name)
92+
try:
93+
scoped = parse_test_config(yaml_file, candidate_group, scoped_test_name)
94+
except KeyError:
95+
continue
9396
result.update(scoped)
9497
return result
9598

@@ -125,17 +128,33 @@ def is_model_compat_test(rel_path: str, file_path: Path) -> bool:
125128
return any(marker in contents for marker in markers)
126129

127130

131+
def matches_test_regex(test_regex: str, rel_path: str) -> bool:
132+
if re.match(test_regex, rel_path):
133+
return True
134+
return re.match(test_regex, PurePosixPath(rel_path).name) is not None
135+
136+
137+
def should_skip_test(yaml_file: str | Path, rel_path: str) -> bool:
138+
try:
139+
config = parse_test_config_for_path(yaml_file, "tests", rel_path)
140+
except KeyError:
141+
return False
142+
return bool(config.get("skip", False))
143+
144+
128145
def list_tests(ignored_test_files: str | list[str], test_names: str, test_regex: str, tests_root: str | Path) -> tuple[list[str], list[str], list[str]]:
129146
tests_root = Path(tests_root)
130147
input_tests = [strip_py_suffix(name) for name in split_csv(test_names)]
131148
ignored_raw = ignored_test_files if isinstance(ignored_test_files, list) else split_csv(ignored_test_files)
132149
ignored_set = {strip_py_suffix(name) for name in ignored_raw}
150+
yaml_file = Path(__file__).with_name("test.yaml")
133151

134152
all_tests = {
135153
rel: path
136154
for path in tests_root.rglob("test_*.py")
137155
for rel in [str(path.relative_to(tests_root).with_suffix(""))]
138156
if rel not in ignored_set and path.stem not in ignored_set
157+
if not should_skip_test(yaml_file, rel)
139158
}
140159

141160
model_tests = {
@@ -145,7 +164,7 @@ def list_tests(ignored_test_files: str | list[str], test_names: str, test_regex:
145164
and "mlx" not in rel
146165
and "ipex" not in rel
147166
and "xpu" not in rel
148-
and re.match(test_regex, rel)
167+
and matches_test_regex(test_regex, rel)
149168
and is_model_compat_test(rel, path)
150169
}
151170

@@ -157,15 +176,15 @@ def list_tests(ignored_test_files: str | list[str], test_names: str, test_regex:
157176
and "mlx" not in rel
158177
and "ipex" not in rel
159178
and "xpu" not in rel
160-
and re.match(test_regex, rel)
179+
and matches_test_regex(test_regex, rel)
161180
}
162181

163182
mlx_tests = {
164183
rel
165184
for rel in all_tests
166185
if ("mlx" in rel or "apple" in rel)
167186
and ((rel in input_tests) if input_tests else True)
168-
and re.match(test_regex, rel)
187+
and matches_test_regex(test_regex, rel)
169188
}
170189

171190
return (

.github/scripts/test.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ common:
22
py: 3.14t # common config
33
gpu: 1
44
sm: 0
5+
skip: false
56

67
tests:
78
test_multi_gpu_inference: # per-test config
@@ -18,4 +19,5 @@ tests/models:
1819

1920
tests/kernels:
2021
test_asymmetric_real_models:
21-
sm: '9.0'
22+
sm: '9.0'
23+
skip: true # no SM90 card

.github/workflows/unit_tests.yml

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -301,37 +301,6 @@ jobs:
301301
echo "--- uninstalling required deps..."
302302
python .github/scripts/ci_deps.py uninstall ${{ matrix.test_script }}
303303
304-
# - name: Install Evalution
305-
# run: |
306-
# uv pip install git+https://x-access-token:${{ secrets.REPO_TOKEN }}@github.com/ModelCloud/Evalution.git
307-
# - name: Install requirements
308-
# run: |
309-
# bash -c "$(curl -L http://${RUNNER}/scripts/env/init_compiler_no_env.sh)" @ ${{ needs.check-vm.outputs.cuda_version }} ${{ env.TORCH_VERSION }} $python_version${{ env.PYTHON_VERSION }}
310-
311-
# - name: Download source from local
312-
# continue-on-error: true
313-
# run: |
314-
# curl -s -O http://$RUNNER/whl/${{ env.repo }}/${{ github.run_id }}/gptqmodel_source.tar.gz
315-
# ls -ahl .
316-
# sha256=$(sha256sum $file_name)
317-
# echo "sha256=$sha256"
318-
# echo "SOURCE_DOWNLOADED=1" >> $GITHUB_ENV
319-
320-
# - name: Download source from github
321-
# if: env.SOURCE_DOWNLOADED == '' && !cancelled()
322-
# uses: actions/download-artifact@v8
323-
# with:
324-
# name: source
325-
# path: dist
326-
# run-id: ${{ github.run_id }}
327-
328-
# - name: Uncompress source
329-
# continue-on-error: true
330-
# run: |
331-
# find . -mindepth 1 ! -name "gptqmodel_source.tar.gz" -exec rm -rf {} +
332-
# ls -ahl .
333-
# tar -zxf gptqmodel_source.tar.gz
334-
335304
- name: Install package from source
336305
run: |
337306
uv pip uninstall gptqmodel || true
@@ -394,12 +363,14 @@ jobs:
394363
run: |
395364
if grep -q '^# GPU=-1$' "${{ matrix.test_script }}"; then
396365
echo "SKIP_GPU_ALLOCATION=true" >> "$GITHUB_ENV"
366+
elif [[ "${{ matrix.test_script }}" == *xpu* ]]; then
367+
echo "SKIP_GPU_ALLOCATION=true" >> "$GITHUB_ENV"
397368
else
398369
echo "SKIP_GPU_ALLOCATION=false" >> "$GITHUB_ENV"
399370
fi
400371
401372
- name: Find suitable GPU
402-
if: ${{ !contains(matrix.test_script, 'ipex') && !contains(matrix.test_script, 'xpu') && !cancelled() && env.SKIP_GPU_ALLOCATION != 'true' }}
373+
if: ${{ !cancelled() && env.SKIP_GPU_ALLOCATION != 'true' }}
403374
run: |
404375
python .github/scripts/ci_gpu.py allocate \
405376
--base-url "${GPU_ALLOCATOR_URL}" \
@@ -413,9 +384,6 @@ jobs:
413384
- name: Run tests
414385
run: |
415386
extra_args=()
416-
if [[ "${{ matrix.test_script }}" == *ipex* ]]; then
417-
extra_args+=(--clear-cuda)
418-
fi
419387
if [[ "${{ matrix.test_script }}" == *xpu* ]]; then
420388
extra_args+=(--clear-cuda --xpu-mode)
421389
fi
@@ -436,7 +404,7 @@ jobs:
436404
--test-script "${{ matrix.test_script }}"
437405
438406
- name: Release GPU
439-
if: always() && !contains(matrix.test_script, 'ipex') && !contains(matrix.test_script, 'xpu') && env.SKIP_GPU_ALLOCATION != 'true'
407+
if: always() && env.SKIP_GPU_ALLOCATION != 'true'
440408
run: |
441409
python .github/scripts/ci_gpu.py release \
442410
--base-url "${GPU_ALLOCATOR_URL}" \
@@ -628,6 +596,8 @@ jobs:
628596
run: |
629597
if grep -q '^# GPU=-1$' "${{ matrix.test_script }}"; then
630598
echo "SKIP_GPU_ALLOCATION=true" >> "$GITHUB_ENV"
599+
elif [[ "${{ matrix.test_script }}" == *xpu* ]]; then
600+
echo "SKIP_GPU_ALLOCATION=true" >> "$GITHUB_ENV"
631601
else
632602
echo "SKIP_GPU_ALLOCATION=false" >> "$GITHUB_ENV"
633603
fi

0 commit comments

Comments
 (0)