mirror of
https://github.com/actions/upload-artifact.git
synced 2026-02-26 05:32:32 +00:00
Support direct file uploads (#764)
* Cache licenses * Bump minimatch to 10.1.1 * Try fixing licenced issues * More licensed fixes * Support direct file uploads * Add CI tests for direct uploads * Use download-artifact@main temporarily * CI: clean up artifacts on successful runs * Use script v8 * Fix some issues with the cleanup * Add unit tests * Clarify naming
This commit is contained in:
@ -72,6 +72,7 @@ const mockInputs = (
|
||||
[Inputs.RetentionDays]: 0,
|
||||
[Inputs.CompressionLevel]: 6,
|
||||
[Inputs.Overwrite]: false,
|
||||
[Inputs.Archive]: true,
|
||||
...overrides
|
||||
}
|
||||
|
||||
@ -273,4 +274,57 @@ describe('upload', () => {
|
||||
`Skipping deletion of '${fixtures.artifactName}', it does not exist`
|
||||
)
|
||||
})
|
||||
|
||||
test('passes skipArchive when archive is false', async () => {
|
||||
mockInputs({
|
||||
[Inputs.Archive]: false
|
||||
})
|
||||
|
||||
mockFindFilesToUpload.mockResolvedValue({
|
||||
filesToUpload: [fixtures.filesToUpload[0]],
|
||||
rootDirectory: fixtures.rootDirectory
|
||||
})
|
||||
|
||||
await run()
|
||||
|
||||
expect(artifact.default.uploadArtifact).toHaveBeenCalledWith(
|
||||
fixtures.artifactName,
|
||||
[fixtures.filesToUpload[0]],
|
||||
fixtures.rootDirectory,
|
||||
{compressionLevel: 6, skipArchive: true}
|
||||
)
|
||||
})
|
||||
|
||||
test('does not pass skipArchive when archive is true', async () => {
|
||||
mockInputs({
|
||||
[Inputs.Archive]: true
|
||||
})
|
||||
|
||||
mockFindFilesToUpload.mockResolvedValue({
|
||||
filesToUpload: [fixtures.filesToUpload[0]],
|
||||
rootDirectory: fixtures.rootDirectory
|
||||
})
|
||||
|
||||
await run()
|
||||
|
||||
expect(artifact.default.uploadArtifact).toHaveBeenCalledWith(
|
||||
fixtures.artifactName,
|
||||
[fixtures.filesToUpload[0]],
|
||||
fixtures.rootDirectory,
|
||||
{compressionLevel: 6}
|
||||
)
|
||||
})
|
||||
|
||||
test('fails when archive is false and multiple files are provided', async () => {
|
||||
mockInputs({
|
||||
[Inputs.Archive]: false
|
||||
})
|
||||
|
||||
await run()
|
||||
|
||||
expect(core.setFailed).toHaveBeenCalledWith(
|
||||
`When 'archive' is set to false, only a single file can be uploaded. Found ${fixtures.filesToUpload.length} files to upload.`
|
||||
)
|
||||
expect(artifact.default.uploadArtifact).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user