fix(ci): avoid root-owned npm cache workspace files (#8669)

This commit is contained in:
易良 2026-08-07 15:08:34 +08:00 committed by GitHub
parent 6897ef7440
commit 5fdcdb28e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 7 deletions

View file

@ -755,8 +755,8 @@ describe('qwen-triage: npm cache producer workflow', () => {
it('runs on the same target as the consumers so the cache version matches', () => {
// actions/cache scopes an entry by a hash of the literal cache path plus
// the compression method. A producer on a different runner or outside the
// container computes a different version, so every restore misses even
// when the key and path strings match — pin runs-on + container to the
// container image computes a different version, so every restore misses
// even when the key and path strings match — pin runs-on + image to the
// consumers' so both match by construction.
for (const [jobName, jobDef] of [
['verify', verifyJob],
@ -767,11 +767,16 @@ describe('qwen-triage: npm cache producer workflow', () => {
jobDef['runs-on'],
`producer runs-on must match ${jobName}`,
);
assert.deepEqual(
saveJob.container,
jobDef.container,
`producer container must match ${jobName}`,
assert.equal(
saveJob.container.image,
jobDef.container.image,
`producer container image must match ${jobName}`,
);
}
assert.equal(
saveJob.container.options,
'--init --user node',
'producer must not leave root-owned files on the self-hosted runner',
);
});
});

View file

@ -30,7 +30,8 @@ jobs:
runs-on: ['self-hosted', 'linux', 'x64', 'ecs-qwen']
container:
image: 'node:22-bookworm'
options: '--init'
# Match the host runner UID/GID so bind-mounted files stay writable.
options: '--init --user node'
timeout-minutes: 15
steps:
- uses: 'actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10' # v6.0.3

View file

@ -5370,6 +5370,7 @@ describe('qwen-triage npm cache producer', () => {
"runs-on: ['self-hosted', 'linux', 'x64', 'ecs-qwen']",
);
expect(cacheProducerWorkflow).toContain("image: 'node:22-bookworm'");
expect(cacheProducerWorkflow).toContain("options: '--init --user node'");
for (const jobName of ['verify', 'tmux-testing']) {
expect(job(jobName)).toContain(
"runs-on: ['self-hosted', 'linux', 'x64', 'ecs-qwen']",