Skip to content

Commit 00db307

Browse files
rodrigo-rocaclaude
andcommitted
test(ci): verify RUNNER_TEMP-derived <root>/_diag job-name discovery
Adds a regression test for the self-hosted layout where the runner is installed directly under /home/runner, so diagnostic logs live at /home/runner/_diag (reachable only via the RUNNER_TEMP-derived <runnerRoot>/_diag candidate). Existing tests never set RUNNER_TEMP, so this path was previously unexercised. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent dc5fb2c commit 00db307

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

packages/base/src/helpers/__tests__/ci.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,24 @@ describe('getGithubJobDisplayNameFromLogs', () => {
682682
expect(mockedFs.readFileSync).toHaveBeenCalledWith(`${targetDir}/${sampleLogFileName}`, 'utf-8')
683683
})
684684

685+
test('should find the job display name at <runnerRoot>/_diag derived from RUNNER_TEMP', () => {
686+
// Self-hosted runner installed directly under /home/runner, so diagnostic logs
687+
// live at /home/runner/_diag (not under an actions-runner/ subdir). The dir is
688+
// only reachable via the RUNNER_TEMP-derived <runnerRoot>/_diag candidate.
689+
process.env.RUNNER_TEMP = '/home/runner/_work/_temp'
690+
const targetDir = '/home/runner/_diag'
691+
const logContent = sampleLogContent(sampleJobDisplayName)
692+
693+
mockReaddirSync(targetDir, sampleLogFileName)
694+
jest.spyOn(fs, 'readFileSync').mockReturnValue(logContent)
695+
696+
const jobName = getGithubJobNameFromLogs(createMockContext() as BaseContext)
697+
698+
expect(jobName).toBe(sampleJobDisplayName)
699+
expect(mockedFs.readdirSync).toHaveBeenCalledWith(targetDir, {withFileTypes: true})
700+
expect(mockedFs.readFileSync).toHaveBeenCalledWith(`${targetDir}/${sampleLogFileName}`, 'utf-8')
701+
})
702+
685703
test('should find and return the job display name windows (SaaS)', () => {
686704
process.env.RUNNER_OS = 'Windows'
687705
const targetDir = HOSTED_SAAS_DIAG_DIR_WIN

0 commit comments

Comments
 (0)