Skip to content

Commit

Permalink
Merge pull request #11229 from OfficeDev/anchenyi/avoid_aync_validati…
Browse files Browse the repository at this point in the history
…on_conflicts

feat: avoid aync validation conflicts
  • Loading branch information
anchenyi authored Apr 1, 2024
2 parents f4324c7 + abbc72c commit b015b28
Show file tree
Hide file tree
Showing 3 changed files with 325 additions and 12 deletions.
3 changes: 2 additions & 1 deletion packages/fx-core/resource/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@
"driver.teamsApp.progressBar.publishTeamsAppStep2.2": "Publishing Teams app...",
"driver.teamsApp.progressBar.validateWithTestCases": "Submitting validation request...",
"driver.teamsApp.progressBar.validateWithTestCases.step": "Validation request submitted, status: %s. You will be notified when the result is ready or you can check all your validation records in [Teams Developer Portal](%s).",
"driver.teamsApp.progressBar.validateWithTestCases.conflict": "A validation is currently in progress, please submit later. You can find this existing validation in [Teams Developer Portal](%s).",
"driver.teamsApp.summary.createTeamsAppAlreadyExists": "Teams app with id %s already exists, skipped creating a new Teams app.",
"driver.teamsApp.summary.publishTeamsAppExists": "Teams app with id %s already exists in the organization's app store.",
"driver.teamsApp.summary.publishTeamsAppNotExists": "Teams app with id %s does not exist in the organization's app store.",
Expand All @@ -718,7 +719,7 @@
"driver.teamsApp.summary.validate.warning": "%s warning",
"driver.teamsApp.summary.validate.skipped": "%s skipped",
"driver.teamsApp.summary.validate.all": "All",
"driver.teamsApp.summary.validateWithTestCases": "Validation request completed, status: %s. \n\nSummary:\n%s. View the result from: %s%s",
"driver.teamsApp.summary.validateWithTestCases": "Validation request completed, status: %s. \n\nSummary:\n%s. View the result from: %s.%s",
"driver.teamsApp.summary.validateWithTestCases.result": "Validation request completed, status: %s. %s. Check [Output panel](command:fx-extension.showOutputChannel) for details.",
"driver.teamsApp.summary.validateWithTestCases.result.detail": "%s Validation title: %s. Message: %s",
"driver.teamsApp.validate.result": "Teams Toolkit has completed checking your app package against validation rules. %s.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,42 @@ export class ValidateWithTestCasesDriver implements StepDriver {
return err(appStudioTokenRes.error);
}
const appStudioToken = appStudioTokenRes.value;

// Check if the app has ongoing validation
const existingValidationResponse = await AppStudioClient.getAppValidationRequestList(
manifest.id,
appStudioToken
);
if (existingValidationResponse.appValidations) {
for (const validation of existingValidationResponse.appValidations) {
if (
validation.status === AsyncAppValidationStatus.InProgress ||
validation.status === AsyncAppValidationStatus.Created
) {
if (context.platform === Platform.CLI) {
const message: Array<{ content: string; color: Colors }> = [
{
content: `A validation is currently in progress, please submit later. You can find this existing validation from `,
color: Colors.BRIGHT_YELLOW,
},
{
content: `${getAppStudioEndpoint()}/apps/${manifest.id}/app-validation/${
validation.id
}`,
color: Colors.BRIGHT_CYAN,
},
];
context.ui?.showMessage("warn", message, false);
} else {
const message = getLocalizedString(
"driver.teamsApp.progressBar.validateWithTestCases.conflict",
`${getAppStudioEndpoint()}/apps/${manifest.id}/app-validation/${validation.id}`
);
context.logProvider.warning(message);
}
return ok(new Map());
}
}
}
const response: AsyncAppValidationResponse = await AppStudioClient.submitAppValidationRequest(
manifest.id,
appStudioToken
Expand Down
Loading

0 comments on commit b015b28

Please sign in to comment.