Skip to content

Commit bc4d78c

Browse files
authored
feat: support test tool binary version (#13093)
* feat: install action support binary test tool * fix: use npm as default option * fix: add ut * feat(template): make test tool default option in python template * fix: schema change
1 parent 2673a27 commit bc4d78c

File tree

7 files changed

+84
-42
lines changed

7 files changed

+84
-42
lines changed

packages/fx-core/resource/yaml-schema/yaml.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,10 @@
12771277
"symlinkDir": {
12781278
"type": "string",
12791279
"description": "The path of the symlink target for the folder containing Azure Functions Core Tools binaries."
1280+
},
1281+
"releaseType": {
1282+
"type": "string",
1283+
"description": "The release type of Teams App Test Tool: binary or npm. Default to 'npm'."
12801284
}
12811285
}
12821286
},

packages/fx-core/src/component/driver/devTool/installDriver.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,29 @@
44
/**
55
* @author Xiaofu Huang <xiaofhua@microsoft.com>
66
*/
7+
import { hooks } from "@feathersjs/hooks/lib";
8+
import { FxError, Result } from "@microsoft/teamsfx-api";
79
import * as path from "path";
810
import semver from "semver";
911
import { Service } from "typedi";
10-
import { FxError, Result } from "@microsoft/teamsfx-api";
12+
import { ErrorContextMW } from "../../../common/globalVars";
13+
import { getLocalizedString } from "../../../common/localizeUtils";
14+
import { InvalidActionInputError } from "../../../error/common";
1115
import {
1216
DependencyStatus,
1317
EmptyLogger,
1418
EmptyTelemetry,
1519
TestToolReleaseType,
1620
v3DefaultHelpLink,
1721
} from "../../deps-checker";
22+
import { DotnetChecker } from "../../deps-checker/internal/dotnetChecker";
23+
import { FuncToolChecker } from "../../deps-checker/internal/funcToolChecker";
24+
import { TestToolChecker } from "../../deps-checker/internal/testToolChecker";
1825
import { LocalCertificate, LocalCertificateManager } from "../../local/localCertificateManager";
1926
import { wrapRun } from "../../utils/common";
2027
import { DriverContext } from "../interface/commonArgs";
2128
import { ExecutionResult, StepDriver } from "../interface/stepDriver";
29+
import { addStartAndEndTelemetry } from "../middleware/addStartAndEndTelemetry";
2230
import { WrapDriverContext } from "../util/wrapUtil";
2331
import {
2432
Summaries,
@@ -29,16 +37,8 @@ import {
2937
} from "./constant";
3038
import { DotnetInstallationUserError } from "./error/dotnetInstallationUserError";
3139
import { FuncInstallationUserError } from "./error/funcInstallationUserError";
32-
import { InstallToolArgs } from "./interfaces/InstallToolArgs";
33-
import { InvalidActionInputError } from "../../../error/common";
34-
import { addStartAndEndTelemetry } from "../middleware/addStartAndEndTelemetry";
35-
import { hooks } from "@feathersjs/hooks/lib";
36-
import { getLocalizedString } from "../../../common/localizeUtils";
37-
import { FuncToolChecker } from "../../deps-checker/internal/funcToolChecker";
38-
import { DotnetChecker } from "../../deps-checker/internal/dotnetChecker";
39-
import { ErrorContextMW } from "../../../common/globalVars";
40-
import { TestToolChecker } from "../../deps-checker/internal/testToolChecker";
4140
import { TestToolInstallationUserError } from "./error/testToolInstallationUserError";
41+
import { InstallToolArgs } from "./interfaces/InstallToolArgs";
4242

4343
const ACTION_NAME = "devTool/install";
4444
const helpLink = "https://aka.ms/teamsfx-actions/devtool-install";
@@ -127,8 +127,9 @@ export class ToolsInstallDriverImpl {
127127

128128
if (args.testTool) {
129129
await this.resolveTestTool(
130-
// Hardcode to npm release type if running from YAML
131-
TestToolReleaseType.Npm,
130+
args.testTool.releaseType == TestToolReleaseType.Binary
131+
? TestToolReleaseType.Binary
132+
: TestToolReleaseType.Npm,
132133
`${args.testTool.version}`,
133134
args.testTool.symlinkDir
134135
);
@@ -329,6 +330,13 @@ export class ToolsInstallDriverImpl {
329330
if (typeof args.testTool.symlinkDir !== "string") {
330331
throw new InvalidActionInputError(ACTION_NAME, ["testTool.symlinkDir"], helpLink);
331332
}
333+
if (
334+
args.testTool.releaseType &&
335+
args.testTool.releaseType !== TestToolReleaseType.Binary &&
336+
args.testTool.releaseType !== TestToolReleaseType.Npm
337+
) {
338+
throw new InvalidActionInputError(ACTION_NAME, ["testTool.releaseType"], helpLink);
339+
}
332340
}
333341
}
334342

packages/fx-core/src/component/driver/devTool/interfaces/InstallToolArgs.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ interface FuncArgs {
3535
interface TestToolArgs {
3636
version: string | number;
3737
symlinkDir: string;
38+
releaseType?: string;
3839
}

packages/fx-core/tests/component/driver/devTool/installDriver.test.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { UserError } from "@microsoft/teamsfx-api";
55
import chai from "chai";
66
import "mocha";
77
import * as sinon from "sinon";
8-
import { DepsType } from "../../../../src/component/deps-checker/depsChecker";
8+
import { DepsType, TestToolReleaseType } from "../../../../src/component/deps-checker/depsChecker";
99
import { DotnetChecker } from "../../../../src/component/deps-checker/internal/dotnetChecker";
1010
import { FuncToolChecker } from "../../../../src/component/deps-checker/internal/funcToolChecker";
1111
import { TestToolChecker } from "../../../../src/component/deps-checker/internal/testToolChecker";
@@ -319,7 +319,7 @@ describe("Tools Install Driver test", () => {
319319
});
320320

321321
it("Install test tool", async () => {
322-
sandbox.stub(TestToolChecker.prototype, "resolve").resolves({
322+
const resolveStub = sandbox.stub(TestToolChecker.prototype, "resolve").resolves({
323323
name: "Teams App Test Tool",
324324
type: DepsType.TestTool,
325325
isInstalled: true,
@@ -339,6 +339,14 @@ describe("Tools Install Driver test", () => {
339339
if (res.isOk()) {
340340
chai.assert.isEmpty(res.value);
341341
}
342+
chai.assert.isTrue(
343+
resolveStub.calledWith({
344+
versionRange: "~0.1.0",
345+
symlinkDir: "./devTools/testTool",
346+
releaseType: TestToolReleaseType.Npm,
347+
projectPath: mockedDriverContext.projectPath,
348+
})
349+
);
342350
});
343351

344352
// it("Install test tool failed without error", async () => {
@@ -398,6 +406,13 @@ describe("Tools Install Driver test", () => {
398406
args: { testTool: { version: "~1", symlinkDir: 1 } },
399407
expected: false,
400408
},
409+
{
410+
name: "invalid releaseType",
411+
args: {
412+
testTool: { version: "~1", symlinkDir: "./devTools/testTool", releaseType: "bin" },
413+
},
414+
expected: false,
415+
},
401416
];
402417
for (const c of cases) {
403418
it("Install test tool args check " + c.name, async () => {

templates/python/custom-copilot-basic/.vscode/launch.json.tpl

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"request": "launch",
88
"url": "https://teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&${account-hint}",
99
"presentation": {
10-
"group": "1-Teams",
10+
"group": "2-Teams",
1111
"order": 4
1212
},
1313
"internalConsoleOptions": "neverOpen"
@@ -18,7 +18,7 @@
1818
"request": "launch",
1919
"url": "https://teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&${account-hint}",
2020
"presentation": {
21-
"group": "1-Teams",
21+
"group": "2-Teams",
2222
"order": 5
2323
},
2424
"internalConsoleOptions": "neverOpen"
@@ -29,7 +29,7 @@
2929
"request": "launch",
3030
"preLaunchTask": "Start Teams App in Desktop Client (Remote)",
3131
"presentation": {
32-
"group": "1-Teams",
32+
"group": "2-Teams",
3333
"order": 6
3434
},
3535
"internalConsoleOptions": "neverOpen"
@@ -63,18 +63,6 @@
6363
"program": "${workspaceFolder}/src/app.py",
6464
"cwd": "${workspaceFolder}/src",
6565
"console": "integratedTerminal"
66-
},
67-
{
68-
"name": "Start Test Tool",
69-
"type": "node",
70-
"request": "launch",
71-
"program": "${workspaceFolder}/devTools/teamsapptester/node_modules/@microsoft/teams-app-test-tool/cli.js",
72-
"args": [
73-
"start"
74-
],
75-
"cwd": "${workspaceFolder}",
76-
"console": "integratedTerminal",
77-
"internalConsoleOptions": "neverOpen"
7866
{{#CEAEnabled}}
7967
},
8068
{
@@ -150,7 +138,7 @@
150138
"cascadeTerminateToConfigurations": ["Start Python"],
151139
"preLaunchTask": "Start Teams App Locally",
152140
"presentation": {
153-
"group": "1-Teams",
141+
"group": "2-Teams",
154142
"order": 1
155143
},
156144
"stopAll": true
@@ -161,7 +149,7 @@
161149
"cascadeTerminateToConfigurations": ["Start Python"],
162150
"preLaunchTask": "Start Teams App Locally",
163151
"presentation": {
164-
"group": "1-Teams",
152+
"group": "2-Teams",
165153
"order": 2
166154
},
167155
"stopAll": true
@@ -171,7 +159,7 @@
171159
"configurations": ["Start Python"],
172160
"preLaunchTask": "Start Teams App in Desktop Client",
173161
"presentation": {
174-
"group": "1-Teams",
162+
"group": "2-Teams",
175163
"order": 3
176164
},
177165
"stopAll": true
@@ -180,14 +168,10 @@
180168
"name": "Debug in Test Tool",
181169
"configurations": [
182170
"Start Python",
183-
"Start Test Tool"
184-
],
185-
"cascadeTerminateToConfigurations": [
186-
"Start Test Tool"
187171
],
188-
"preLaunchTask": "Deploy (Test Tool)",
172+
"preLaunchTask": "Test Tool",
189173
"presentation": {
190-
"group": "2-local",
174+
"group": "1-local",
191175
"order": 1
192176
},
193177
"stopAll": true

templates/python/custom-copilot-basic/.vscode/tasks.json

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
{
55
"version": "2.0.0",
66
"tasks": [
7+
{
8+
"label": "Test Tool",
9+
"dependsOn": ["Validate prerequisites (Test Tool)", "Deploy (Test Tool)", "Start Test Tool"],
10+
"dependsOrder": "sequence",
11+
"presentation": {
12+
"reveal": "never"
13+
},
14+
},
715
{
816
// Check all required prerequisites.
917
// See https://aka.ms/teamsfx-tasks/check-prerequisites to know the details and how to customize the args.
@@ -12,7 +20,6 @@
1220
"command": "debug-check-prerequisites",
1321
"args": {
1422
"prerequisites": [
15-
"nodejs", // Check if Node.js is installed and the version is >= 12.
1623
"portOccupancy" // Validate available ports to ensure those debug ones are not occupied.
1724
],
1825
"portOccupancy": [
@@ -25,15 +32,37 @@
2532
// Build project.
2633
// See https://aka.ms/teamsfx-tasks/deploy to know the details and how to customize the args.
2734
"label": "Deploy (Test Tool)",
28-
"dependsOn": [
29-
"Validate prerequisites (Test Tool)"
30-
],
3135
"type": "teamsfx",
3236
"command": "deploy",
3337
"args": {
3438
"env": "testtool",
3539
}
3640
},
41+
{
42+
"label": "Start Test Tool",
43+
"type": "shell",
44+
"command": "${workspaceFolder}/devTools/teamsapptester/teamsapptester.exe",
45+
"args": [
46+
"start"
47+
],
48+
"isBackground": true,
49+
"problemMatcher": {
50+
"owner": "custom",
51+
"pattern": {
52+
"regexp": ".*InternalServiceError: (.*)",
53+
"message": 1
54+
},
55+
"background": {
56+
"activeOnStart": true,
57+
"beginsPattern": {
58+
"regexp": ".*Teams App Test Tool"
59+
},
60+
"endsPattern": {
61+
"regexp": ".*started web socket client"
62+
}
63+
},
64+
}
65+
},
3766
{
3867
"label": "Start Teams App Locally",
3968
"dependsOn": [

templates/python/custom-copilot-basic/teamsapp.testtool.yml.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ deploy:
1010
testTool:
1111
version: ~0.2.1
1212
symlinkDir: ./devTools/teamsapptester
13+
releaseType: binary
1314

1415
# Generate runtime environment variables
1516
- uses: file/createOrUpdateEnvironmentFile

0 commit comments

Comments
 (0)