fix(cache): make tar scratch cleanup best-effort
Log scratch-directory cleanup failures without replacing a successful archive read or the original tool error. Keep scratch ownership in execReadCommands and cover both outcomes for extraction and listing.
This commit is contained in:
1 parent
cd705bb67f
commit
3607dcfa49
2 files changed
+34
-1
No files matched your search
@@ -1,4 +1,6 @@
|
||||
import * as core from '@actions/core'
|
||||
import * as exec from '@actions/exec'
|
||||
import * as io from '@actions/io'
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import * as tar from '../src/internal/tar'
|
||||
@@ -178,6 +180,32 @@ describeWindows.each([
|
||||
expectCleanScratch()
|
||||
})
|
||||
|
||||
test.each<[Operation, boolean]>([
|
||||
['extract', false],
|
||||
['extract', true],
|
||||
['list', false],
|
||||
['list', true]
|
||||
])(
|
||||
'preserves the %s result when cleanup fails (command fails=%s)',
|
||||
async (operation, commandFails) => {
|
||||
const debugMock = jest.spyOn(core, 'debug').mockImplementation(() => {})
|
||||
jest
|
||||
.spyOn(io, 'rmRF')
|
||||
.mockRejectedValue(new Error('simulated cleanup failure'))
|
||||
failStage = commandFails ? 'tar' : undefined
|
||||
|
||||
const result = readers[operation](archives[0], compression)
|
||||
if (commandFails) {
|
||||
await expect(result).rejects.toThrow('simulated tar failure')
|
||||
} else {
|
||||
await expect(result).resolves.toBeUndefined()
|
||||
}
|
||||
expect(debugMock).toHaveBeenCalledWith(
|
||||
expect.stringContaining('simulated cleanup failure')
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
test.each<[Operation, 'decompress' | 'tar']>([
|
||||
['extract', 'decompress'],
|
||||
['extract', 'tar'],
|
||||
|
||||
Reference in new issue
Block a user