Skip to content

Commit e0eb2fd

Browse files
authored
chore(ci): Scope tests extras backend tests (#9170)
Signed-off-by: Richard Palethorpe <io@richiejp.com>
1 parent dd3376e commit e0eb2fd

2 files changed

Lines changed: 123 additions & 31 deletions

File tree

.github/workflows/test-extra.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,37 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
jobs:
17+
detect-changes:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
run-all: ${{ steps.detect.outputs.run-all }}
21+
transformers: ${{ steps.detect.outputs.transformers }}
22+
rerankers: ${{ steps.detect.outputs.rerankers }}
23+
diffusers: ${{ steps.detect.outputs.diffusers }}
24+
coqui: ${{ steps.detect.outputs.coqui }}
25+
moonshine: ${{ steps.detect.outputs.moonshine }}
26+
pocket-tts: ${{ steps.detect.outputs.pocket-tts }}
27+
qwen-tts: ${{ steps.detect.outputs.qwen-tts }}
28+
qwen-asr: ${{ steps.detect.outputs.qwen-asr }}
29+
nemo: ${{ steps.detect.outputs.nemo }}
30+
voxcpm: ${{ steps.detect.outputs.voxcpm }}
31+
llama-cpp-quantization: ${{ steps.detect.outputs.llama-cpp-quantization }}
32+
acestep-cpp: ${{ steps.detect.outputs.acestep-cpp }}
33+
voxtral: ${{ steps.detect.outputs.voxtral }}
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v6
37+
- name: Setup Bun
38+
uses: oven-sh/setup-bun@v2
39+
- name: Install dependencies
40+
run: bun add js-yaml @octokit/core
41+
- name: Detect changed backends
42+
id: detect
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
GITHUB_EVENT_PATH: ${{ github.event_path }}
46+
run: bun run scripts/changed-backends.js
47+
1748
# Requires CUDA
1849
# tests-chatterbox-tts:
1950
# runs-on: ubuntu-latest
@@ -37,6 +68,8 @@ jobs:
3768
# make --jobs=5 --output-sync=target -C backend/python/chatterbox
3869
# make --jobs=5 --output-sync=target -C backend/python/chatterbox test
3970
tests-transformers:
71+
needs: detect-changes
72+
if: needs.detect-changes.outputs.transformers == 'true' || needs.detect-changes.outputs.run-all == 'true'
4073
runs-on: ubuntu-latest
4174
steps:
4275
- name: Clone
@@ -58,6 +91,8 @@ jobs:
5891
make --jobs=5 --output-sync=target -C backend/python/transformers
5992
make --jobs=5 --output-sync=target -C backend/python/transformers test
6093
tests-rerankers:
94+
needs: detect-changes
95+
if: needs.detect-changes.outputs.rerankers == 'true' || needs.detect-changes.outputs.run-all == 'true'
6196
runs-on: ubuntu-latest
6297
steps:
6398
- name: Clone
@@ -80,6 +115,8 @@ jobs:
80115
make --jobs=5 --output-sync=target -C backend/python/rerankers test
81116
82117
tests-diffusers:
118+
needs: detect-changes
119+
if: needs.detect-changes.outputs.diffusers == 'true' || needs.detect-changes.outputs.run-all == 'true'
83120
runs-on: ubuntu-latest
84121
steps:
85122
- name: Clone
@@ -229,6 +266,8 @@ jobs:
229266
# make --jobs=5 --output-sync=target -C backend/python/vllm test
230267

231268
tests-coqui:
269+
needs: detect-changes
270+
if: needs.detect-changes.outputs.coqui == 'true' || needs.detect-changes.outputs.run-all == 'true'
232271
runs-on: ubuntu-latest
233272
steps:
234273
- name: Clone
@@ -248,6 +287,8 @@ jobs:
248287
make --jobs=5 --output-sync=target -C backend/python/coqui
249288
make --jobs=5 --output-sync=target -C backend/python/coqui test
250289
tests-moonshine:
290+
needs: detect-changes
291+
if: needs.detect-changes.outputs.moonshine == 'true' || needs.detect-changes.outputs.run-all == 'true'
251292
runs-on: ubuntu-latest
252293
steps:
253294
- name: Clone
@@ -267,6 +308,8 @@ jobs:
267308
make --jobs=5 --output-sync=target -C backend/python/moonshine
268309
make --jobs=5 --output-sync=target -C backend/python/moonshine test
269310
tests-pocket-tts:
311+
needs: detect-changes
312+
if: needs.detect-changes.outputs.pocket-tts == 'true' || needs.detect-changes.outputs.run-all == 'true'
270313
runs-on: ubuntu-latest
271314
steps:
272315
- name: Clone
@@ -286,6 +329,8 @@ jobs:
286329
make --jobs=5 --output-sync=target -C backend/python/pocket-tts
287330
make --jobs=5 --output-sync=target -C backend/python/pocket-tts test
288331
tests-qwen-tts:
332+
needs: detect-changes
333+
if: needs.detect-changes.outputs.qwen-tts == 'true' || needs.detect-changes.outputs.run-all == 'true'
289334
runs-on: ubuntu-latest
290335
steps:
291336
- name: Clone
@@ -327,6 +372,8 @@ jobs:
327372
# make --jobs=5 --output-sync=target -C backend/python/fish-speech
328373
# make --jobs=5 --output-sync=target -C backend/python/fish-speech test
329374
tests-qwen-asr:
375+
needs: detect-changes
376+
if: needs.detect-changes.outputs.qwen-asr == 'true' || needs.detect-changes.outputs.run-all == 'true'
330377
runs-on: ubuntu-latest
331378
steps:
332379
- name: Clone
@@ -346,6 +393,8 @@ jobs:
346393
make --jobs=5 --output-sync=target -C backend/python/qwen-asr
347394
make --jobs=5 --output-sync=target -C backend/python/qwen-asr test
348395
tests-nemo:
396+
needs: detect-changes
397+
if: needs.detect-changes.outputs.nemo == 'true' || needs.detect-changes.outputs.run-all == 'true'
349398
runs-on: ubuntu-latest
350399
steps:
351400
- name: Clone
@@ -365,6 +414,8 @@ jobs:
365414
make --jobs=5 --output-sync=target -C backend/python/nemo
366415
make --jobs=5 --output-sync=target -C backend/python/nemo test
367416
tests-voxcpm:
417+
needs: detect-changes
418+
if: needs.detect-changes.outputs.voxcpm == 'true' || needs.detect-changes.outputs.run-all == 'true'
368419
runs-on: ubuntu-latest
369420
steps:
370421
- name: Clone
@@ -384,6 +435,8 @@ jobs:
384435
make --jobs=5 --output-sync=target -C backend/python/voxcpm
385436
make --jobs=5 --output-sync=target -C backend/python/voxcpm test
386437
tests-llama-cpp-quantization:
438+
needs: detect-changes
439+
if: needs.detect-changes.outputs.llama-cpp-quantization == 'true' || needs.detect-changes.outputs.run-all == 'true'
387440
runs-on: ubuntu-latest
388441
timeout-minutes: 30
389442
steps:
@@ -411,6 +464,8 @@ jobs:
411464
run: |
412465
make --jobs=5 --output-sync=target -C backend/python/llama-cpp-quantization test
413466
tests-acestep-cpp:
467+
needs: detect-changes
468+
if: needs.detect-changes.outputs.acestep-cpp == 'true' || needs.detect-changes.outputs.run-all == 'true'
414469
runs-on: ubuntu-latest
415470
steps:
416471
- name: Clone
@@ -441,6 +496,8 @@ jobs:
441496
run: |
442497
make --jobs=5 --output-sync=target -C backend/go/acestep-cpp test
443498
tests-voxtral:
499+
needs: detect-changes
500+
if: needs.detect-changes.outputs.voxtral == 'true' || needs.detect-changes.outputs.run-all == 'true'
444501
runs-on: ubuntu-latest
445502
steps:
446503
- name: Clone

scripts/changed-backends.js

Lines changed: 66 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,9 @@ const backendJobsDarwin = jobs["backend-jobs-darwin"];
1010
const includes = backendJobs.strategy.matrix.include;
1111
const includesDarwin = backendJobsDarwin.strategy.matrix.include;
1212

13-
// Set up Octokit for PR changed files
14-
const token = process.env.GITHUB_TOKEN;
15-
const octokit = new Octokit({ auth: token });
16-
1713
const eventPath = process.env.GITHUB_EVENT_PATH;
1814
const event = JSON.parse(fs.readFileSync(eventPath, "utf8"));
1915

20-
let prNumber, repo, owner;
21-
if (event.pull_request) {
22-
prNumber = event.pull_request.number;
23-
repo = event.repository.name;
24-
owner = event.repository.owner.login;
25-
} else {
26-
throw new Error("This workflow must be triggered by a pull_request event.");
27-
}
28-
29-
async function getChangedFiles() {
30-
let files = [];
31-
let page = 1;
32-
while (true) {
33-
const res = await octokit.request('GET /repos/{owner}/{repo}/pulls/{pull_number}/files', {
34-
owner,
35-
repo,
36-
pull_number: prNumber,
37-
per_page: 100,
38-
page
39-
});
40-
files = files.concat(res.data.map(f => f.filename));
41-
if (res.data.length < 100) break;
42-
page++;
43-
}
44-
return files;
45-
}
46-
4716
// Infer backend path
4817
function inferBackendPath(item) {
4918
if (item.dockerfile.endsWith("python")) {
@@ -66,6 +35,65 @@ function inferBackendPathDarwin(item) {
6635
return `backend/${item.lang}/${item.backend}/`;
6736
}
6837

38+
// Build a deduplicated map of backend name -> path prefix from all matrix entries
39+
function getAllBackendPaths() {
40+
const paths = new Map();
41+
for (const item of includes) {
42+
const p = inferBackendPath(item);
43+
if (p && !paths.has(item.backend)) {
44+
paths.set(item.backend, p);
45+
}
46+
}
47+
for (const item of includesDarwin) {
48+
const p = inferBackendPathDarwin(item);
49+
if (p && !paths.has(item.backend)) {
50+
paths.set(item.backend, p);
51+
}
52+
}
53+
return paths;
54+
}
55+
56+
const allBackendPaths = getAllBackendPaths();
57+
58+
// Non-PR events: output run-all=true and all backends as true
59+
if (!event.pull_request) {
60+
fs.appendFileSync(process.env.GITHUB_OUTPUT, `run-all=true\n`);
61+
fs.appendFileSync(process.env.GITHUB_OUTPUT, `has-backends=true\n`);
62+
fs.appendFileSync(process.env.GITHUB_OUTPUT, `has-backends-darwin=true\n`);
63+
fs.appendFileSync(process.env.GITHUB_OUTPUT, `matrix=${JSON.stringify({ include: includes })}\n`);
64+
fs.appendFileSync(process.env.GITHUB_OUTPUT, `matrix-darwin=${JSON.stringify({ include: includesDarwin })}\n`);
65+
for (const backend of allBackendPaths.keys()) {
66+
fs.appendFileSync(process.env.GITHUB_OUTPUT, `${backend}=true\n`);
67+
}
68+
process.exit(0);
69+
}
70+
71+
// PR context
72+
const prNumber = event.pull_request.number;
73+
const repo = event.repository.name;
74+
const owner = event.repository.owner.login;
75+
76+
const token = process.env.GITHUB_TOKEN;
77+
const octokit = new Octokit({ auth: token });
78+
79+
async function getChangedFiles() {
80+
let files = [];
81+
let page = 1;
82+
while (true) {
83+
const res = await octokit.request('GET /repos/{owner}/{repo}/pulls/{pull_number}/files', {
84+
owner,
85+
repo,
86+
pull_number: prNumber,
87+
per_page: 100,
88+
page
89+
});
90+
files = files.concat(res.data.map(f => f.filename));
91+
if (res.data.length < 100) break;
92+
page++;
93+
}
94+
return files;
95+
}
96+
6997
(async () => {
7098
const changedFiles = await getChangedFiles();
7199

@@ -90,8 +118,15 @@ function inferBackendPathDarwin(item) {
90118
console.log("Has backends?:", hasBackends);
91119
console.log("Has Darwin backends?:", hasBackendsDarwin);
92120

121+
fs.appendFileSync(process.env.GITHUB_OUTPUT, `run-all=false\n`);
93122
fs.appendFileSync(process.env.GITHUB_OUTPUT, `has-backends=${hasBackends}\n`);
94123
fs.appendFileSync(process.env.GITHUB_OUTPUT, `has-backends-darwin=${hasBackendsDarwin}\n`);
95124
fs.appendFileSync(process.env.GITHUB_OUTPUT, `matrix=${JSON.stringify({ include: filtered })}\n`);
96125
fs.appendFileSync(process.env.GITHUB_OUTPUT, `matrix-darwin=${JSON.stringify({ include: filteredDarwin })}\n`);
126+
127+
// Per-backend boolean outputs
128+
for (const [backend, pathPrefix] of allBackendPaths) {
129+
const changed = changedFiles.some(file => file.startsWith(pathPrefix));
130+
fs.appendFileSync(process.env.GITHUB_OUTPUT, `${backend}=${changed ? 'true' : 'false'}\n`);
131+
}
97132
})();

0 commit comments

Comments
 (0)