Skip to content

Commit fa6f99f

Browse files
authored
test: enable e2e coverage report (#10361)
* test: update * test: update * test: update * test: update * ci: update * test: update * test: for test * ci: update * test: update * ci: enable --parallel in mocha
1 parent a0a587c commit fa6f99f

File tree

7 files changed

+1306
-9
lines changed

7 files changed

+1306
-9
lines changed

.github/workflows/e2e-test.yml

+83-1
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@ on:
1818
required: false
1919
type: string
2020

21+
get-coverage:
22+
description: "check e2e coverage for fx-core"
23+
required: false
24+
type: boolean
25+
default: false
26+
2127
schedule:
2228
- cron: "0 22 * * *"
2329

2430
pull_request_target:
2531

2632
jobs:
2733
setup:
28-
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name == 'teamsfx-bot/TeamsFx') }}
34+
if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && !github.event.inputs.get-coverage) || (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name == 'teamsfx-bot/TeamsFx') }}
2935
runs-on: ubuntu-latest
3036
outputs:
3137
cases: ${{ steps.schedule-cases.outputs.cases || steps.dispatch-cases.outputs.cases || steps.pr-cases.outputs.cases }}
@@ -451,3 +457,79 @@ jobs:
451457
MAIL_CLIENT_ID: ${{ secrets.TEST_CLEAN_CLIENT_ID }}
452458
MAIL_CLIENT_SECRET: ${{ secrets.TEST_CLEAN_CLIENT_SECRET }}
453459
MAIL_TENANT_ID: ${{ secrets.TEST_CLEAN_TENANT_ID }}
460+
461+
e2e-coverage:
462+
if: ${{github.event_name == 'workflow_dispatch' && github.event.inputs.get-coverage }}
463+
runs-on: ubuntu-latest
464+
steps:
465+
- uses: actions/checkout@v3
466+
- uses: actions/setup-node@v3
467+
with:
468+
node-version: 18
469+
- uses: pnpm/action-setup@v2
470+
with:
471+
version: 8
472+
473+
- name: mv files
474+
working-directory: packages/tests
475+
run: |
476+
rm src/e2e/commonUtils.ts src/utils/commonUtils.ts
477+
mv src/e2e/commonUtils.ts.back src/e2e/commonUtils.ts
478+
mv src/utils/commonUtils.ts.back src/utils/commonUtils.ts
479+
480+
- uses: jossef/action-set-json-field@v1
481+
with:
482+
file: ./packages/fx-core/.nycrc
483+
field: excludeAfterRemap
484+
value: false
485+
486+
- name: Update config.json
487+
working-directory: packages/fx-core
488+
run: echo "`jq '.include=["build"]' .nycrc`" > .nycrc
489+
490+
- name: less nycrc
491+
working-directory: packages/fx-core
492+
run: |
493+
less .nycrc
494+
495+
- name: setup
496+
run: |
497+
npm run setup
498+
499+
- name: run test for coverage
500+
working-directory: packages/fx-core
501+
env:
502+
AZURE_ACCOUNT_NAME: ${{ secrets.TEST_USER_NAME }}
503+
AZURE_ACCOUNT_OBJECT_ID: ${{ secrets.TEST_USER_OBJECT_ID }}
504+
AZURE_ACCOUNT_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
505+
AZURE_SUBSCRIPTION_ID: ${{ secrets.TEST_SUBSCRIPTION_ID }}
506+
AZURE_TENANT_ID: ${{ secrets.TEST_TENANT_ID }}
507+
M365_ACCOUNT_NAME: ${{ secrets.TEST_USER_NAME }}
508+
M365_ACCOUNT_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
509+
M365_TENANT_ID: ${{ secrets.TEST_TENANT_ID_2 }}
510+
CI_ENABLED: "true"
511+
M365_ACCOUNT_COLLABORATOR: ${{ secrets.TEST_COLLABORATOR_USER_NAME }}
512+
AZURE_DEVOPS_EXT_PAT: ${{ secrets.ADO_PAT }}
513+
TEAMSFX_DEBUG_TEMPLATE: "true"
514+
NODE_ENV: "development"
515+
TEAMSFX_AAD_DEPLOY_ONLY: "true"
516+
SIDELOADING_SERVICE_ENDPOINT: ${{ secrets.SIDELOADING_SERVICE_ENDPOINT }}
517+
SIDELOADING_SERVICE_SCOPE: ${{ secrets.SIDELOADING_SERVICE_SCOPE }}
518+
ADO_TOKEN: ${{ secrets.ADO_PAT }}
519+
run: |
520+
npx nyc mocha --parallel ../tests/src/e2e/**/*.tests.ts
521+
522+
- name: pack zip
523+
if: ${{always()}}
524+
working-directory: packages/fx-core
525+
run: |
526+
zip -r out1.zip .nyc_output/
527+
zip -r out2.zip coverage/
528+
529+
- uses: actions/upload-artifact@v3
530+
if: ${{ always() }}
531+
with:
532+
name: coverage
533+
path: |
534+
packages/fx-core/out1.zip
535+
packages/fx-core/out2.zip

packages/cli/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"terser-webpack-plugin": "^5.1.2",
8787
"ts-loader": "^9.2.2",
8888
"ts-node": "^9.1.1",
89+
"tslib": "^2.3.1",
8990
"typescript": "^4.3.2",
9091
"umd-compat-loader": "^2.1.2",
9192
"url-loader": "^4.1.1",

packages/fx-core/.nycrc

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"extends": "@istanbuljs/nyc-config-typescript",
33
"all": true,
44
"include": [
5-
"src/**/*.ts",
6-
"src/**/*.js"
5+
"src/"
76
],
7+
"extension": [".js",".ts"],
88
"exclude": [
99
"src/common/deps-checker/**/*",
1010
"src/question/generator.ts"

packages/tests/package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@microsoft/dev-tunnels-management": "~1.0.7445",
2121
"@microsoft/dev-tunnels-ssh": "~3.11.31",
2222
"@microsoft/extra-shot-mocha": "0.0.1",
23-
"@microsoft/teamsfx-core": "^2.0.5",
23+
"@microsoft/teamsfx-core": "workspace:*",
2424
"@types/chai": "^4.2.19",
2525
"@types/fs-extra": "^7.0.0",
2626
"@types/glob": "^7.1.3",
@@ -59,6 +59,7 @@
5959
"rimraf": "^3.0.2",
6060
"sinon": "^9.2.2",
6161
"ts-node": "^10.7.0",
62+
"tslib": "^2.3.1",
6263
"typescript": "^5.0.4",
6364
"uuid": "^8.3.2",
6465
"vscode-extension-tester": "^5.9.1"
@@ -69,8 +70,8 @@
6970
"@azure/arm-sql": "^9.0.0",
7071
"@azure/identity": "^3.1.3",
7172
"@azure/msal-node": "1.17.3",
72-
"@microsoft/teamsfx-api": "^0.22.5",
73-
"@microsoft/teamsapp-cli": "^3.0.0-alpha",
73+
"@microsoft/teamsfx-api": "workspace:*",
74+
"@microsoft/teamsapp-cli": "workspace:*",
7475
"@types/semver": "^7.3.8",
7576
"axios": "^0.21.1",
7677
"azure-arm-resource": "^7.4.0",

0 commit comments

Comments
 (0)