-
Notifications
You must be signed in to change notification settings - Fork 2
235 lines (200 loc) · 7.46 KB
/
Copy pathsubmodule-tests.yml
File metadata and controls
235 lines (200 loc) · 7.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
name: submodule-tests
on:
pull_request:
branches: [dev, master, code-optimization]
types: [opened, synchronize, reopened]
schedule:
- cron: "0 18 * * *"
workflow_dispatch:
permissions:
contents: read
jobs:
submodule-gate:
name: Submodule Gate / Core Reference
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Detect submodule changes
id: detect
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
GITLINKS=$(git diff --raw "$BASE_SHA..$HEAD_SHA" | awk '$2 == "160000"' | wc -l | tr -d ' ')
echo "count=$GITLINKS" >> "$GITHUB_OUTPUT"
- name: Checkout changed submodule graph
if: steps.detect.outputs.count != '0'
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 1
- name: Validate core-reference in isolated environments
id: validation
if: steps.detect.outputs.count != '0'
continue-on-error: true
run: |
python scripts/ci/submodule_validation.py \
--profile core-reference \
--artifacts-dir submodule-artifacts/core-reference
- name: Record not-applicable evidence
if: steps.detect.outputs.count == '0'
run: |
mkdir -p submodule-artifacts
printf '{"result":"not-applicable","reason":"no gitlink change"}\n' > submodule-artifacts/not-applicable.json
- name: Upload submodule validation artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: submodule-validation-pr-${{ github.event.pull_request.number }}
# Keep the durable phase evidence, not the disposable virtualenvs
# and wheel build directories. Uploading those transient files can
# exhaust the artifact action's Node heap on diagnostic runs.
path: |
submodule-artifacts/**/submodule-validation.json
submodule-artifacts/**/submodule-validation.junit.xml
submodule-artifacts/**/submodule-validation.md
submodule-artifacts/**/logs/**
if-no-files-found: error
retention-days: 30
- name: Publish gate summary
if: always()
run: |
{
echo "## Submodule Gate / Core Reference"
echo ""
if [ "${{ steps.detect.outputs.count }}" = "0" ]; then
echo "- Result: **not-applicable** (no gitlink change)"
else
echo "- Result: **${{ steps.validation.outcome }}**"
echo "- Evidence: JSON, JUnit, Markdown index, and per-phase logs are attached."
fi
} >> "$GITHUB_STEP_SUMMARY"
- name: Fail changed-submodule PR when core reference fails
if: steps.detect.outputs.count != '0' && steps.validation.outcome != 'success'
run: exit 1
# 迭代07:子仓 lint 与 format 分别按仓分片,并维持 report-only。
# 截至 2026-09-20:lint 存量 10 项、format 涉及 452 个文件。
# 两项需分别清零、稳定 CI、独立回滚后,才分别升级为 blocking。
# 滚动棘轮由 .github/workflows/tests.yml 的 quality-ratchet job 承担。
discover-submodules:
name: Discover submodules
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
modules: ${{ steps.list.outputs.modules }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1
- name: List bt_api_* checkouts
id: list
run: |
MODULES=$(ls -d bt_api/bt_api_* 2>/dev/null | xargs -n1 basename | sort | paste -sd, -)
MODULES_JSON=$(printf '%s' "$MODULES" | python3 -c \
'import json,sys; print(json.dumps([m for m in sys.stdin.read().strip().split(",") if m]))')
echo "modules=$MODULES_JSON" >> "$GITHUB_OUTPUT"
echo "Discovered submodules: $MODULES_JSON"
submodule-lint:
name: Submodule Lint / ${{ matrix.module }}
needs: discover-submodules
runs-on: ubuntu-latest
timeout-minutes: 10
# report-only:lint 存量清零并满足上方独立升级条件后再改为阻塞。
continue-on-error: true
strategy:
fail-fast: false
matrix:
module: ${{ fromJSON(needs.discover-submodules.outputs.modules) }}
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 1
- uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
cache-dependency-path: pyproject.toml
- name: Install ruff
run: |
python -m pip install --upgrade pip
pip install "ruff==0.16.2"
- name: Ruff lint (${{ matrix.module }})
run: ruff check bt_api/${{ matrix.module }}
submodule-format:
name: Submodule Format / ${{ matrix.module }}
needs: discover-submodules
runs-on: ubuntu-latest
timeout-minutes: 10
# report-only:format 存量清零并满足上方独立升级条件后再改为阻塞。
continue-on-error: true
strategy:
fail-fast: false
matrix:
module: ${{ fromJSON(needs.discover-submodules.outputs.modules) }}
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 1
- uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
cache-dependency-path: pyproject.toml
- name: Install ruff
run: |
python -m pip install --upgrade pip
pip install "ruff==0.16.2"
- name: Ruff format check (${{ matrix.module }})
run: ruff format --check bt_api/${{ matrix.module }}
submodule-diagnostic:
name: Submodule Diagnostic / All Profiles
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 1
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Validate core-reference pilot
id: core
continue-on-error: true
run: |
python scripts/ci/submodule_validation.py \
--profile core-reference \
--artifacts-dir submodule-artifacts/core-reference
- name: Run all-profile diagnostic evidence
if: always()
run: |
python scripts/ci/submodule_validation.py \
--profile all \
--diagnostic \
--artifacts-dir submodule-artifacts/all
- name: Upload diagnostic artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: submodule-validation-diagnostic-${{ github.run_id }}
# Retain reports and logs while excluding transient venvs and wheels.
path: |
submodule-artifacts/**/submodule-validation.json
submodule-artifacts/**/submodule-validation.junit.xml
submodule-artifacts/**/submodule-validation.md
submodule-artifacts/**/logs/**
if-no-files-found: error
retention-days: 30
- name: Fail scheduled pilot when core reference fails
if: steps.core.outcome != 'success'
run: exit 1