Skip to content

Commit a9e0115

Browse files
committed
fix(ci): route OpenWork checks to hosted runners
1 parent 66c6e71 commit a9e0115

2 files changed

Lines changed: 41 additions & 37 deletions

File tree

.github/scripts/ci-runner-routing.test.mjs

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Runner-routing regression guards for ci.yml and serve-ab.yml.
1+
// Runner-routing regression guards for ci.yml.
22
//
33
// classify_pr carries the routing logic TWICE — the `runs-on` expression
44
// (which selects the classify job's own runner) and the `pick_runner` shell
@@ -21,10 +21,6 @@ const workflowsDir = join(
2121
'workflows',
2222
);
2323
const ciDoc = parse(readFileSync(join(workflowsDir, 'ci.yml'), 'utf8'));
24-
const serveAbDoc = parse(
25-
readFileSync(join(workflowsDir, 'serve-ab.yml'), 'utf8'),
26-
);
27-
2824
const TRUSTED = ['OWNER', 'MEMBER', 'COLLABORATOR'];
2925
const ECS = '["self-hosted", "linux", "x64", "ecs-qwen"]';
3026
const HOSTED = '["ubuntu-latest"]';
@@ -38,16 +34,28 @@ const pickRunner = ciDoc.jobs.classify_pr.steps.find(
3834
// routing-relevant inputs: contains(list, '') is false, a missing
3935
// pull_request (merge_group / dispatch) yields '' for both head.repo and
4036
// author_association.
41-
function simulateRunsOn({ ecsDisabled, sameRepo, assoc, mergeGroup }) {
37+
function simulateRunsOn({
38+
ecsDisabled,
39+
sameRepo,
40+
assoc,
41+
mergeGroup,
42+
qwenRepo = true,
43+
}) {
4244
const trusted = TRUSTED.includes(assoc);
43-
const ecs =
44-
!ecsDisabled && (sameRepo || trusted || mergeGroup);
45+
const ecs = qwenRepo && !ecsDisabled && (sameRepo || trusted || mergeGroup);
4546
return ecs ? ECS : HOSTED;
4647
}
4748

4849
// Executes the real pick_runner shell with the same inputs and returns the
4950
// selected runner exactly as CI would publish it.
50-
function runPickRunner({ ecsDisabled, sameRepo, assoc, eventName, dispatch }) {
51+
function runPickRunner({
52+
ecsDisabled,
53+
sameRepo,
54+
assoc,
55+
eventName,
56+
dispatch,
57+
qwenRepo = true,
58+
}) {
5159
const tmp = mkdtempSync(join(tmpdir(), 'pick-runner-'));
5260
const outputFile = join(tmp, 'github_output');
5361
const result = spawnSync('bash', ['-c', pickRunner.run], {
@@ -57,6 +65,9 @@ function runPickRunner({ ecsDisabled, sameRepo, assoc, eventName, dispatch }) {
5765
ECS_DISABLED: ecsDisabled ? 'true' : '',
5866
EVENT_NAME: eventName,
5967
DISPATCH_LINUX_RUNNER: dispatch ?? '',
68+
GITHUB_REPOSITORY: qwenRepo
69+
? 'QwenLM/qwen-code'
70+
: 'modelstudioai/openwork',
6071
GITHUB_OUTPUT: outputFile,
6172
},
6273
encoding: 'utf8',
@@ -162,38 +173,31 @@ describe('ci.yml classify_pr runner routing', () => {
162173
);
163174
});
164175

176+
it('uses hosted runners outside the QwenLM repository', () => {
177+
assert.equal(
178+
runPickRunner({
179+
ecsDisabled: false,
180+
sameRepo: true,
181+
assoc: 'OWNER',
182+
eventName: 'pull_request',
183+
qwenRepo: false,
184+
}),
185+
HOSTED,
186+
);
187+
});
188+
165189
it('the runs-on expression keeps the trusted clause and kill-switch', () => {
166190
// Structural pins for the expression half of the drift guard — the
167191
// simulation above re-implements it, so pin the real text too.
168192
assert.match(
169193
classifyRunsOn,
170194
/contains\(fromJSON\('\["OWNER","MEMBER","COLLABORATOR"\]'\), github\.event\.pull_request\.author_association\)/,
171195
);
172-
assert.match(classifyRunsOn, /vars\.MAINTAINER_ECS_RUNNER_DISABLED != 'true'/);
173-
assert.match(classifyRunsOn, /github\.event_name == 'merge_group'/);
174-
});
175-
});
176-
177-
describe('serve-ab.yml runner routing', () => {
178-
const runsOn = String(serveAbDoc.jobs.ab['runs-on']);
179-
180-
it('admits same-repo and write-access fork PRs, guarded by the kill-switch', () => {
181-
assert.match(runsOn, /head\.repo\.full_name == github\.repository/);
182196
assert.match(
183-
runsOn,
184-
/contains\(fromJSON\('\["OWNER","MEMBER","COLLABORATOR"\]'\), github\.event\.pull_request\.author_association\)/,
185-
);
186-
assert.match(runsOn, /vars\.MAINTAINER_ECS_RUNNER_DISABLED != 'true'/);
187-
assert.match(runsOn, /ecs-qwen/);
188-
assert.match(runsOn, /ubuntu-latest/);
189-
});
190-
191-
it('wipes the reused workspace before checking out PR code', () => {
192-
const wipe = serveAbDoc.jobs.ab.steps.find(
193-
(s) => s.name === 'Wipe stale workspace before checkout',
197+
classifyRunsOn,
198+
/vars\.MAINTAINER_ECS_RUNNER_DISABLED != 'true'/,
194199
);
195-
assert.ok(wipe, 'self-hosted reuse must not bleed one PR into the next');
196-
assert.equal(wipe.if, "${{ runner.environment == 'self-hosted' }}");
197-
assert.match(wipe.run, /find "\$GITHUB_WORKSPACE" -mindepth 1 -maxdepth 1 -exec rm -rf/);
200+
assert.match(classifyRunsOn, /github\.repository == 'QwenLM\/qwen-code'/);
201+
assert.match(classifyRunsOn, /github\.event_name == 'merge_group'/);
198202
});
199203
});

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ jobs:
6262
# else a busy hosted pool delays it and blocks the ECS-bound jobs. The
6363
# kill-switch is read here, so flipping it reverts everything to hosted.
6464
# This runs-on and the pick_runner step below are the canonical home of
65-
# the association routing; sdk-java.yml and serve-ab.yml mirror it.
66-
runs-on: '${{ (vars.MAINTAINER_ECS_RUNNER_DISABLED != ''true'' && (github.event.pull_request.head.repo.full_name == github.repository || contains(fromJSON(''["OWNER","MEMBER","COLLABORATOR"]''), github.event.pull_request.author_association) || github.event_name == ''merge_group'')) && fromJSON(''["self-hosted", "linux", "x64", "ecs-qwen"]'') || fromJSON(''["ubuntu-latest"]'') }}'
65+
# the association routing; sdk-java.yml mirrors it.
66+
runs-on: '${{ (github.repository == ''QwenLM/qwen-code'' && vars.MAINTAINER_ECS_RUNNER_DISABLED != ''true'' && (github.event.pull_request.head.repo.full_name == github.repository || contains(fromJSON(''["OWNER","MEMBER","COLLABORATOR"]''), github.event.pull_request.author_association) || github.event_name == ''merge_group'')) && fromJSON(''["self-hosted", "linux", "x64", "ecs-qwen"]'') || fromJSON(''["ubuntu-latest"]'') }}'
6767
continue-on-error: true
6868
outputs:
6969
skip_ci: '${{ steps.release_sync.outputs.skip_ci }}'
@@ -124,10 +124,10 @@ jobs:
124124
OWNER|MEMBER|COLLABORATOR) trusted_author=true ;;
125125
esac
126126
if [[ "${EVENT_NAME}" == "workflow_dispatch" ]]; then
127-
if [[ "${ECS_DISABLED}" != "true" && "${DISPATCH_LINUX_RUNNER}" == "self-hosted" ]]; then
127+
if [[ "${GITHUB_REPOSITORY}" == "QwenLM/qwen-code" && "${ECS_DISABLED}" != "true" && "${DISPATCH_LINUX_RUNNER}" == "self-hosted" ]]; then
128128
ubuntu_runner='["self-hosted", "linux", "x64", "ecs-qwen"]'
129129
fi
130-
elif [[ "${ECS_DISABLED}" != "true" && ( "${SAME_REPO}" == "true" || "${trusted_author}" == "true" || "${EVENT_NAME}" == "merge_group" ) ]]; then
130+
elif [[ "${GITHUB_REPOSITORY}" == "QwenLM/qwen-code" && "${ECS_DISABLED}" != "true" && ( "${SAME_REPO}" == "true" || "${trusted_author}" == "true" || "${EVENT_NAME}" == "merge_group" ) ]]; then
131131
ubuntu_runner='["self-hosted", "linux", "x64", "ecs-qwen"]'
132132
fi
133133
echo "ubuntu_runner=${ubuntu_runner}" >> "${GITHUB_OUTPUT}"

0 commit comments

Comments
 (0)