Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JavaToolInstallerV0 ] Changed logic of extraction, fix inactivated Clean Destination Directory issue #13209

Merged
merged 1 commit into from
Jul 10, 2020

Conversation

AlexandrKravchuk
Copy link
Contributor

@AlexandrKravchuk AlexandrKravchuk commented Jun 30, 2020

Task name: JavaToolInstaller

Description:

  1. Naming of extraction directory (each archive extracts into a directory named as 'JAVA_HOME_<archive_name>_<archive_extension>'
  2. No extraction if it's in cache
  3. Refactoring logic, dividing code into methods

Documentation changes required: (Y/N) Yes, #88

Added unit tests: (Y/N) No, will be done in #81

Attached related issue: (Y/N) https://github.com/microsoft/build-task-team/issues/10

Checklist:

  • Task version was bumped - please check instruction how to do it
  • Checked that applied changes work as expected

Test Build Result: Build

@AlexandrKravchuk AlexandrKravchuk added bug p1 Priority 1 (should have immediate attention) labels Jun 30, 2020
@AlexandrKravchuk AlexandrKravchuk self-assigned this Jun 30, 2020
@AlexandrKravchuk AlexandrKravchuk force-pushed the users/v-alekr/build-task-team#10-patch6020 branch 2 times, most recently from 162047e to 790e3f6 Compare June 30, 2020 13:41
@AlexandrKravchuk AlexandrKravchuk force-pushed the users/v-alekr/build-task-team#10-patch6020 branch from 790e3f6 to 70f6813 Compare July 2, 2020 14:58
@AlexandrKravchuk AlexandrKravchuk changed the title fix DTS 1674974; build-task-team#10 [JavaToolInstallerV0 ] fix DTS 1674974; changed logic of extraction, fix inactivated Clean Destination Directory issue Jul 2, 2020
Copy link
Contributor

@alexander-smolyakov alexander-smolyakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look at the comments, other changes are LGTM, thanks!

sevenZip.arg(file);
const execResult = sevenZip.execSync();
if (execResult.code != taskLib.TaskResult.Succeeded) {
taskLib.debug('execResult: ' + JSON.stringify(execResult));
}
}

public static getFileEnding(file: string): string {
let fileEnding = '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess a better way is to extract the file extension firstly and then check if it supported.

Also maybe better move array with the supported file extension as global constant?

const fileEnding = file.substring(file.lastIndexOf('.'));

const supportedFileExtension: Array<string> = ['.tar', '.tar.gz', '.zip', '.7z'];

if (!supportedFileEndings.some((extension) => extension === fileEnding)) {
    throw new Error(taskLib.loc('UnsupportedFileExtension'));
}

return fileEnding;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexander-smolyakov the problem we saw here is that there's a validation for file ending - it differs from file extension... For example, for filename.tar.gz is considered to have file ending '.tar.gz', but '.gz' as extension. There's also could be the case when there's a dot in filename (like 'file.name.tar.gz'), so we can't simply extract substring after first dot...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anatolybolshakov Oh, I see now. I think it will be useful to add information about these cases in the function description.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That function was just moved here from javatoolinstaller.ts to avoid the circular dependency

Copy link
Contributor

@anatolybolshakov anatolybolshakov Jul 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think it also makes sense to describe difference between file ending/file extension here - I asked @ekaterina-tatanova to update comments since she reworked this method also and added some js doc for it in another on-code-review PR - #13203 (comment)

@@ -179,4 +181,4 @@
"UsePreinstalledJava": "ms-resource:loc.messages.UsePreinstalledJava",
"WrongArchiveStructure": "ms-resource:loc.messages.WrongArchiveStructure"
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Add EOL

@anatolybolshakov anatolybolshakov changed the title [JavaToolInstallerV0 ] fix DTS 1674974; changed logic of extraction, fix inactivated Clean Destination Directory issue [JavaToolInstallerV0 ] Changed logic of extraction, fix inactivated Clean Destination Directory issue Jul 3, 2020
Copy link
Contributor

@anatolybolshakov anatolybolshakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@AlexandrKravchuk AlexandrKravchuk force-pushed the users/v-alekr/build-task-team#10-patch6020 branch 5 times, most recently from 0754de3 to 60fce3a Compare July 6, 2020 15:18
@AlexandrKravchuk
Copy link
Contributor Author

AlexandrKravchuk commented Jul 6, 2020

After Testing by Canary Sceneries from Canary Build repo, I found some issues with Azure Blob JDK Installation.
These issues were fixed and tested again: here's the results:

  1. Build for Azure Blob
  2. Build for local storage

@@ -62,6 +63,8 @@ export class JavaFilesExtractor {
const sevenZip = taskLib.tool(this.getSevenZipLocation());
sevenZip.arg('x');
sevenZip.arg('-o' + destinationFolder);
// skip if exists
sevenZip.arg('-aos');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this change of behavior break existing customers? Do we need to hide it behind an input flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. In order to keep the task working for existing customers, it's better to get rid of this line at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean if someone wants to use archives from cache they can just inactivate Clean Directory checkbox.

@AlexandrKravchuk AlexandrKravchuk force-pushed the users/v-alekr/build-task-team#10-patch6020 branch from 60fce3a to a1d811a Compare July 10, 2020 15:57
@AlexandrKravchuk AlexandrKravchuk force-pushed the users/v-alekr/build-task-team#10-patch6020 branch from a1d811a to b1b10c8 Compare July 10, 2020 16:02
@AlexandrKravchuk AlexandrKravchuk merged commit 6ca9a89 into master Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug p1 Priority 1 (should have immediate attention)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants