Describe the bug
Context: @actions/artifact
According to README.md, relative paths for files are supported as well as absolute path. However, when trying to use relative path I kept running into fatal error:
Error: File <file> does not exist
Also, if file is not found, the error is thrown even if I use continueOnError: true which is contrary to the docs:
If set to true and an error is encountered, the failed file will be skipped and ignored and all other queued files will be attempted to be uploaded.
I've tried try...catch but that did not work either.
I believe the error is due to how path is being checked:
|
export function getUploadZipSpecification( |
|
filesToZip: string[], |
|
rootDirectory: string |
|
): UploadZipSpecification[] { |
|
for (let file of filesToZip) { |
|
if (!fs.existsSync(file)) { |
|
throw new Error(`File ${file} does not exist`) |
|
} |
As you can see, rootDirectory is not concatenated with filesToZip.
To Reproduce
const client = artifact.create();
const filePath = path.resolve(__dirname, 'file');
this.spawnSync.call('touch', [filePath]);
fs.openSync(filePath, 'a');
this.spawnSync.call('ls', ['-l', __dirname]);
console.log(fs.existsSync(filePath));
client.uploadArtifact('file-abs-path', [filePath], __dirname, {
continueOnError: true }); // works
client.uploadArtifact('file-rel-path', ['file'], __dirname, {
continueOnError: true }); // does not work, throws error
Expected behavior
- relative path to be functional
continueOnError: true to not throw error
Describe the bug
Context: @actions/artifact
According to README.md, relative paths for files are supported as well as absolute path. However, when trying to use relative path I kept running into fatal error:
Also, if file is not found, the error is thrown even if I use
continueOnError: truewhich is contrary to the docs:I've tried
try...catchbut that did not work either.I believe the error is due to how path is being checked:
toolkit/packages/artifact/src/internal/upload/upload-zip-specification.ts
Lines 41 to 44 in c9dab8c
toolkit/packages/artifact/src/internal/upload/upload-zip-specification.ts
Lines 77 to 80 in c9dab8c
As you can see,
rootDirectoryis not concatenated withfilesToZip.To Reproduce
Expected behavior
continueOnError: trueto not throw error