-
Notifications
You must be signed in to change notification settings - Fork 0
332 lines (293 loc) · 13.5 KB
/
nightly.yml
File metadata and controls
332 lines (293 loc) · 13.5 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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# SPDX-License-Identifier: AGPL-3.0-or-later
name: Nightly Tests
# Nightly workflow runs expensive cross-Python and integration tests.
# Results are recorded as commit statuses so release.yml can skip them
# when the release SHA was already covered by nightly.
on:
schedule:
- cron: '30 5 * * *' # 5:30 AM UTC daily
workflow_dispatch:
concurrency:
group: nightly-singleton
cancel-in-progress: false
jobs:
# ─────────────────────────────────────────────────────────────
# Test matrix (Python versions on Linux)
# Uses container images to guarantee Python availability —
# setup-python@v5 can't find pre-built binaries for Debian 12
# (the versions manifest only ships Ubuntu builds).
# ─────────────────────────────────────────────────────────────
test-matrix:
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
fail-fast: false
runs-on: self-hosted
container: python:${{ matrix.python-version }}-bookworm
timeout-minutes: 15
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: "1"
steps:
# Forgejo runner needs Node.js in the container to execute
# JS-based actions. python:*-bookworm images don't ship it.
- name: Install Node.js for JS-based actions
run: apt-get update && apt-get install -y nodejs
- uses: actions/checkout@v4
- name: Install dependencies
run: |
pip install --upgrade pip
if [ -d "packages/hypergumbo-core" ]; then
pip install -e packages/hypergumbo-core \
-e packages/hypergumbo-lang-mainstream \
-e packages/hypergumbo-lang-common \
-e packages/hypergumbo-lang-extended1 \
-e packages/hypergumbo-lang-rust-analyzer \
-e "packages/hypergumbo-tracker[dev,tui]" \
-e packages/hypergumbo \
jsonschema
else
pip install -e .[dev]
fi
- name: Build source-only grammars
run: ./scripts/build-source-grammars
- name: Check for sentence-transformers
run: |
if python -c "import sentence_transformers" 2>/dev/null; then
echo "sentence-transformers available"
echo "EMBEDDINGS_AVAILABLE=true" >> "$GITHUB_ENV"
else
echo "sentence-transformers not installed, embedding tests will be skipped"
echo "EMBEDDINGS_AVAILABLE=false" >> "$GITHUB_ENV"
fi
- name: Run tests with coverage
run: |
if [ -d "packages/hypergumbo-core" ]; then
COV_PATHS="--cov=packages/hypergumbo-core/src --cov=packages/hypergumbo-lang-mainstream/src --cov=packages/hypergumbo-lang-common/src --cov=packages/hypergumbo-lang-extended1/src --cov=packages/hypergumbo-lang-rust-analyzer/src --cov=packages/hypergumbo-tracker/src"
TEST_PATHS="packages/*/tests/"
else
COV_PATHS="--cov=src"
TEST_PATHS=""
fi
# Detect available CPUs from cgroup limits
if [ -f /sys/fs/cgroup/cpu.max ]; then
read quota period < /sys/fs/cgroup/cpu.max
if [ "$quota" != "max" ]; then
WORKERS=$((quota / period))
else
WORKERS=$(nproc)
fi
else
WORKERS=$(nproc)
fi
if [ "$EMBEDDINGS_AVAILABLE" = "true" ]; then
pytest -n "$WORKERS" $COV_PATHS --cov-report=term-missing --cov-fail-under=100 $TEST_PATHS
else
pytest -n "$WORKERS" $COV_PATHS --cov-report=term-missing --cov-fail-under=100 \
--cov-config=.coveragerc.no-embeddings $TEST_PATHS
fi
- name: Mark version as passed
if: success()
run: |
mkdir -p /tmp/matrix-result
echo "passed" > /tmp/matrix-result/py${{ matrix.python-version }}
- name: Upload pass marker
if: success()
uses: actions/upload-artifact@v3
with:
name: matrix-pass-py${{ matrix.python-version }}
path: /tmp/matrix-result/py${{ matrix.python-version }}
retention-days: 1
# ─────────────────────────────────────────────────────────────
# Test matrix retry (handles transient infra failures)
# Only retries Python versions where the primary job failed.
# ─────────────────────────────────────────────────────────────
test-matrix-retry:
needs: [test-matrix]
if: >-
always() &&
(needs.test-matrix.result == 'failure' || needs.test-matrix.result == 'cancelled')
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
fail-fast: false
runs-on: self-hosted
container: python:${{ matrix.python-version }}-bookworm
timeout-minutes: 15
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: "1"
steps:
# Forgejo runner needs Node.js in the container to execute JS-based
# actions like `actions/download-artifact@v3`. python:*-bookworm
# images don't ship it. This MUST precede the download-artifact
# step — if Node isn't on PATH, download-artifact fails with
# `OCI runtime exec failed ... exec: "node": executable file not
# found` under `continue-on-error: true`, the pass-marker file is
# never written, and the skip-check then incorrectly reports
# "Primary job failed ... retrying" for every Python version.
# Observed 2026-04-21 on a nightly where the primary 3.10/3.11
# passed but their retry ran anyway. The primary test-matrix job
# solves this the same way (step "Install Node.js for JS-based
# actions" at the top).
- name: Install Node.js for JS-based actions
run: apt-get update && apt-get install -y nodejs
- name: Download pass marker
id: check-primary
uses: actions/download-artifact@v3
with:
name: matrix-pass-py${{ matrix.python-version }}
path: /tmp/matrix-result
continue-on-error: true
- name: Skip if primary passed
id: skip-check
run: |
if [ -f /tmp/matrix-result/py${{ matrix.python-version }} ]; then
echo "Primary job passed for Python ${{ matrix.python-version }} — skipping retry"
echo "should_skip=true" >> "$GITHUB_OUTPUT"
else
echo "Primary job failed for Python ${{ matrix.python-version }} — retrying"
echo "should_skip=false" >> "$GITHUB_OUTPUT"
fi
- uses: actions/checkout@v4
if: steps.skip-check.outputs.should_skip != 'true'
- name: Install dependencies
if: steps.skip-check.outputs.should_skip != 'true'
run: |
pip install --upgrade pip
if [ -d "packages/hypergumbo-core" ]; then
pip install -e packages/hypergumbo-core \
-e packages/hypergumbo-lang-mainstream \
-e packages/hypergumbo-lang-common \
-e packages/hypergumbo-lang-extended1 \
-e packages/hypergumbo-lang-rust-analyzer \
-e "packages/hypergumbo-tracker[dev,tui]" \
-e packages/hypergumbo \
jsonschema
else
pip install -e .[dev]
fi
- name: Build source-only grammars
if: steps.skip-check.outputs.should_skip != 'true'
run: ./scripts/build-source-grammars
- name: Check for sentence-transformers
if: steps.skip-check.outputs.should_skip != 'true'
run: |
if python -c "import sentence_transformers" 2>/dev/null; then
echo "sentence-transformers available"
echo "EMBEDDINGS_AVAILABLE=true" >> "$GITHUB_ENV"
else
echo "sentence-transformers not installed, embedding tests will be skipped"
echo "EMBEDDINGS_AVAILABLE=false" >> "$GITHUB_ENV"
fi
- name: Run tests with coverage
if: steps.skip-check.outputs.should_skip != 'true'
run: |
if [ -d "packages/hypergumbo-core" ]; then
COV_PATHS="--cov=packages/hypergumbo-core/src --cov=packages/hypergumbo-lang-mainstream/src --cov=packages/hypergumbo-lang-common/src --cov=packages/hypergumbo-lang-extended1/src --cov=packages/hypergumbo-lang-rust-analyzer/src --cov=packages/hypergumbo-tracker/src"
TEST_PATHS="packages/*/tests/"
else
COV_PATHS="--cov=src"
TEST_PATHS=""
fi
# Detect available CPUs from cgroup limits
if [ -f /sys/fs/cgroup/cpu.max ]; then
read quota period < /sys/fs/cgroup/cpu.max
if [ "$quota" != "max" ]; then
WORKERS=$((quota / period))
else
WORKERS=$(nproc)
fi
else
WORKERS=$(nproc)
fi
if [ "$EMBEDDINGS_AVAILABLE" = "true" ]; then
pytest -n "$WORKERS" $COV_PATHS --cov-report=term-missing --cov-fail-under=100 $TEST_PATHS
else
pytest -n "$WORKERS" $COV_PATHS --cov-report=term-missing --cov-fail-under=100 \
--cov-config=.coveragerc.no-embeddings $TEST_PATHS
fi
# ─────────────────────────────────────────────────────────────
# Integration tests
# ─────────────────────────────────────────────────────────────
integration-tests:
runs-on: self-hosted
timeout-minutes: 30
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: "1"
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install --upgrade pip
if [ -d "packages/hypergumbo-core" ]; then
pip install -e packages/hypergumbo-core \
-e packages/hypergumbo-lang-mainstream \
-e packages/hypergumbo-lang-common \
-e packages/hypergumbo-lang-extended1 \
-e packages/hypergumbo-lang-rust-analyzer \
-e packages/hypergumbo
else
pip install -e .[dev]
fi
- name: Build source-only grammars
run: ./scripts/build-source-grammars
- name: Install jq
run: |
sudo apt-get update && sudo apt-get install -y jq || true
- name: Run integration tests
run: ./scripts/integration-test --quick
# ─────────────────────────────────────────────────────────────
# Report results as commit statuses
# ─────────────────────────────────────────────────────────────
report:
needs: [test-matrix, test-matrix-retry, integration-tests]
if: always()
runs-on: self-hosted
steps:
- name: Set commit statuses
env:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
run: |
SHA="${{ github.sha }}"
REPO="${{ github.repository }}"
API="https://codeberg.org/api/v1/repos/${REPO}/statuses/${SHA}"
if [ -z "$FORGEJO_TOKEN" ]; then
echo "::warning::FORGEJO_TOKEN not set, skipping commit status updates"
exit 0
fi
# test-matrix passes if primary OR retry succeeded
MATRIX_STATE="failure"
if [ "${{ needs.test-matrix.result }}" = "success" ] || \
[ "${{ needs.test-matrix-retry.result }}" = "success" ]; then
MATRIX_STATE="success"
fi
curl -s -X POST \
-H "Authorization: token $FORGEJO_TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"state\": \"${MATRIX_STATE}\",
\"context\": \"nightly/test-matrix\",
\"description\": \"Nightly Python 3.10-3.13 test matrix\",
\"target_url\": \"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\"
}" \
"$API"
echo "Set nightly/test-matrix status: $MATRIX_STATE"
# Report integration-tests status
INTEGRATION_STATE="success"
if [ "${{ needs.integration-tests.result }}" != "success" ]; then
INTEGRATION_STATE="failure"
fi
curl -s -X POST \
-H "Authorization: token $FORGEJO_TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"state\": \"${INTEGRATION_STATE}\",
\"context\": \"nightly/integration-tests\",
\"description\": \"Nightly integration tests\",
\"target_url\": \"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\"
}" \
"$API"
echo "Set nightly/integration-tests status: $INTEGRATION_STATE"