fixed substring issue with /github/workspace and /github/file_commands (#35)

* fixed substring issue with /github/workspace and /github/file_commands

* npm run format

* last 3 parts of the path are mounted to /github/workspace and /github/file_commands

* file commands now point to _temp/_runner_file_commands
This commit is contained in:
Nikola Jokic
2022-11-03 14:55:07 +01:00
committed by GitHub
parent 8986035ca8
commit 23cc6dda6f
2 changed files with 19 additions and 14 deletions

View File

@@ -22,16 +22,18 @@ export function containerVolumes(
const workspacePath = process.env.GITHUB_WORKSPACE as string const workspacePath = process.env.GITHUB_WORKSPACE as string
if (containerAction) { if (containerAction) {
const i = workspacePath.lastIndexOf('_work/')
const workspaceRelativePath = workspacePath.slice(i + '_work/'.length)
mounts.push( mounts.push(
{ {
name: POD_VOLUME_NAME, name: POD_VOLUME_NAME,
mountPath: '/github/workspace', mountPath: '/github/workspace',
subPath: workspacePath.substring(workspacePath.indexOf('work/') + 1) subPath: workspaceRelativePath
}, },
{ {
name: POD_VOLUME_NAME, name: POD_VOLUME_NAME,
mountPath: '/github/file_commands', mountPath: '/github/file_commands',
subPath: workspacePath.substring(workspacePath.indexOf('work/') + 1) subPath: '_temp/_runner_file_commands'
} }
) )
return mounts return mounts

View File

@@ -103,19 +103,22 @@ describe('k8s utils', () => {
it('should have container action volumes', () => { it('should have container action volumes', () => {
let volumes = containerVolumes([], true, true) let volumes = containerVolumes([], true, true)
expect( let workspace = volumes.find(e => e.mountPath === '/github/workspace')
volumes.find(e => e.mountPath === '/github/workspace') let fileCommands = volumes.find(
).toBeTruthy() e => e.mountPath === '/github/file_commands'
expect( )
volumes.find(e => e.mountPath === '/github/file_commands') expect(workspace).toBeTruthy()
).toBeTruthy() expect(workspace?.subPath).toBe('repo/repo')
expect(fileCommands).toBeTruthy()
expect(fileCommands?.subPath).toBe('_temp/_runner_file_commands')
volumes = containerVolumes([], false, true) volumes = containerVolumes([], false, true)
expect( workspace = volumes.find(e => e.mountPath === '/github/workspace')
volumes.find(e => e.mountPath === '/github/workspace') fileCommands = volumes.find(e => e.mountPath === '/github/file_commands')
).toBeTruthy() expect(workspace).toBeTruthy()
expect( expect(workspace?.subPath).toBe('repo/repo')
volumes.find(e => e.mountPath === '/github/file_commands') expect(fileCommands).toBeTruthy()
).toBeTruthy() expect(fileCommands?.subPath).toBe('_temp/_runner_file_commands')
}) })
it('should have externals, github home and github workflow mounts if job container', () => { it('should have externals, github home and github workflow mounts if job container', () => {