Skip to content

Commit 35437cd

Browse files
merge
2 parents 7f5914d + 9294041 commit 35437cd

74 files changed

Lines changed: 4524 additions & 1657 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/citest.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: citest
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- "release/**"
8+
paths-ignore:
9+
- "docs/**"
10+
- "temp/**"
11+
- "README.md"
12+
- "LICENSE"
13+
- ".github/workflows/publish.yaml"
14+
15+
pull_request:
16+
paths-ignore:
17+
- "docs/**"
18+
- "temp/**"
19+
- "README.md"
20+
- "LICENSE"
21+
- ".github/workflows/publish.yaml"
22+
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.ref }}
25+
cancel-in-progress: true
26+
27+
jobs:
28+
unittest:
29+
# Mock mode: no credentials, no network calls to the Hub. This mirrors
30+
# distro build sandboxes (NixOS/FreeBSD) so a green run here means the
31+
# test suite also passes when downstream packagers run it.
32+
runs-on: ubuntu-latest
33+
timeout-minutes: 30
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
# 3.10 = oldest supported, 3.14 = used by NixOS packaging.
38+
python-version: ["3.10", "3.12", "3.14"]
39+
env:
40+
MODELSCOPE_RUN_REMOTE_TESTS: "false"
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v4
44+
45+
- name: Set up Python ${{ matrix.python-version }}
46+
uses: actions/setup-python@v5
47+
with:
48+
python-version: ${{ matrix.python-version }}
49+
50+
- name: Install package with dev dependencies
51+
run: pip install -e ".[dev]"
52+
53+
- name: Run unit tests (mock mode)
54+
run: pytest tests/ --ignore=tests/integration -q
55+
56+
lint:
57+
# Hard gate: the ruff/mypy backlog was cleared, keep it at zero.
58+
runs-on: ubuntu-latest
59+
timeout-minutes: 10
60+
steps:
61+
- name: Checkout
62+
uses: actions/checkout@v4
63+
64+
- name: Set up Python
65+
uses: actions/setup-python@v5
66+
with:
67+
python-version: "3.13"
68+
69+
- name: Install package with dev dependencies
70+
run: pip install -e ".[dev]"
71+
72+
- name: Ruff check
73+
run: ruff check src/ tests/
74+
75+
- name: Ruff format check
76+
run: ruff format --check src/ tests/
77+
78+
- name: Mypy
79+
run: mypy src/modelscope_hub/

.github/workflows/publish.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,29 @@ concurrency:
1010
cancel-in-progress: true
1111

1212
jobs:
13+
test-gate:
14+
# Release gate: the mock-mode suite must pass before anything is built
15+
# or uploaded. Same environment shape as downstream distro sandboxes.
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 30
18+
env:
19+
MODELSCOPE_RUN_REMOTE_TESTS: "false"
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Set up Python 3.13
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: '3.13'
27+
28+
- name: Install package with dev dependencies
29+
run: pip install -e ".[dev]"
30+
31+
- name: Run unit tests (mock mode)
32+
run: pytest tests/ --ignore=tests/integration -q
33+
1334
build-n-publish:
35+
needs: test-gate
1436
runs-on: ubuntu-22.04
1537
steps:
1638
- uses: actions/checkout@v4

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Local pre-commit hooks. Optional but recommended: CI (citest.yaml) enforces
2+
# the same checks as a hard gate, this just gives faster feedback.
3+
#
4+
# Setup:
5+
# pip install pre-commit && pre-commit install
6+
repos:
7+
- repo: https://github.com/astral-sh/ruff-pre-commit
8+
rev: v0.15.11
9+
hooks:
10+
- id: ruff-check
11+
args: [--fix]
12+
files: ^(src|tests)/
13+
- id: ruff-format
14+
files: ^(src|tests)/
15+
# mypy is intentionally left to CI: a full run over src/ takes too long for a
16+
# commit hook and needs the package's own dependencies installed.

0 commit comments

Comments
 (0)