From 346a4a40c4bb7c700bcf403390f76509cc664bc5 Mon Sep 17 00:00:00 2001 From: Vineet Date: Wed, 9 Sep 2020 17:51:02 +0530 Subject: [PATCH 01/31] Added GitHub Workflow YAML definition. --- .github/workflows/workflow (1).yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/workflow (1).yml diff --git a/.github/workflows/workflow (1).yml b/.github/workflows/workflow (1).yml new file mode 100644 index 00000000..b8d8df40 --- /dev/null +++ b/.github/workflows/workflow (1).yml @@ -0,0 +1,20 @@ +on: + push: + branches: + - master + +name: Package and deploy simple web app + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + # checkout the repo + - uses: actions/checkout@master + + # deploy web app using publish profile credentials + - uses: azure/webapps-deploy@v1 + with: + app-name: vnm-demo + package: out/configure/test/test-fixtures + publish-profile: ${{ secrets.AZURE_CREDENTIALS_a307cf3d }} \ No newline at end of file From 28973471ee885a04e56e65f206d824675291a56b Mon Sep 17 00:00:00 2001 From: Vineet Date: Wed, 9 Sep 2020 18:11:28 +0530 Subject: [PATCH 02/31] Added GitHub Workflow YAML definition. --- .github/workflows/workflow (2).yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/workflow (2).yml diff --git a/.github/workflows/workflow (2).yml b/.github/workflows/workflow (2).yml new file mode 100644 index 00000000..dfded7a2 --- /dev/null +++ b/.github/workflows/workflow (2).yml @@ -0,0 +1,20 @@ +on: + push: + branches: + - master + +name: Package and deploy simple web app + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + # checkout the repo + - uses: actions/checkout@master + + # deploy web app using publish profile credentials + - uses: azure/webapps-deploy@v1 + with: + app-name: vnm-demo + package: out/configure/test/test-fixtures + publish-profile: ${{ secrets.AZURE_CREDENTIALS_66dd6999 }} \ No newline at end of file From 48cb7a02f20154cfa9a06907d7ed37d3ee9c2847 Mon Sep 17 00:00:00 2001 From: Vineet Date: Wed, 9 Sep 2020 18:41:30 +0530 Subject: [PATCH 03/31] Added GitHub Workflow YAML definition. --- .github/workflows/workflow (4).yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/workflow (4).yml diff --git a/.github/workflows/workflow (4).yml b/.github/workflows/workflow (4).yml new file mode 100644 index 00000000..7b9f8ac9 --- /dev/null +++ b/.github/workflows/workflow (4).yml @@ -0,0 +1,20 @@ +on: + push: + branches: + - master + +name: Package and deploy simple web app + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + # checkout the repo + - uses: actions/checkout@master + + # deploy web app using publish profile credentials + - uses: azure/webapps-deploy@v1 + with: + app-name: vnm-demo + package: out/configure/test/test-fixtures + publish-profile: ${{ secrets.AZURE_CREDENTIALS_a3f36a98 }} \ No newline at end of file From aa7a4d07fec6991a57edbf02f2d8fa7d70304e61 Mon Sep 17 00:00:00 2001 From: Vineet Date: Wed, 9 Sep 2020 23:52:46 +0530 Subject: [PATCH 04/31] Added GitHub Workflow YAML definition. --- .github/workflows/workflow (8).yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/workflow (8).yml diff --git a/.github/workflows/workflow (8).yml b/.github/workflows/workflow (8).yml new file mode 100644 index 00000000..626f3c65 --- /dev/null +++ b/.github/workflows/workflow (8).yml @@ -0,0 +1,20 @@ +on: + push: + branches: + - master + +name: Package and deploy simple web app + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + # checkout the repo + - uses: actions/checkout@master + + # deploy web app using publish profile credentials + - uses: azure/webapps-deploy@v1 + with: + app-name: vnm-demo + package: out/configure/test/test-fixtures + publish-profile: ${{ secrets.AZURE_CREDENTIALS_d9740d7c }} \ No newline at end of file From 2d299783c2eb2911fe4490c0bf498a61e2d9c97a Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 10 Sep 2020 00:05:21 +0530 Subject: [PATCH 05/31] Added GitHub Workflow YAML definition. --- .github/workflows/workflow (9).yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/workflow (9).yml diff --git a/.github/workflows/workflow (9).yml b/.github/workflows/workflow (9).yml new file mode 100644 index 00000000..768a7588 --- /dev/null +++ b/.github/workflows/workflow (9).yml @@ -0,0 +1,20 @@ +on: + push: + branches: + - master + +name: Package and deploy simple web app + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + # checkout the repo + - uses: actions/checkout@master + + # deploy web app using publish profile credentials + - uses: azure/webapps-deploy@v1 + with: + app-name: vnm-demo + package: out/configure/test/test-fixtures + publish-profile: ${{ secrets.AZURE_CREDENTIALS_81057a1f }} \ No newline at end of file From efc015ff269554b2463a2a781b6ebd89a95251dd Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 10 Sep 2020 00:07:11 +0530 Subject: [PATCH 06/31] Added GitHub Workflow YAML definition. --- .github/workflows/workflow (10).yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/workflow (10).yml diff --git a/.github/workflows/workflow (10).yml b/.github/workflows/workflow (10).yml new file mode 100644 index 00000000..8c9fb5af --- /dev/null +++ b/.github/workflows/workflow (10).yml @@ -0,0 +1,20 @@ +on: + push: + branches: + - master + +name: Package and deploy simple web app + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + # checkout the repo + - uses: actions/checkout@master + + # deploy web app using publish profile credentials + - uses: azure/webapps-deploy@v1 + with: + app-name: vnm-demo + package: out/configure/test/test-fixtures + publish-profile: ${{ secrets.AZURE_CREDENTIALS_231e0eb5 }} \ No newline at end of file From 2ae4c46004a022a6278d8e17742388c0217fdac8 Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 10 Sep 2020 00:10:22 +0530 Subject: [PATCH 07/31] Added GitHub Workflow YAML definition. --- .github/workflows/workflow (11).yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/workflow (11).yml diff --git a/.github/workflows/workflow (11).yml b/.github/workflows/workflow (11).yml new file mode 100644 index 00000000..61ff8dd2 --- /dev/null +++ b/.github/workflows/workflow (11).yml @@ -0,0 +1,20 @@ +on: + push: + branches: + - master + +name: Package and deploy simple web app + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + # checkout the repo + - uses: actions/checkout@master + + # deploy web app using publish profile credentials + - uses: azure/webapps-deploy@v1 + with: + app-name: vnm-demo + package: out/configure/test/test-fixtures + publish-profile: ${{ secrets.AZURE_CREDENTIALS_48cec3f2 }} \ No newline at end of file From b33b14d8531e553bf06b3fa3497f65897d1cb3f1 Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 10 Sep 2020 00:11:54 +0530 Subject: [PATCH 08/31] Added GitHub Workflow YAML definition. --- .github/workflows/workflow (12).yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/workflow (12).yml diff --git a/.github/workflows/workflow (12).yml b/.github/workflows/workflow (12).yml new file mode 100644 index 00000000..52185502 --- /dev/null +++ b/.github/workflows/workflow (12).yml @@ -0,0 +1,20 @@ +on: + push: + branches: + - master + +name: Package and deploy simple web app + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + # checkout the repo + - uses: actions/checkout@master + + # deploy web app using publish profile credentials + - uses: azure/webapps-deploy@v1 + with: + app-name: vnm-demo + package: out/configure/test/test-fixtures + publish-profile: ${{ secrets.AZURE_CREDENTIALS_77eab120 }} \ No newline at end of file From 692ae2524900a57919d842091eaf636f96ebd714 Mon Sep 17 00:00:00 2001 From: Vineet Date: Tue, 15 Sep 2020 15:13:18 +0530 Subject: [PATCH 09/31] e2e-v1 --- .vscode/launch.json | 14 +- package-lock.json | 371 +++++++++++------- package.json | 12 +- .../localGithubWorkflowConfigurer.ts | 2 +- src/configure/helper/gitHubHelper.ts | 10 +- src/configure/test/index.ts | 18 +- src/configure/test/runTest.ts | 2 +- .../E2ETests/GitHubWithWinWebapp.test.ts | 149 +++++++ .../{ => UnitTests}/GitHubClient.test.ts | 21 +- .../{ => UnitTests}/commonHelper.test.ts | 4 +- 10 files changed, 447 insertions(+), 156 deletions(-) create mode 100644 src/configure/test/suite/E2ETests/GitHubWithWinWebapp.test.ts rename src/configure/test/suite/{ => UnitTests}/GitHubClient.test.ts (88%) rename src/configure/test/suite/{ => UnitTests}/commonHelper.test.ts (95%) diff --git a/.vscode/launch.json b/.vscode/launch.json index 1dadb93d..2770e9e9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -27,13 +27,17 @@ "request": "launch", "runtimeExecutable": "${execPath}", "args": [ - "${workspaceRoot}/src/test/workspace/", + "/Users/vineetmimrot/work/raw-work/repo/github/staticwebapp", "--extensionDevelopmentPath=${workspaceFolder}", - "--extensionTestsPath=${workspaceFolder}/out/test" + "--extensionTestsPath=${workspaceFolder}/out/configure/test" ], "outFiles": [ - "${workspaceFolder}/out/test/**/*.js" - ] + "${workspaceFolder}/out/configure/test/**/*.js" + ], + "env": { + // Uncomment below line to show telemetry on Debug console + "DEBUGTELEMETRY": "v", + } }, { "name": "Extension Tests From Server", @@ -60,4 +64,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index e042721c..ef2fec0f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,51 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@sinonjs/commons": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.1.tgz", + "integrity": "sha512-892K+kWUUi3cl+LlqEWIDrhvLgdL79tECi8JZUyq6IviKy/DNhuzCRlbHUjxK89f4ypPMMaFnFuR9Ie6DoIMsw==", + "dev": true, + "requires": { + "type-detect": "4.0.8" + } + }, + "@sinonjs/fake-timers": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-6.0.1.tgz", + "integrity": "sha512-MZPUxrmFubI36XS1DI3qmI0YdN1gks62JtFZvxR67ljjSNCeK6U08Zx4msEWOXuofgqUt6zPHSi1H9fbjR/NRA==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.7.0" + } + }, + "@sinonjs/formatio": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-5.0.1.tgz", + "integrity": "sha512-KaiQ5pBf1MpS09MuA0kp6KBQt2JUOQycqVG1NZXvzeaXe5LGFqAKueIS0bw4w0P9r7KuBSVdUk5QjXsUdu2CxQ==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1", + "@sinonjs/samsam": "^5.0.2" + } + }, + "@sinonjs/samsam": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-5.1.0.tgz", + "integrity": "sha512-42nyaQOVunX5Pm6GRJobmzbS7iLI+fhERITnETXzzwDZh+TtDr/Au3yAvXVjFmZ4wEUaE4Y3NFZfKv0bV0cbtg==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.6.0", + "lodash.get": "^4.4.2", + "type-detect": "^4.0.8" + } + }, + "@sinonjs/text-encoding": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz", + "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", + "dev": true + }, "@types/anymatch": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/@types/anymatch/-/anymatch-1.3.1.tgz", @@ -72,6 +117,21 @@ "integrity": "sha512-sWj7AMiG0fYmta6ug1ublLjtj/tqn+CnCZeo7yswR1ykxel0FOWFGdWviTcGSNAMmtLbycDqbg6w98VPFKJmbw==", "dev": true }, + "@types/sinon": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-9.0.5.tgz", + "integrity": "sha512-4CnkGdM/5/FXDGqL32JQ1ttVrGvhOoesLLF7VnTh4KdjK5N5VQOtxaylFqqTjnHx55MnD9O02Nbk5c1ELC8wlQ==", + "dev": true, + "requires": { + "@types/sinonjs__fake-timers": "*" + } + }, + "@types/sinonjs__fake-timers": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-6.0.1.tgz", + "integrity": "sha512-yYezQwGWty8ziyYLdZjwxyMb0CZR49h8JALHGrxjQHWlqGgc8kLdHEgWrgL0uZ29DMvEVBDnHU2Wg36zKSIUtA==", + "dev": true + }, "@types/source-list-map": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz", @@ -99,6 +159,12 @@ "integrity": "sha512-vfzZGgZKRFy7KEWcBGfIFk+h6B+thDCLfkD1exMBMRlUsx2icA+J6y4kAbZs/TjSTeY1duw89QUU133TSzr60Q==", "dev": true }, + "@types/vscode": { + "version": "1.48.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.48.0.tgz", + "integrity": "sha512-sZJKzsJz1gSoFXcOJWw3fnKl2sseUgZmvB4AJZS+Fea+bC/jfGPVhmFL/FfQHld/TKtukVONsmoD3Pkyx9iadg==", + "dev": true + }, "@types/webpack": { "version": "4.41.13", "resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.41.13.tgz", @@ -734,7 +800,7 @@ "dependencies": { "chalk": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { @@ -1167,6 +1233,15 @@ "type-detect": "^4.0.5" } }, + "chai-as-promised": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-7.1.1.tgz", + "integrity": "sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==", + "dev": true, + "requires": { + "check-error": "^1.0.2" + } + }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -1372,7 +1447,7 @@ }, "commander": { "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz", "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", "dev": true }, @@ -2253,6 +2328,16 @@ "integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=", "dev": true }, + "fill-keys": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/fill-keys/-/fill-keys-1.0.2.tgz", + "integrity": "sha1-mo+jb06K1jTjv2tPPIiCVRRS6yA=", + "dev": true, + "requires": { + "is-object": "~1.0.1", + "merge-descriptors": "~1.0.0" + } + }, "fill-range": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.4.tgz", @@ -2961,6 +3046,12 @@ "kind-of": "^3.0.2" } }, + "is-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.1.tgz", + "integrity": "sha1-iVJojF7C/9awPsyF52ngKQMINHA=", + "dev": true + }, "is-path-cwd": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz", @@ -3166,6 +3257,12 @@ "verror": "1.10.0" } }, + "just-extend": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.1.0.tgz", + "integrity": "sha512-ApcjaOdVTJ7y4r08xI5wIqpvwS48Q0PBG4DJROcEkH1f8MdAiNFyFxz3xoL0LWAVwjrwPYZdVHHxhRHcx/uGLA==", + "dev": true + }, "jwa": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", @@ -3285,6 +3382,12 @@ "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=", "dev": true }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "dev": true + }, "lodash.isplainobject": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", @@ -3418,6 +3521,12 @@ } } }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=", + "dev": true + }, "micromatch": { "version": "2.3.11", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", @@ -3548,7 +3657,7 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { @@ -3770,6 +3879,15 @@ } } }, + "mocha-explorer-launcher-scripts": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/mocha-explorer-launcher-scripts/-/mocha-explorer-launcher-scripts-0.3.0.tgz", + "integrity": "sha512-6+lGXAvrT3oN92smLyF1jQaLunOsiqAxcRxvuVjXrzKrDUU2npaVivrOE+VxYKMCdxItiX5bviJQCMIpdQa38A==", + "dev": true, + "requires": { + "vscode-test-adapter-remoting-util": "^0.11.0" + } + }, "mock-require": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/mock-require/-/mock-require-3.0.3.tgz", @@ -3791,6 +3909,12 @@ } } }, + "module-not-found-error": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/module-not-found-error/-/module-not-found-error-1.0.1.tgz", + "integrity": "sha1-z4tP9PKWQGdNbN0CsOO8UjwrvcA=", + "dev": true + }, "moment": { "version": "2.24.0", "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", @@ -3941,6 +4065,19 @@ "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==", "dev": true }, + "nise": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/nise/-/nise-4.0.4.tgz", + "integrity": "sha512-bTTRUNlemx6deJa+ZyoCUTRvH3liK5+N6VQZ4NIw90AgDXY6iPnsqplNFf6STcj+ePk0H/xqxnP75Lr0J0Fq3A==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.7.0", + "@sinonjs/fake-timers": "^6.0.0", + "@sinonjs/text-encoding": "^0.7.1", + "just-extend": "^4.0.2", + "path-to-regexp": "^1.7.0" + } + }, "nock": { "version": "13.0.2", "resolved": "https://registry.npmjs.org/nock/-/nock-13.0.2.tgz", @@ -4375,6 +4512,23 @@ "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", "dev": true }, + "path-to-regexp": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", + "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", + "dev": true, + "requires": { + "isarray": "0.0.1" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + } + } + }, "pathval": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", @@ -4477,6 +4631,17 @@ "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", "dev": true }, + "proxyquire": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/proxyquire/-/proxyquire-2.1.3.tgz", + "integrity": "sha512-BQWfCqYM+QINd+yawJz23tbBM40VIGXOdDw3X344KcclI/gtBbdWF6SlQ4nK/bYhF9d27KYug9WzljHC6B9Ysg==", + "dev": true, + "requires": { + "fill-keys": "^1.0.2", + "module-not-found-error": "^1.0.1", + "resolve": "^1.11.1" + } + }, "prr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", @@ -4570,12 +4735,6 @@ "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", "dev": true }, - "querystringify": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.1.tgz", - "integrity": "sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA==", - "dev": true - }, "randomatic": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-3.1.1.tgz", @@ -5055,12 +5214,6 @@ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, - "requires-port": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", - "dev": true - }, "resolve": { "version": "1.12.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", @@ -5251,6 +5404,44 @@ } } }, + "sinon": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.0.3.tgz", + "integrity": "sha512-IKo9MIM111+smz9JGwLmw5U1075n1YXeAq8YeSFlndCLhAL5KGn6bLgu7b/4AYHTV/LcEMcRm2wU2YiL55/6Pg==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.7.2", + "@sinonjs/fake-timers": "^6.0.1", + "@sinonjs/formatio": "^5.0.1", + "@sinonjs/samsam": "^5.1.0", + "diff": "^4.0.2", + "nise": "^4.0.4", + "supports-color": "^7.1.0" + }, + "dependencies": { + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", @@ -5415,6 +5606,15 @@ "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", "dev": true }, + "split": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", + "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", + "dev": true, + "requires": { + "through": "2" + } + }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", @@ -6473,16 +6673,6 @@ } } }, - "url-parse": { - "version": "1.4.7", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz", - "integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==", - "dev": true, - "requires": { - "querystringify": "^2.1.1", - "requires-port": "^1.0.0" - } - }, "use": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", @@ -6532,112 +6722,6 @@ "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==", "dev": true }, - "vscode": { - "version": "1.1.33", - "resolved": "https://registry.npmjs.org/vscode/-/vscode-1.1.33.tgz", - "integrity": "sha512-sXedp2oF6y4ZvqrrFiZpeMzaCLSWV+PpYkIxjG/iYquNZ9KrLL2LujltGxPLvzn49xu2sZkyC+avVNFgcJD1Iw==", - "dev": true, - "requires": { - "glob": "^7.1.2", - "mocha": "^4.0.1", - "request": "^2.88.0", - "semver": "^5.4.1", - "source-map-support": "^0.5.0", - "url-parse": "^1.4.4", - "vscode-test": "^0.1.4" - }, - "dependencies": { - "browser-stdout": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", - "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", - "dev": true - }, - "commander": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", - "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", - "dev": true - }, - "diff": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.3.1.tgz", - "integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==", - "dev": true - }, - "growl": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", - "dev": true - }, - "has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", - "dev": true - }, - "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", - "dev": true - }, - "mocha": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-4.1.0.tgz", - "integrity": "sha512-0RVnjg1HJsXY2YFDoTNzcc1NKhYuXKRrBAG2gDygmJJA136Cs2QlRliZG1mA0ap7cuaT30mw16luAeln+4RiNA==", - "dev": true, - "requires": { - "browser-stdout": "1.3.0", - "commander": "2.11.0", - "debug": "3.1.0", - "diff": "3.3.1", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.3", - "he": "1.1.1", - "mkdirp": "0.5.1", - "supports-color": "4.4.0" - }, - "dependencies": { - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - } - } - }, - "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", - "dev": true, - "requires": { - "has-flag": "^2.0.0" - } - }, - "vscode-test": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/vscode-test/-/vscode-test-0.1.5.tgz", - "integrity": "sha512-s+lbF1Dtasc0yXVB9iQTexBe2JK6HJAUJe3fWezHKIjq+xRw5ZwCMEMBaonFIPy7s95qg2HPTRDR5W4h4kbxGw==", - "dev": true, - "requires": { - "http-proxy-agent": "^2.1.0", - "https-proxy-agent": "^2.2.1" - } - } - } - }, "vscode-azureextensiondev": { "version": "0.3.4", "resolved": "https://registry.npmjs.org/vscode-azureextensiondev/-/vscode-azureextensiondev-0.3.4.tgz", @@ -6834,6 +6918,31 @@ "rimraf": "^2.6.3" } }, + "vscode-test-adapter-api": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/vscode-test-adapter-api/-/vscode-test-adapter-api-1.9.0.tgz", + "integrity": "sha512-lltjehUP0J9H3R/HBctjlqeUCwn2t9Lbhj2Y500ib+j5Y4H3hw+hVTzuSsfw16LtxY37knlU39QIlasa7svzOQ==", + "dev": true + }, + "vscode-test-adapter-remoting-util": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/vscode-test-adapter-remoting-util/-/vscode-test-adapter-remoting-util-0.11.0.tgz", + "integrity": "sha512-EZPjSZ6O4NLIY0WjScND8EFQ6z2D0KYoWLfSPMFxKFcv2MpgzF8gIOAXVmkgu0mVKrmRDoSQ7URqcsvFGOtaMA==", + "dev": true, + "requires": { + "split": "^1.0.1", + "tslib": "^2.0.0", + "vscode-test-adapter-api": "^1.9.0" + }, + "dependencies": { + "tslib": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz", + "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==", + "dev": true + } + } + }, "vscode-uri": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-1.0.6.tgz", diff --git a/package.json b/package.json index 34cba677..f099a891 100644 --- a/package.json +++ b/package.json @@ -111,9 +111,8 @@ "vscode:prepublish": "npm run compile", "compile": "tsc -p ./ && node copyStaticFiles.js", "watch": "node copyStaticFiles.js && tsc -watch -p ./", - "postinstall": "node ./node_modules/vscode/bin/install", "pretest": "npm run compile", - "test": "node ./out/configure/test/runTest.js" + "test": "cp -r ./src/configure/test/test-fixtures/ ./out/configure/test/test-fixtures/ && node ./out/configure/test/runTest.js" }, "devDependencies": { "@types/fs-extra": "4.0.5", @@ -123,19 +122,24 @@ "@types/mustache": "0.8.32", "@types/node": "7.0.43", "@types/q": "1.5.0", + "@types/sinon": "^9.0.5", "@types/underscore": "1.8.9", + "@types/vscode": "^1.32.0", "ajv": "^6.9.1", "assert": "1.4.1", "chai": "^4.2.0", + "chai-as-promised": "^7.1.1", "glob": "^7.1.6", "mocha": "^7.1.2", + "mocha-explorer-launcher-scripts": "^0.3.0", "nock": "^13.0.2", + "proxyquire": "2.1.3", + "sinon": "^9.0.3", "ts-node": "7.0.1", "tslint": "5.8.0", "tslint-microsoft-contrib": "^6.2.0", "typescript": "3.3.1", "typescript-tslint-plugin": "^0.5.5", - "vscode": "1.1.33", "vscode-azureextensiondev": "^0.3.1", "vscode-test": "^1.3.0" }, @@ -163,4 +167,4 @@ "extensionDependencies": [ "ms-vscode.azure-account" ] -} +} \ No newline at end of file diff --git a/src/configure/configurers/localGithubWorkflowConfigurer.ts b/src/configure/configurers/localGithubWorkflowConfigurer.ts index c9dc2b8f..71e34e39 100644 --- a/src/configure/configurers/localGithubWorkflowConfigurer.ts +++ b/src/configure/configurers/localGithubWorkflowConfigurer.ts @@ -202,7 +202,7 @@ export class LocalGitHubWorkflowConfigurer implements Configurer { displayMessage = Messages.modifyAndCommitMultipleFiles; } - let commitOrDiscard = await vscode.window.showInformationMessage( + const commitOrDiscard = await this.controlProvider.showInformationBox( utils.format(displayMessage, Messages.commitAndPush, inputs.sourceRepository.branch, inputs.sourceRepository.remoteName), Messages.commitAndPush, Messages.discardPipeline); diff --git a/src/configure/helper/gitHubHelper.ts b/src/configure/helper/gitHubHelper.ts index 32112ca7..2b39d96c 100644 --- a/src/configure/helper/gitHubHelper.ts +++ b/src/configure/helper/gitHubHelper.ts @@ -1,6 +1,7 @@ export class GitHubProvider { // private gitHubPatToken: string; - private static GitHubUrl = 'https://github.com/'; + private static GitHubUrl1 = 'https://github.com/'; + private static GitHubUrl2 = 'https://www.github.com/'; private static SSHGitHubUrl = 'git@github.com:'; // constructor(gitHubPat: string) { @@ -8,7 +9,7 @@ export class GitHubProvider { // } public static isGitHubUrl(remoteUrl: string): boolean { - return remoteUrl.startsWith(GitHubProvider.GitHubUrl) || remoteUrl.startsWith(GitHubProvider.SSHGitHubUrl); + return remoteUrl.startsWith(GitHubProvider.GitHubUrl1) || remoteUrl.startsWith(GitHubProvider.GitHubUrl2) || remoteUrl.startsWith(GitHubProvider.SSHGitHubUrl); } public static getRepositoryIdFromUrl(remoteUrl: string): string { @@ -17,12 +18,13 @@ export class GitHubProvider { return remoteUrl.substring(GitHubProvider.SSHGitHubUrl.length); } - let endCount: number = remoteUrl.indexOf('.git'); + let endCount: number = remoteUrl.indexOf('.git', remoteUrl.lastIndexOf('/') + 1); if (endCount < 0) { endCount = remoteUrl.length; } - return remoteUrl.substring(GitHubProvider.GitHubUrl.length, endCount); + return remoteUrl.startsWith(GitHubProvider.GitHubUrl1) ? + remoteUrl.substring(GitHubProvider.GitHubUrl1.length, endCount) : remoteUrl.substring(GitHubProvider.GitHubUrl2.length, endCount); } public static getFormattedRemoteUrl(remoteUrl: string): string { diff --git a/src/configure/test/index.ts b/src/configure/test/index.ts index cc6ffb47..f564912d 100644 --- a/src/configure/test/index.ts +++ b/src/configure/test/index.ts @@ -1,18 +1,30 @@ +import * as fs from 'fs'; import * as glob from 'glob'; import * as Mocha from 'mocha'; +import * as os from 'os'; import * as path from 'path'; export function run(): Promise { // Create the mocha test + const testsRoot = path.resolve(__dirname, '..'); + const testResultDir = path.join(testsRoot, 'test', 'deploy-azure-extension-testResult'); + if (!fs.existsSync(testResultDir)) { + fs.mkdirSync(testResultDir); + } + const testResultFileName = path.normalize(path.join(testResultDir, os.platform() + "-" + ((new Date()).toJSON().slice(0, 19).replace('T', '_').replace(/:/g, '')) + ".xml")); const mocha = new Mocha({ ui: 'bdd', - color: true + color: true, + reporter: "xunit", + reporterOptions: { + output: testResultFileName, + } }); - const testsRoot = path.resolve(__dirname, '..'); return new Promise((c, e) => { - glob('**/suite/**.test.js', { cwd: testsRoot }, (err, files) => { + glob('**/suite/E2ETests/**.test.js', { cwd: testsRoot }, (err, files) => { + // glob('**/suite/**/**.test.js', { cwd: testsRoot }, (err, files) => { if (err) { return e(err); } diff --git a/src/configure/test/runTest.ts b/src/configure/test/runTest.ts index 0bdd6b8a..7790cb56 100644 --- a/src/configure/test/runTest.ts +++ b/src/configure/test/runTest.ts @@ -13,7 +13,7 @@ async function testHost() { const extensionTestsPath = path.resolve(__dirname, './index'); // Download VS Code, unzip it and run the integration test - await runTests({ extensionDevelopmentPath, extensionTestsPath }); + await runTests({ launchArgs: ["/Users/vineetmimrot/work/raw-work/repo/github/staticwebapp"], extensionDevelopmentPath, extensionTestsPath }); } catch (err) { console.error('Failed to run tests. Error : ' + err); process.exit(1); diff --git a/src/configure/test/suite/E2ETests/GitHubWithWinWebapp.test.ts b/src/configure/test/suite/E2ETests/GitHubWithWinWebapp.test.ts new file mode 100644 index 00000000..dd2978b0 --- /dev/null +++ b/src/configure/test/suite/E2ETests/GitHubWithWinWebapp.test.ts @@ -0,0 +1,149 @@ +import * as vscode from 'vscode'; +import { ControlProvider } from "../../../helper/controlProvider"; +import { Messages } from "../../../resources/messages"; +// var path = require('path'); +// var os = require('os'); +// var fs = require('fs'); +let sinon = require('sinon'); +let chai = require("chai"); +let chaiAsPromised = require("chai-as-promised"); + +chai.use(chaiAsPromised); +//let expect = chai.expect; + +const extensionId = "ms-vscode-deploy-azure.azure-deploy"; + +let subscriptionData = { + label: "RMDev", + data: { + session: { + userId: "vimimrot@microsoft.com", + tenantId: "72f988bf-86f1-41af-91ab-2d7cd011db47" + }, + subscription: { + id: "/subscriptions/c00d16c7-6c1f-4c03-9be1-6934a4c49682", + subscriptionId: "c00d16c7-6c1f-4c03-9be1-6934a4c49682", + displayName: "RMDev", + } + }, + description: "c00d16c7-6c1f-4c03-9be1-6934a4c49682" +}; + +let webappResourceData = { + label: "vnm-demo", + data: { + id: "/subscriptions/c00d16c7-6c1f-4c03-9be1-6934a4c49682/resourceGroups/vnmtestlinux93c8/providers/Microsoft.Web/sites/vnm-demo", + name: "vnm-demo", + type: "Microsoft.Web/sites", + kind: "app" + } +}; + +describe('# Should start extension @vscode-deploy-azure ', function () { + context('Should start extension @vscode-deploy-azure', function () { + it('should be able to activate the extension', async function () { + this.timeout(60 * 1000); + await sleep(2000); + const extension = vscode.extensions.getExtension(extensionId); + if (!extension.isActive) { + chai.expect(extension.activate()).should.be.fulfilled; + } + }); + }); + + + context('Mock - Should configure pipeline @vscode-deploy-azure', function () { + + // before(function () { + // this.timeout(0); + // var projectPath: string; + + // var localGitDirPath = fs.mkdtempSync(path.join(os.tmpdir(), 'sample-')); + // const gitUrl = "https://github.com/microsoft/devops-project-samples.git"; + // return LocalGitRepoHelper.GitCloneRepo(gitUrl, localGitDirPath).then(() => { + // fs.rmdirSync(path.join(localGitDirPath, ".git"), { recursive: true }); + // projectPath = path.join(localGitDirPath, "html", "webapp", "Application"); + // let uri = vscode.Uri.file(projectPath); + // return vscode.commands.executeCommand('vscode.openFolder', uri).then((success) => { + // }, (err) => { + // throw new Error("Unable to open folder: " + projectPath); + // }); + // }); + // }); + + it('Mock - configure pipeline @vscode-deploy-azure', function () { + this.timeout(0); + + let mockGetInput, mockShowQuickPick, mockShowInformationMessage; + return sleep(5000).then(() => { + return vscode.extensions.getExtension(extensionId).activate(); + }).then(() => { + mockGetInput = sinon.stub(ControlProvider.prototype, 'showInputBox'); + mockGetInput.onFirstCall().resolves('bf025851a48bfe18d7b49e7ec7f7bb6c854645d8'); + + mockShowQuickPick = sinon.stub(ControlProvider.prototype, 'showQuickPick'); + mockShowQuickPick + .onFirstCall().resolves(subscriptionData) + .onSecondCall().resolves(webappResourceData); + + mockShowInformationMessage = sinon.stub(ControlProvider.prototype, 'showInformationBox'); + mockShowInformationMessage.onFirstCall().resolves(Messages.discardPipeline); + return sleep(5000); + }).then(() => { + return vscode.commands.executeCommand("configure-cicd-pipeline"); + }).then(() => { + sinon.assert.calledOnce(mockGetInput); + sinon.assert.calledTwice(mockShowQuickPick); + sinon.assert.calledOnce(mockShowInformationMessage); + }); + }); + + after(function () { + sinon.restore(); + }); + }); + + // context('Mock - Should configure pipeline @vscode-deploy-azure', function () { + // it('Mock - configure pipeline @vscode-deploy-azure', async function () { + // this.timeout(0); + // await sleep(5000); + // await vscode.extensions.getExtension(extensionId).activate(); + // // await sleep(2000); + // let mockControlProvider; + // mockControlProvider = sinon.createStubInstance(ControlProvider); + // mockControlProvider.showInputBox.onFirstCall().resolves('bf025851a48bfe18d7b49e7ec7f7bb6c854645d8'); + + // // mockShowQuickPick = sinon.stub(ControlProvider.prototype, 'showQuickPick'); + // mockControlProvider.showQuickPick + // .onFirstCall().resolves(subscriptionData) + // .onSecondCall().resolves(webappResourceData) + // .onThirdCall().resolves("vnm-test2"); + + // // mockShowInformationMessage = sinon.stub(ControlProvider.prototype, 'showInformationBox'); + // mockControlProvider.showInformationBox.onFirstCall().resolves(Messages.commitAndPush); + // await sleep(2000); + // await vscode.commands.executeCommand("configure-cicd-pipeline"); + // // await sleep(2000); + // expect(mockControlProvider.showInputBox.calledOnce, "showInputBox.calledOnce").to.be.true; + // expect(mockControlProvider.showQuickPick.calledThrice, "showQuickPick.calledThrice").to.be.true; + // expect(mockControlProvider.showInformationBox.calledOnce, "showInformationBox.calledOnce").to.be.true; + + // }); + + // after(() => { + // sinon.restore(); + // }) + // }); + + + +}); + +// afterEach(() => { +// // Restore the default sandbox here +// sinon.restore(); +// }); + +async function sleep(ms: number) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} diff --git a/src/configure/test/suite/GitHubClient.test.ts b/src/configure/test/suite/UnitTests/GitHubClient.test.ts similarity index 88% rename from src/configure/test/suite/GitHubClient.test.ts rename to src/configure/test/suite/UnitTests/GitHubClient.test.ts index b0fcd2d0..a1309005 100644 --- a/src/configure/test/suite/GitHubClient.test.ts +++ b/src/configure/test/suite/UnitTests/GitHubClient.test.ts @@ -1,5 +1,5 @@ import * as _ from 'lodash'; -import { GithubClient } from "../../clients/github/githubClient"; +import { GithubClient } from "../../../clients/github/githubClient"; var expect = require('chai').expect; var nock = require('nock'); @@ -28,6 +28,13 @@ var orgList = [ "repos_url": "https://api.github.com/orgs/SampleOrganizationC/repos" }]; +var userInfo = { + "login": "username", + "id": 66721313, + "url": "https://api.github.com/users/username", + "repos_url": "https://api.github.com/users/username/repos" +} + var repoCreationResponseOnSuccess = { "id": 278008782, "name": repoName, @@ -51,10 +58,12 @@ describe('# Testing listOrganizations() ', function () { it('should return a list of organizations', function (done) { nock('https://api.github.com') .get('/user/orgs') - .reply(200, orgList); + .reply(200, orgList) + .get('/user') + .reply(200, userInfo); githubClient.listOrganizations(true).then((orgs) => { expect(Array.isArray(orgs)).to.equal(true); - expect(orgs.length).to.equal(3); + expect(orgs.length).to.equal(4); orgs.forEach((org) => { expect(org).to.have.property('login'); expect(org).to.have.property('id'); @@ -69,10 +78,12 @@ describe('# Testing listOrganizations() ', function () { it('Should return an empty list of organization', function (done) { nock('https://api.github.com') .get('/user/orgs') - .reply(200, []); + .reply(200, []) + .get('/user') + .reply(200, userInfo); githubClient.listOrganizations(true).then((orgs) => { expect(Array.isArray(orgs)).to.equal(true); - expect(orgs.length).to.equal(0); + expect(orgs.length).to.equal(1); done(); }); }); diff --git a/src/configure/test/suite/commonHelper.test.ts b/src/configure/test/suite/UnitTests/commonHelper.test.ts similarity index 95% rename from src/configure/test/suite/commonHelper.test.ts rename to src/configure/test/suite/UnitTests/commonHelper.test.ts index 210c8d4b..639d1f39 100644 --- a/src/configure/test/suite/commonHelper.test.ts +++ b/src/configure/test/suite/UnitTests/commonHelper.test.ts @@ -1,6 +1,6 @@ import * as _ from 'lodash'; -import { GithubClient } from "../../clients/github/githubClient"; -import { generateGitHubRepository } from "../../helper/commonHelper"; +import { GithubClient } from "../../../clients/github/githubClient"; +import { generateGitHubRepository } from "../../../helper/commonHelper"; var expect = require('chai').expect; var nock = require('nock'); From b83de5cf9ecb5af7f8812b011ca4d374c1d55c8d Mon Sep 17 00:00:00 2001 From: Vineet Date: Tue, 15 Sep 2020 15:16:28 +0530 Subject: [PATCH 10/31] minor fix --- .github/CODEOWNERS | 1 - .github/workflows/workflow (1).yml | 20 -------------------- .github/workflows/workflow (10).yml | 20 -------------------- .github/workflows/workflow (11).yml | 20 -------------------- .github/workflows/workflow (12).yml | 20 -------------------- .github/workflows/workflow (2).yml | 20 -------------------- .github/workflows/workflow (4).yml | 20 -------------------- .github/workflows/workflow (8).yml | 20 -------------------- .github/workflows/workflow (9).yml | 20 -------------------- 9 files changed, 161 deletions(-) delete mode 100644 .github/CODEOWNERS delete mode 100644 .github/workflows/workflow (1).yml delete mode 100644 .github/workflows/workflow (10).yml delete mode 100644 .github/workflows/workflow (11).yml delete mode 100644 .github/workflows/workflow (12).yml delete mode 100644 .github/workflows/workflow (2).yml delete mode 100644 .github/workflows/workflow (4).yml delete mode 100644 .github/workflows/workflow (8).yml delete mode 100644 .github/workflows/workflow (9).yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index 23a746b6..00000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @bishal-pdmsft @vineetmimrot @kanika1894 @anuragc617 diff --git a/.github/workflows/workflow (1).yml b/.github/workflows/workflow (1).yml deleted file mode 100644 index b8d8df40..00000000 --- a/.github/workflows/workflow (1).yml +++ /dev/null @@ -1,20 +0,0 @@ -on: - push: - branches: - - master - -name: Package and deploy simple web app - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - # checkout the repo - - uses: actions/checkout@master - - # deploy web app using publish profile credentials - - uses: azure/webapps-deploy@v1 - with: - app-name: vnm-demo - package: out/configure/test/test-fixtures - publish-profile: ${{ secrets.AZURE_CREDENTIALS_a307cf3d }} \ No newline at end of file diff --git a/.github/workflows/workflow (10).yml b/.github/workflows/workflow (10).yml deleted file mode 100644 index 8c9fb5af..00000000 --- a/.github/workflows/workflow (10).yml +++ /dev/null @@ -1,20 +0,0 @@ -on: - push: - branches: - - master - -name: Package and deploy simple web app - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - # checkout the repo - - uses: actions/checkout@master - - # deploy web app using publish profile credentials - - uses: azure/webapps-deploy@v1 - with: - app-name: vnm-demo - package: out/configure/test/test-fixtures - publish-profile: ${{ secrets.AZURE_CREDENTIALS_231e0eb5 }} \ No newline at end of file diff --git a/.github/workflows/workflow (11).yml b/.github/workflows/workflow (11).yml deleted file mode 100644 index 61ff8dd2..00000000 --- a/.github/workflows/workflow (11).yml +++ /dev/null @@ -1,20 +0,0 @@ -on: - push: - branches: - - master - -name: Package and deploy simple web app - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - # checkout the repo - - uses: actions/checkout@master - - # deploy web app using publish profile credentials - - uses: azure/webapps-deploy@v1 - with: - app-name: vnm-demo - package: out/configure/test/test-fixtures - publish-profile: ${{ secrets.AZURE_CREDENTIALS_48cec3f2 }} \ No newline at end of file diff --git a/.github/workflows/workflow (12).yml b/.github/workflows/workflow (12).yml deleted file mode 100644 index 52185502..00000000 --- a/.github/workflows/workflow (12).yml +++ /dev/null @@ -1,20 +0,0 @@ -on: - push: - branches: - - master - -name: Package and deploy simple web app - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - # checkout the repo - - uses: actions/checkout@master - - # deploy web app using publish profile credentials - - uses: azure/webapps-deploy@v1 - with: - app-name: vnm-demo - package: out/configure/test/test-fixtures - publish-profile: ${{ secrets.AZURE_CREDENTIALS_77eab120 }} \ No newline at end of file diff --git a/.github/workflows/workflow (2).yml b/.github/workflows/workflow (2).yml deleted file mode 100644 index dfded7a2..00000000 --- a/.github/workflows/workflow (2).yml +++ /dev/null @@ -1,20 +0,0 @@ -on: - push: - branches: - - master - -name: Package and deploy simple web app - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - # checkout the repo - - uses: actions/checkout@master - - # deploy web app using publish profile credentials - - uses: azure/webapps-deploy@v1 - with: - app-name: vnm-demo - package: out/configure/test/test-fixtures - publish-profile: ${{ secrets.AZURE_CREDENTIALS_66dd6999 }} \ No newline at end of file diff --git a/.github/workflows/workflow (4).yml b/.github/workflows/workflow (4).yml deleted file mode 100644 index 7b9f8ac9..00000000 --- a/.github/workflows/workflow (4).yml +++ /dev/null @@ -1,20 +0,0 @@ -on: - push: - branches: - - master - -name: Package and deploy simple web app - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - # checkout the repo - - uses: actions/checkout@master - - # deploy web app using publish profile credentials - - uses: azure/webapps-deploy@v1 - with: - app-name: vnm-demo - package: out/configure/test/test-fixtures - publish-profile: ${{ secrets.AZURE_CREDENTIALS_a3f36a98 }} \ No newline at end of file diff --git a/.github/workflows/workflow (8).yml b/.github/workflows/workflow (8).yml deleted file mode 100644 index 626f3c65..00000000 --- a/.github/workflows/workflow (8).yml +++ /dev/null @@ -1,20 +0,0 @@ -on: - push: - branches: - - master - -name: Package and deploy simple web app - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - # checkout the repo - - uses: actions/checkout@master - - # deploy web app using publish profile credentials - - uses: azure/webapps-deploy@v1 - with: - app-name: vnm-demo - package: out/configure/test/test-fixtures - publish-profile: ${{ secrets.AZURE_CREDENTIALS_d9740d7c }} \ No newline at end of file diff --git a/.github/workflows/workflow (9).yml b/.github/workflows/workflow (9).yml deleted file mode 100644 index 768a7588..00000000 --- a/.github/workflows/workflow (9).yml +++ /dev/null @@ -1,20 +0,0 @@ -on: - push: - branches: - - master - -name: Package and deploy simple web app - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - # checkout the repo - - uses: actions/checkout@master - - # deploy web app using publish profile credentials - - uses: azure/webapps-deploy@v1 - with: - app-name: vnm-demo - package: out/configure/test/test-fixtures - publish-profile: ${{ secrets.AZURE_CREDENTIALS_81057a1f }} \ No newline at end of file From 4b645405329ef307ed106aa625783b89bf2d5c63 Mon Sep 17 00:00:00 2001 From: Vineet Date: Wed, 16 Sep 2020 21:48:35 +0530 Subject: [PATCH 11/31] final version of test --- .vscode/launch.json | 4 +- copyStaticFiles.js | 3 + package-lock.json | 216 +++++++++++------- package.json | 8 +- ...portalExtensionRepositoryAnalysisClient.ts | 2 +- src/configure/configure.ts | 7 +- .../configurers/azurePipelineConfigurer.ts | 14 +- .../localGithubWorkflowConfigurer.ts | 6 +- src/configure/helper/AssetHandler.ts | 8 +- src/configure/helper/LocalGitRepoHelper.ts | 2 +- src/configure/resources/constants.ts | 2 + .../Static_Windows_WebApp.test.ts | 62 +++++ .../E2ETests/Static_Win_WebApp_Suite/index.ts | 6 + src/configure/test/E2ETests/testConstants.ts | 58 +++++ .../Static_Windows_WebApp_Workflow.yml | 20 ++ src/configure/test/E2ETests/testMocks.ts | 88 +++++++ .../GitHubClient.test.ts | 2 +- .../commonHelper.test.ts | 4 +- src/configure/test/UnitTestsSuite/index.ts | 6 + .../{index.ts => commonIndexUtilities.ts} | 11 +- src/configure/test/runTest.ts | 35 ++- .../E2ETests/GitHubWithWinWebapp.test.ts | 149 ------------ src/configure/utilities/utilities.ts | 5 + 23 files changed, 437 insertions(+), 281 deletions(-) create mode 100644 src/configure/test/E2ETests/Static_Win_WebApp_Suite/Static_Windows_WebApp.test.ts create mode 100644 src/configure/test/E2ETests/Static_Win_WebApp_Suite/index.ts create mode 100644 src/configure/test/E2ETests/testConstants.ts create mode 100644 src/configure/test/E2ETests/testFixtures/workflows/Static_Windows_WebApp_Workflow.yml create mode 100644 src/configure/test/E2ETests/testMocks.ts rename src/configure/test/{suite/UnitTests => UnitTestsSuite}/GitHubClient.test.ts (98%) rename src/configure/test/{suite/UnitTests => UnitTestsSuite}/commonHelper.test.ts (95%) create mode 100644 src/configure/test/UnitTestsSuite/index.ts rename src/configure/test/{index.ts => commonIndexUtilities.ts} (78%) delete mode 100644 src/configure/test/suite/E2ETests/GitHubWithWinWebapp.test.ts diff --git a/.vscode/launch.json b/.vscode/launch.json index 2770e9e9..ba88b3aa 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -27,9 +27,9 @@ "request": "launch", "runtimeExecutable": "${execPath}", "args": [ - "/Users/vineetmimrot/work/raw-work/repo/github/staticwebapp", + "/Users/vineetmimrot/work/raw-work/repo/github/staticwebapp/", "--extensionDevelopmentPath=${workspaceFolder}", - "--extensionTestsPath=${workspaceFolder}/out/configure/test" + "--extensionTestsPath=${workspaceFolder}/out/configure/test/E2ETests/Static_Win_WebApp_Suite" ], "outFiles": [ "${workspaceFolder}/out/configure/test/**/*.js" diff --git a/copyStaticFiles.js b/copyStaticFiles.js index 029f7ab4..20352ef5 100644 --- a/copyStaticFiles.js +++ b/copyStaticFiles.js @@ -32,3 +32,6 @@ var mkdir = function (options, target) { mkdir("-p", path.join(__dirname, 'out/configure/templates')); cp("-Rf", path.join(__dirname, 'src/configure/templates/*'), path.join(__dirname, 'out/configure/templates')); //# sourceMappingURL=copyStaticFiles.js.map + +mkdir("-p", path.join(__dirname, 'out/configure/test/E2ETests/testFixtures')); +cp("-Rf", path.join(__dirname, 'src/configure/test/E2ETests/testFixtures/*'), path.join(__dirname, 'out/configure/test/E2ETests/testFixtures')); diff --git a/package-lock.json b/package-lock.json index ef2fec0f..76380b34 100644 --- a/package-lock.json +++ b/package-lock.json @@ -159,12 +159,6 @@ "integrity": "sha512-vfzZGgZKRFy7KEWcBGfIFk+h6B+thDCLfkD1exMBMRlUsx2icA+J6y4kAbZs/TjSTeY1duw89QUU133TSzr60Q==", "dev": true }, - "@types/vscode": { - "version": "1.48.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.48.0.tgz", - "integrity": "sha512-sZJKzsJz1gSoFXcOJWw3fnKl2sseUgZmvB4AJZS+Fea+bC/jfGPVhmFL/FfQHld/TKtukVONsmoD3Pkyx9iadg==", - "dev": true - }, "@types/webpack": { "version": "4.41.13", "resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.41.13.tgz", @@ -2328,16 +2322,6 @@ "integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=", "dev": true }, - "fill-keys": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/fill-keys/-/fill-keys-1.0.2.tgz", - "integrity": "sha1-mo+jb06K1jTjv2tPPIiCVRRS6yA=", - "dev": true, - "requires": { - "is-object": "~1.0.1", - "merge-descriptors": "~1.0.0" - } - }, "fill-range": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.4.tgz", @@ -3046,12 +3030,6 @@ "kind-of": "^3.0.2" } }, - "is-object": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.1.tgz", - "integrity": "sha1-iVJojF7C/9awPsyF52ngKQMINHA=", - "dev": true - }, "is-path-cwd": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz", @@ -3521,12 +3499,6 @@ } } }, - "merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=", - "dev": true - }, "micromatch": { "version": "2.3.11", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", @@ -3879,15 +3851,6 @@ } } }, - "mocha-explorer-launcher-scripts": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/mocha-explorer-launcher-scripts/-/mocha-explorer-launcher-scripts-0.3.0.tgz", - "integrity": "sha512-6+lGXAvrT3oN92smLyF1jQaLunOsiqAxcRxvuVjXrzKrDUU2npaVivrOE+VxYKMCdxItiX5bviJQCMIpdQa38A==", - "dev": true, - "requires": { - "vscode-test-adapter-remoting-util": "^0.11.0" - } - }, "mock-require": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/mock-require/-/mock-require-3.0.3.tgz", @@ -3909,12 +3872,6 @@ } } }, - "module-not-found-error": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/module-not-found-error/-/module-not-found-error-1.0.1.tgz", - "integrity": "sha1-z4tP9PKWQGdNbN0CsOO8UjwrvcA=", - "dev": true - }, "moment": { "version": "2.24.0", "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", @@ -4631,17 +4588,6 @@ "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", "dev": true }, - "proxyquire": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/proxyquire/-/proxyquire-2.1.3.tgz", - "integrity": "sha512-BQWfCqYM+QINd+yawJz23tbBM40VIGXOdDw3X344KcclI/gtBbdWF6SlQ4nK/bYhF9d27KYug9WzljHC6B9Ysg==", - "dev": true, - "requires": { - "fill-keys": "^1.0.2", - "module-not-found-error": "^1.0.1", - "resolve": "^1.11.1" - } - }, "prr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", @@ -4735,6 +4681,12 @@ "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", "dev": true }, + "querystringify": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", + "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==", + "dev": true + }, "randomatic": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-3.1.1.tgz", @@ -5214,6 +5166,12 @@ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, + "requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", + "dev": true + }, "resolve": { "version": "1.12.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", @@ -5606,15 +5564,6 @@ "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", "dev": true }, - "split": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", - "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", - "dev": true, - "requires": { - "through": "2" - } - }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", @@ -6673,6 +6622,16 @@ } } }, + "url-parse": { + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz", + "integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==", + "dev": true, + "requires": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + }, "use": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", @@ -6722,6 +6681,112 @@ "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==", "dev": true }, + "vscode": { + "version": "1.1.33", + "resolved": "https://registry.npmjs.org/vscode/-/vscode-1.1.33.tgz", + "integrity": "sha512-sXedp2oF6y4ZvqrrFiZpeMzaCLSWV+PpYkIxjG/iYquNZ9KrLL2LujltGxPLvzn49xu2sZkyC+avVNFgcJD1Iw==", + "dev": true, + "requires": { + "glob": "^7.1.2", + "mocha": "^4.0.1", + "request": "^2.88.0", + "semver": "^5.4.1", + "source-map-support": "^0.5.0", + "url-parse": "^1.4.4", + "vscode-test": "^0.1.4" + }, + "dependencies": { + "browser-stdout": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", + "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", + "dev": true + }, + "commander": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", + "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", + "dev": true + }, + "diff": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.3.1.tgz", + "integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==", + "dev": true + }, + "growl": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", + "dev": true + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, + "mocha": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-4.1.0.tgz", + "integrity": "sha512-0RVnjg1HJsXY2YFDoTNzcc1NKhYuXKRrBAG2gDygmJJA136Cs2QlRliZG1mA0ap7cuaT30mw16luAeln+4RiNA==", + "dev": true, + "requires": { + "browser-stdout": "1.3.0", + "commander": "2.11.0", + "debug": "3.1.0", + "diff": "3.3.1", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.3", + "he": "1.1.1", + "mkdirp": "0.5.1", + "supports-color": "4.4.0" + }, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } + } + }, + "supports-color": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", + "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "dev": true, + "requires": { + "has-flag": "^2.0.0" + } + }, + "vscode-test": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/vscode-test/-/vscode-test-0.1.5.tgz", + "integrity": "sha512-s+lbF1Dtasc0yXVB9iQTexBe2JK6HJAUJe3fWezHKIjq+xRw5ZwCMEMBaonFIPy7s95qg2HPTRDR5W4h4kbxGw==", + "dev": true, + "requires": { + "http-proxy-agent": "^2.1.0", + "https-proxy-agent": "^2.2.1" + } + } + } + }, "vscode-azureextensiondev": { "version": "0.3.4", "resolved": "https://registry.npmjs.org/vscode-azureextensiondev/-/vscode-azureextensiondev-0.3.4.tgz", @@ -6918,31 +6983,6 @@ "rimraf": "^2.6.3" } }, - "vscode-test-adapter-api": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/vscode-test-adapter-api/-/vscode-test-adapter-api-1.9.0.tgz", - "integrity": "sha512-lltjehUP0J9H3R/HBctjlqeUCwn2t9Lbhj2Y500ib+j5Y4H3hw+hVTzuSsfw16LtxY37knlU39QIlasa7svzOQ==", - "dev": true - }, - "vscode-test-adapter-remoting-util": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/vscode-test-adapter-remoting-util/-/vscode-test-adapter-remoting-util-0.11.0.tgz", - "integrity": "sha512-EZPjSZ6O4NLIY0WjScND8EFQ6z2D0KYoWLfSPMFxKFcv2MpgzF8gIOAXVmkgu0mVKrmRDoSQ7URqcsvFGOtaMA==", - "dev": true, - "requires": { - "split": "^1.0.1", - "tslib": "^2.0.0", - "vscode-test-adapter-api": "^1.9.0" - }, - "dependencies": { - "tslib": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz", - "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==", - "dev": true - } - } - }, "vscode-uri": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-1.0.6.tgz", diff --git a/package.json b/package.json index f099a891..37d30c37 100644 --- a/package.json +++ b/package.json @@ -111,8 +111,8 @@ "vscode:prepublish": "npm run compile", "compile": "tsc -p ./ && node copyStaticFiles.js", "watch": "node copyStaticFiles.js && tsc -watch -p ./", - "pretest": "npm run compile", - "test": "cp -r ./src/configure/test/test-fixtures/ ./out/configure/test/test-fixtures/ && node ./out/configure/test/runTest.js" + "postinstall": "node ./node_modules/vscode/bin/install", + "test": "node ./out/configure/test/runTest.js" }, "devDependencies": { "@types/fs-extra": "4.0.5", @@ -124,22 +124,20 @@ "@types/q": "1.5.0", "@types/sinon": "^9.0.5", "@types/underscore": "1.8.9", - "@types/vscode": "^1.32.0", "ajv": "^6.9.1", "assert": "1.4.1", "chai": "^4.2.0", "chai-as-promised": "^7.1.1", "glob": "^7.1.6", "mocha": "^7.1.2", - "mocha-explorer-launcher-scripts": "^0.3.0", "nock": "^13.0.2", - "proxyquire": "2.1.3", "sinon": "^9.0.3", "ts-node": "7.0.1", "tslint": "5.8.0", "tslint-microsoft-contrib": "^6.2.0", "typescript": "3.3.1", "typescript-tslint-plugin": "^0.5.5", + "vscode": "1.1.33", "vscode-azureextensiondev": "^0.3.1", "vscode-test": "^1.3.0" }, diff --git a/src/configure/clients/portalExtensionRepositoryAnalysisClient.ts b/src/configure/clients/portalExtensionRepositoryAnalysisClient.ts index ba30c3dc..37d4a35c 100644 --- a/src/configure/clients/portalExtensionRepositoryAnalysisClient.ts +++ b/src/configure/clients/portalExtensionRepositoryAnalysisClient.ts @@ -7,7 +7,7 @@ export class PortalExtensionRepositoryAnalysisClient implements IRepositoryAnaly private restClient: RestClient; private url: string; constructor(url: string, credentials: ServiceClientCredentials) { - this.restClient = new RestClient(credentials); + this.restClient = new RestClient(credentials, { noRetryPolicy: true }); this.url = url; } diff --git a/src/configure/configure.ts b/src/configure/configure.ts index e350a4a3..290cb654 100644 --- a/src/configure/configure.ts +++ b/src/configure/configure.ts @@ -1,5 +1,6 @@ import { GenericResource } from 'azure-arm-resource/lib/resource/models'; import { ApplicationSettings, RepositoryAnalysis } from 'azureintegration-repoanalysis-client-internal'; +import * as fs from 'fs'; import * as path from 'path'; import * as vscode from 'vscode'; import { AzureTreeItem, UserCancelledError } from 'vscode-azureextensionui'; @@ -29,10 +30,7 @@ import { TracePoints } from './resources/tracePoints'; import { InputControlProvider } from './templateInputHelper/InputControlProvider'; import { Utilities, WhiteListedError } from './utilities/utilities'; -const uuid = require('uuid/v4'); - const Layer: string = 'configure'; -export let UniqueResourceNameSuffix: string = uuid().substr(0, 5); export async function configurePipeline(node: AzureTreeItem) { await telemetryHelper.executeFunctionWithTimeTelemetry(async () => { @@ -94,7 +92,6 @@ class Orchestrator { public constructor() { this.inputs = new WizardInputs(); this.controlProvider = new ControlProvider(); - UniqueResourceNameSuffix = uuid().substr(0, 5); } public async configure(node: any): Promise { @@ -291,7 +288,7 @@ class Orchestrator { if (workspaceFolders.length === 1) { telemetryHelper.setTelemetry(TelemetryKeys.MultipleWorkspaceFolders, 'false'); - this.workspacePath = workspaceFolders[0].uri.fsPath; + this.workspacePath = fs.realpathSync(workspaceFolders[0].uri.fsPath); } else { telemetryHelper.setTelemetry(TelemetryKeys.MultipleWorkspaceFolders, 'true'); diff --git a/src/configure/configurers/azurePipelineConfigurer.ts b/src/configure/configurers/azurePipelineConfigurer.ts index d1a232d1..735eaed3 100644 --- a/src/configure/configurers/azurePipelineConfigurer.ts +++ b/src/configure/configurers/azurePipelineConfigurer.ts @@ -6,7 +6,6 @@ import { UserCancelledError } from 'vscode-azureextensionui'; import { AppServiceClient, VSTSDeploymentMessage } from '../clients/azure/appServiceClient'; import { AzureResourceClient } from '../clients/azure/azureResourceClient'; import { AzureDevOpsClient } from "../clients/devOps/azureDevOpsClient"; -import { UniqueResourceNameSuffix } from '../configure'; import { generateDevOpsOrganizationName, generateDevOpsProjectName } from '../helper/commonHelper'; import { ControlProvider } from '../helper/controlProvider'; import { AzureDevOpsHelper } from "../helper/devOps/azureDevOpsHelper"; @@ -22,7 +21,7 @@ import * as constants from '../resources/constants'; import { Messages } from '../resources/messages'; import { TelemetryKeys } from '../resources/telemetryKeys'; import { TracePoints } from '../resources/tracePoints'; -import { WhiteListedError } from '../utilities/utilities'; +import { Utilities, WhiteListedError } from '../utilities/utilities'; import { Configurer } from "./configurerBase"; import Q = require('q'); @@ -150,7 +149,7 @@ export class AzurePipelineConfigurer implements Configurer { }, async () => { try { - let serviceConnectionName = `${inputs.sourceRepository.repositoryName}-${UniqueResourceNameSuffix}`; + let serviceConnectionName = `${inputs.sourceRepository.repositoryName}-${Utilities.shortGuid()}`; inputs.sourceRepository.serviceConnectionId = await serviceConnectionHelper.createGitHubServiceConnection(serviceConnectionName, inputs.githubPATToken); } catch (error) { @@ -170,7 +169,7 @@ export class AzurePipelineConfigurer implements Configurer { }, async () => { try { - let serviceConnectionName = `${inputs.targetResource.resource.name}-${UniqueResourceNameSuffix}`; + let serviceConnectionName = `${inputs.targetResource.resource.name}-${Utilities.shortGuid()}`; switch ((inputs.pipelineConfiguration.template as LocalPipelineTemplate).azureConnectionType) { case AzureConnectionType.None: return ''; @@ -240,7 +239,8 @@ export class AzurePipelineConfigurer implements Configurer { } while (!inputs.sourceRepository.commitId) { - let commitOrDiscard = await vscode.window.showInformationMessage( + let commitOrDiscard = await this.controlProvider.showInformationBox( + constants.CheckInPipelineFilesToRepository, commitMessage, Messages.commitAndPush, Messages.discardPipeline); @@ -250,7 +250,7 @@ export class AzurePipelineConfigurer implements Configurer { try { if (!inputs.sourceRepository.remoteUrl) { let repositoryName = path.basename(inputs.sourceRepository.localPath).trim().replace(/[^a-zA-Z0-9-]/g, ''); - repositoryName = !!repositoryName ? (repositoryName + UniqueResourceNameSuffix) : "codetoazure"; + repositoryName = !!repositoryName ? (repositoryName + Utilities.shortGuid()) : "codetoazure"; let repository = await this.azureDevOpsClient.createRepository(inputs.organizationName, inputs.project.id, repositoryName); inputs.sourceRepository.repositoryName = repository.name; inputs.sourceRepository.repositoryId = repository.id; @@ -289,7 +289,7 @@ export class AzurePipelineConfigurer implements Configurer { try { let targetResource = AzurePipelineConfigurer.getTargetResource(inputs); - let pipelineName = `${(targetResource ? targetResource.name : inputs.pipelineConfiguration.template.label)}-${UniqueResourceNameSuffix}`; + let pipelineName = `${(targetResource ? targetResource.name : inputs.pipelineConfiguration.template.label)}-${Utilities.shortGuid()}`; return await this.azureDevOpsHelper.createAndRunPipeline(pipelineName, inputs); } catch (error) { diff --git a/src/configure/configurers/localGithubWorkflowConfigurer.ts b/src/configure/configurers/localGithubWorkflowConfigurer.ts index 71e34e39..b17e4b2e 100644 --- a/src/configure/configurers/localGithubWorkflowConfigurer.ts +++ b/src/configure/configurers/localGithubWorkflowConfigurer.ts @@ -22,10 +22,9 @@ import * as constants from '../resources/constants'; import { Messages } from '../resources/messages'; import { TelemetryKeys } from '../resources/telemetryKeys'; import { TracePoints } from '../resources/tracePoints'; +import { Utilities } from '../utilities/utilities'; import { Configurer } from "./configurerBase"; - -const uuid = require('uuid/v4'); const Layer = 'LocalGitHubWorkflowConfigurer'; export class LocalGitHubWorkflowConfigurer implements Configurer { @@ -109,7 +108,7 @@ export class LocalGitHubWorkflowConfigurer implements Configurer { }); if (!!azureConnectionSecret) { - inputs.targetResource.serviceConnectionId = 'AZURE_CREDENTIALS_' + uuid().substr(0, 8); + inputs.targetResource.serviceConnectionId = constants.githubSecretNamePrefix + Utilities.shortGuid(8); try { await vscode.window.withProgress( { @@ -203,6 +202,7 @@ export class LocalGitHubWorkflowConfigurer implements Configurer { } const commitOrDiscard = await this.controlProvider.showInformationBox( + constants.CheckInPipelineFilesToRepository, utils.format(displayMessage, Messages.commitAndPush, inputs.sourceRepository.branch, inputs.sourceRepository.remoteName), Messages.commitAndPush, Messages.discardPipeline); diff --git a/src/configure/helper/AssetHandler.ts b/src/configure/helper/AssetHandler.ts index ede21d64..85a18891 100644 --- a/src/configure/helper/AssetHandler.ts +++ b/src/configure/helper/AssetHandler.ts @@ -2,11 +2,11 @@ import * as utils from 'util'; import * as vscode from 'vscode'; import { AppServiceClient } from '../clients/azure/appServiceClient'; import { ArmRestClient } from '../clients/azure/armRestClient'; -import { UniqueResourceNameSuffix } from '../configure'; import { TargetResourceType, WizardInputs } from "../model/models"; import { LocalPipelineTemplate, TemplateAsset, TemplateAssetType, TemplateParameterType } from '../model/templateModels'; import { Messages } from '../resources/messages'; import { TracePoints } from '../resources/tracePoints'; +import { Utilities } from '../utilities/utilities'; import { GraphHelper } from './graphHelper'; import { SodiumLibHelper } from './sodium/SodiumLibHelper'; import { telemetryHelper } from './telemetryHelper'; @@ -43,7 +43,7 @@ export class AssetHandler { let aadAppName = GraphHelper.generateAadApplicationName(inputs.organizationName, inputs.project.name); let aadApp = await GraphHelper.createSpnAndAssignRole(inputs.azureSession, aadAppName, scope); // Use param name for first azure resource param - let serviceConnectionName = `${inputs.pipelineConfiguration.params[(inputs.pipelineConfiguration.template as LocalPipelineTemplate).parameters.find((parameter) => parameter.type === TemplateParameterType.GenericAzureResource).name]}-${UniqueResourceNameSuffix}`; + let serviceConnectionName = `${inputs.pipelineConfiguration.params[(inputs.pipelineConfiguration.template as LocalPipelineTemplate).parameters.find((parameter) => parameter.type === TemplateParameterType.GenericAzureResource).name]}-${Utilities.shortGuid()}`; return await createAsset(serviceConnectionName, asset.type, { "aadApp": aadApp, "scope": scope }, inputs); } catch (error) { @@ -64,7 +64,7 @@ export class AssetHandler { // find LCS of all azure resource params let appServiceClient = new AppServiceClient(inputs.azureSession.credentials, inputs.azureSession.environment, inputs.azureSession.tenantId, inputs.subscriptionId); let publishProfile = await appServiceClient.getWebAppPublishProfileXml(inputs.targetResource.resource.id); - let serviceConnectionName = `${targetWebAppResource.name}-${UniqueResourceNameSuffix}`; + let serviceConnectionName = `${targetWebAppResource.name}-${Utilities.shortGuid()}`; return await createAsset(serviceConnectionName, asset.type, publishProfile, inputs); } catch (error) { @@ -162,7 +162,7 @@ export class AssetHandler { * @returns sanitized asset name and makes it unique by appending 5 digit random alpha numeric string to asset name. */ public static getSanitizedUniqueAssetName(assetName: string): string { - assetName = assetName + "_" + UniqueResourceNameSuffix; + assetName = assetName + "_" + Utilities.shortGuid(); assetName = assetName.replace(/\W/g, ''); return assetName; } diff --git a/src/configure/helper/LocalGitRepoHelper.ts b/src/configure/helper/LocalGitRepoHelper.ts index 7d949642..0fa04ced 100644 --- a/src/configure/helper/LocalGitRepoHelper.ts +++ b/src/configure/helper/LocalGitRepoHelper.ts @@ -146,7 +146,7 @@ export class LocalGitRepoHelper { public async getGitRootDirectory(): Promise { let gitRootDir = await this.gitReference.revparse(["--show-toplevel"]); - return path.normalize(gitRootDir.trim()); + return fs.realpathSync(path.normalize(gitRootDir.trim())); } public async initializeGitRepository(remoteName: string, remoteUrl: string, filesToExcludeRegex?: string): Promise { diff --git a/src/configure/resources/constants.ts b/src/configure/resources/constants.ts index 532812bb..1943e654 100644 --- a/src/configure/resources/constants.ts +++ b/src/configure/resources/constants.ts @@ -167,6 +167,7 @@ export const TargetResource = 'targetResource'; export const ResourceDynamicValidationFailure = 'ResourceDynamicValidationFailure'; export const EnterGithubRepositoryName = 'EnterGithubRepositoryName'; export const SelectGitHubOrganization = 'selectGitHubOrganization'; +export const CheckInPipelineFilesToRepository = "checkInPipelineFilesToRepository"; //RepoAnalysis constants expected in response of Repository Analysis Service export const RepoAnalysisConstants = { @@ -197,6 +198,7 @@ export const azurePipeline: string = "Azure-pipeline"; export const githubWorkflow: string = "Github-workflow"; export const clientPropertyKey: string = "ms.client.vscode"; export const inputModeProperty: string = "inputMode"; +export const githubSecretNamePrefix: string = "AZURE_CREDENTIALS_"; export const ExceptionType = { UnauthorizedRequestException: 'UNAUTHORIZEDREQUESTEXCEPTION' diff --git a/src/configure/test/E2ETests/Static_Win_WebApp_Suite/Static_Windows_WebApp.test.ts b/src/configure/test/E2ETests/Static_Win_WebApp_Suite/Static_Windows_WebApp.test.ts new file mode 100644 index 00000000..d923d632 --- /dev/null +++ b/src/configure/test/E2ETests/Static_Win_WebApp_Suite/Static_Windows_WebApp.test.ts @@ -0,0 +1,62 @@ +import * as vscode from 'vscode'; +import { TestConstants } from "../testConstants"; +import { TestMocks } from '../testMocks'; + +var path = require('path'); +var fs = require('fs'); +let sinon = require('sinon'); +let chai = require("chai"); +let chaiAsPromised = require("chai-as-promised"); + +chai.use(chaiAsPromised); +let expect = chai.expect; + +describe('# Configure Pipeline for Static Website on Windows AppSvc @vscode-deploy-azure ', function () { + context('Should start extension @vscode-deploy-azure', function () { + it('should be able to activate the extension', async function () { + this.timeout(2000); + const extension = vscode.extensions.getExtension(TestConstants.extensionId); + if (!extension.isActive) { + expect(extension.activate()).should.be.fulfilled; + } + }); + }); + + context('Should configure pipeline for Static Website on Windows AppSvc', function () { + let workflowFilePath: string; + before(function () { + this.timeout(5000); + workflowFilePath = path.join(vscode.workspace.workspaceFolders[0].uri.path, ".github/workflows/workflow.yml"); + if (fs.existsSync(workflowFilePath)) { + fs.unlinkSync(workflowFilePath); + } + }); + + it('configure pipeline @vscode-deploy-azure', function () { + this.timeout(0); + var mocks = new TestMocks(); + return vscode.extensions.getExtension(TestConstants.extensionId).activate() + .then(() => { + + mocks.mockCommonMethodsOrProperties(); + mocks.mockGetAppServices_Windows(); + mocks.mockIsScmTypeSet(); + mocks.mockPublishProfile(); + mocks.mockSettingSecret(); + mocks.mockShowInputBox(); + mocks.mockShowQuickPick(); + mocks.mockShowInformationMessage(); + return vscode.commands.executeCommand("configure-cicd-pipeline"); + }).then(() => { + mocks.assertMocks(); + const buf1 = fs.readFileSync(path.join(__dirname, "../testFixtures/workflows", "Static_Windows_WebApp_Workflow.yml")); + const buf2 = fs.readFileSync(workflowFilePath); + expect(Buffer.compare(buf1, buf2)).to.equal(0); + }); + }); + + after(function () { + sinon.restore(); + }); + }); +}); \ No newline at end of file diff --git a/src/configure/test/E2ETests/Static_Win_WebApp_Suite/index.ts b/src/configure/test/E2ETests/Static_Win_WebApp_Suite/index.ts new file mode 100644 index 00000000..3be6988d --- /dev/null +++ b/src/configure/test/E2ETests/Static_Win_WebApp_Suite/index.ts @@ -0,0 +1,6 @@ +import * as path from 'path'; +import { setupTest } from "../../commonIndexUtilities"; + +export function run(): Promise { + return setupTest(path.basename(__dirname), __dirname); +} \ No newline at end of file diff --git a/src/configure/test/E2ETests/testConstants.ts b/src/configure/test/E2ETests/testConstants.ts new file mode 100644 index 00000000..4aa41fe9 --- /dev/null +++ b/src/configure/test/E2ETests/testConstants.ts @@ -0,0 +1,58 @@ +import { GenericResource } from "azure-arm-resource/lib/resource/models"; +import { BasicAuthenticationCredentials } from "ms-rest"; +import { AzureEnvironment } from 'ms-rest-azure'; + +export class TestConstants { + public static extensionId = "ms-vscode-deploy-azure.azure-deploy"; + + public static userName = process.env.Azure_UserName || "vimimrot@microsoft.com"; + public static AzurePAT = process.env.Azure_PAT || "ltieun33kps4sn7ys4a7zbybc73w7htynjypxpaesr2bnb2nvdfq"; + public static GithubPAT = process.env.GithubPAT || "f3a7efaeebab40560a706b5b5a79fc61edf4c358"; + public static PublishProfile = process.env.PublishProfile || "DummyPublishProfile"; + + public static credentials = new BasicAuthenticationCredentials(TestConstants.userName, TestConstants.AzurePAT); + + public static shortGuid = "test"; + + public static session = { + userId: TestConstants.userName, + tenantId: "72f988bf-86f1-41af-91ab-2d7cd011db47", + credentials: TestConstants.credentials, + environment: AzureEnvironment.Azure + } + + public static subscription = { + id: "/subscriptions/c00d16c7-6c1f-4c03-9be1-6934a4c49682", + subscriptionId: "c00d16c7-6c1f-4c03-9be1-6934a4c49682", + displayName: "RMDev" + } + + public static subscriptionData = { + label: TestConstants.subscription.displayName, + data: { + session: TestConstants.session, + subscription: TestConstants.subscription + }, + description: TestConstants.subscription.subscriptionId + }; + + public static windowsWebAppResource = { + id: "/subscriptions/c00d16c7-6c1f-4c03-9be1-6934a4c49682/resourceGroups/vnmtestlinux93c8/providers/Microsoft.Web/sites/vnm-demo", + name: "vnm-demo", + type: "Microsoft.Web/sites", + kind: "app" + }; + + public static windowsWebAppResourceData = { + label: TestConstants.windowsWebAppResource.name, + data: TestConstants.windowsWebAppResource + }; + + public static azureAccountExtensionAPI = { + sessions: [TestConstants.session], + subscriptions: [{ session: TestConstants.session, subscription: TestConstants.subscription }], + filters: [{ session: TestConstants.session, subscription: TestConstants.subscription }], + waitForLogin: () => Promise.resolve(true), + waitForSubscriptions: () => Promise.resolve(true) + } +} \ No newline at end of file diff --git a/src/configure/test/E2ETests/testFixtures/workflows/Static_Windows_WebApp_Workflow.yml b/src/configure/test/E2ETests/testFixtures/workflows/Static_Windows_WebApp_Workflow.yml new file mode 100644 index 00000000..c73d0036 --- /dev/null +++ b/src/configure/test/E2ETests/testFixtures/workflows/Static_Windows_WebApp_Workflow.yml @@ -0,0 +1,20 @@ +on: + push: + branches: + - master + +name: Package and deploy simple web app + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + # checkout the repo + - uses: actions/checkout@master + + # deploy web app using publish profile credentials + - uses: azure/webapps-deploy@v1 + with: + app-name: vnm-demo + package: . + publish-profile: ${{ secrets.AZURE_CREDENTIALS_test }} \ No newline at end of file diff --git a/src/configure/test/E2ETests/testMocks.ts b/src/configure/test/E2ETests/testMocks.ts new file mode 100644 index 00000000..1fc997c6 --- /dev/null +++ b/src/configure/test/E2ETests/testMocks.ts @@ -0,0 +1,88 @@ +import { ResourceListResult } from "azure-arm-resource/lib/resource/models"; +import { AppServiceClient } from "../../clients/azure/appServiceClient"; +import { GithubClient } from "../../clients/github/githubClient"; +import { ControlProvider } from "../../helper/controlProvider"; +import { extensionVariables } from "../../model/models"; +import * as constants from '../../resources/constants'; +import { Messages } from "../../resources/messages"; +import { Utilities } from "../../utilities/utilities"; +import { TestConstants } from "./testConstants"; +import sinon = require("sinon"); + +export class TestMocks { + + constructor() { } + private mockGetInputObj; + private mockShowQuickPickObj; + private mockShowInformationMessageObj; + private mockGetAppServiceObj; + private mockIsScmTypeSetObj; + private mockPublishProfileObj; + private mockSettingSecretObj; + + private mockedObjectArray: any[] = []; + + public mockCommonMethodsOrProperties() { + sinon.stub(extensionVariables, 'azureAccountExtensionApi').value(TestConstants.azureAccountExtensionAPI); + sinon.stub(Utilities, 'shortGuid').returns(TestConstants.shortGuid); + } + + public mockGetAppServices_Windows(args: any = ['app,linux', 'app']) { + this.mockGetAppServiceObj = sinon.stub(AppServiceClient.prototype, 'GetAppServices') + .withArgs(args) + .resolves([TestConstants.windowsWebAppResource]); + + this.mockedObjectArray.push({ mockObject: this.mockGetAppServiceObj, count: 1 }); + } + + public mockIsScmTypeSet() { + this.mockIsScmTypeSetObj = sinon.stub(AppServiceClient.prototype, 'isScmTypeSet') + .withArgs(TestConstants.windowsWebAppResource.id) + .resolves(false); + this.mockedObjectArray.push({ mockObject: this.mockIsScmTypeSetObj, count: 1 }); + } + + public mockPublishProfile() { + this.mockPublishProfileObj = sinon.stub(AppServiceClient.prototype, 'getWebAppPublishProfileXml') + .withArgs(TestConstants.windowsWebAppResource.id) + .resolves(TestConstants.PublishProfile); + this.mockedObjectArray.push({ mockObject: this.mockPublishProfileObj, count: 1 }); + } + + public mockSettingSecret() { + this.mockSettingSecretObj = sinon.stub(GithubClient.prototype, 'createOrUpdateGithubSecret') + .withArgs(constants.githubSecretNamePrefix + TestConstants.shortGuid, sinon.match.any) + .resolves(); + this.mockedObjectArray.push({ mockObject: this.mockSettingSecretObj, count: 1 }); + } + + public mockShowInputBox(resolve: string[] = [TestConstants.GithubPAT]) { + this.mockGetInputObj = sinon.stub(ControlProvider.prototype, 'showInputBox'); + for (var i = 0; i < resolve.length; i++) { + this.mockGetInputObj.onCall(i).resolves(resolve[i]); + } + this.mockedObjectArray.push({ mockObject: this.mockGetInputObj, count: resolve.length }); + } + + public mockShowQuickPick(resolve: any[] = [TestConstants.subscriptionData, TestConstants.windowsWebAppResourceData]) { + this.mockShowQuickPickObj = sinon.stub(ControlProvider.prototype, 'showQuickPick'); + for (var i = 0; i < resolve.length; i++) { + this.mockShowQuickPickObj.onCall(i).resolves(resolve[i]); + } + this.mockedObjectArray.push({ mockObject: this.mockShowQuickPickObj, count: resolve.length }); + } + + public mockShowInformationMessage(resolve: any[] = [Messages.discardPipeline]) { + this.mockShowInformationMessageObj = sinon.stub(ControlProvider.prototype, 'showInformationBox'); + for (var i = 0; i < resolve.length; i++) { + this.mockShowInformationMessageObj.onCall(i).resolves(resolve[i]); + } + this.mockedObjectArray.push({ mockObject: this.mockShowInformationMessageObj, count: resolve.length }); + } + + public assertMocks() { + this.mockedObjectArray.forEach(({ mockObject: object, count: cnt }) => { + sinon.assert.callCount(object, cnt); + }) + } +} \ No newline at end of file diff --git a/src/configure/test/suite/UnitTests/GitHubClient.test.ts b/src/configure/test/UnitTestsSuite/GitHubClient.test.ts similarity index 98% rename from src/configure/test/suite/UnitTests/GitHubClient.test.ts rename to src/configure/test/UnitTestsSuite/GitHubClient.test.ts index a1309005..4fce11e3 100644 --- a/src/configure/test/suite/UnitTests/GitHubClient.test.ts +++ b/src/configure/test/UnitTestsSuite/GitHubClient.test.ts @@ -1,5 +1,5 @@ import * as _ from 'lodash'; -import { GithubClient } from "../../../clients/github/githubClient"; +import { GithubClient } from "../../clients/github/githubClient"; var expect = require('chai').expect; var nock = require('nock'); diff --git a/src/configure/test/suite/UnitTests/commonHelper.test.ts b/src/configure/test/UnitTestsSuite/commonHelper.test.ts similarity index 95% rename from src/configure/test/suite/UnitTests/commonHelper.test.ts rename to src/configure/test/UnitTestsSuite/commonHelper.test.ts index 639d1f39..210c8d4b 100644 --- a/src/configure/test/suite/UnitTests/commonHelper.test.ts +++ b/src/configure/test/UnitTestsSuite/commonHelper.test.ts @@ -1,6 +1,6 @@ import * as _ from 'lodash'; -import { GithubClient } from "../../../clients/github/githubClient"; -import { generateGitHubRepository } from "../../../helper/commonHelper"; +import { GithubClient } from "../../clients/github/githubClient"; +import { generateGitHubRepository } from "../../helper/commonHelper"; var expect = require('chai').expect; var nock = require('nock'); diff --git a/src/configure/test/UnitTestsSuite/index.ts b/src/configure/test/UnitTestsSuite/index.ts new file mode 100644 index 00000000..7e8c2744 --- /dev/null +++ b/src/configure/test/UnitTestsSuite/index.ts @@ -0,0 +1,6 @@ +import * as path from 'path'; +import { setupTest } from "../commonIndexUtilities"; + +export function run(): Promise { + return setupTest(path.basename(__dirname), __dirname); +} \ No newline at end of file diff --git a/src/configure/test/index.ts b/src/configure/test/commonIndexUtilities.ts similarity index 78% rename from src/configure/test/index.ts rename to src/configure/test/commonIndexUtilities.ts index f564912d..daee7e36 100644 --- a/src/configure/test/index.ts +++ b/src/configure/test/commonIndexUtilities.ts @@ -1,17 +1,15 @@ import * as fs from 'fs'; import * as glob from 'glob'; import * as Mocha from 'mocha'; -import * as os from 'os'; import * as path from 'path'; -export function run(): Promise { - // Create the mocha test +export function setupTest(suiteName: string, suitePath: string): Promise { const testsRoot = path.resolve(__dirname, '..'); const testResultDir = path.join(testsRoot, 'test', 'deploy-azure-extension-testResult'); if (!fs.existsSync(testResultDir)) { fs.mkdirSync(testResultDir); } - const testResultFileName = path.normalize(path.join(testResultDir, os.platform() + "-" + ((new Date()).toJSON().slice(0, 19).replace('T', '_').replace(/:/g, '')) + ".xml")); + const testResultFileName = path.normalize(path.join(testResultDir, suiteName + "-" + ((new Date()).toJSON().slice(0, 19).replace('T', '_').replace(/:/g, '')) + ".xml")); const mocha = new Mocha({ ui: 'bdd', color: true, @@ -21,9 +19,8 @@ export function run(): Promise { } }); - return new Promise((c, e) => { - glob('**/suite/E2ETests/**.test.js', { cwd: testsRoot }, (err, files) => { + glob(suitePath + '/**.test.js', { cwd: testsRoot }, (err, files) => { // glob('**/suite/**/**.test.js', { cwd: testsRoot }, (err, files) => { if (err) { return e(err); @@ -47,4 +44,4 @@ export function run(): Promise { } }); }); -} +} \ No newline at end of file diff --git a/src/configure/test/runTest.ts b/src/configure/test/runTest.ts index 7790cb56..dae0fecc 100644 --- a/src/configure/test/runTest.ts +++ b/src/configure/test/runTest.ts @@ -1,23 +1,46 @@ +import * as fs from 'fs'; +import * as os from 'os'; import * as path from 'path'; +import * as git from 'simple-git/promise'; import { runTests } from 'vscode-test'; - async function testHost() { try { // The folder containing the Extension Manifest package.json // Passed to `--extensionDevelopmentPath` - const extensionDevelopmentPath = path.resolve(__dirname, '../../'); + const extensionDevelopmentPath = path.resolve(__dirname, '../../../'); + + const extensionTestsEnv = { + "DEBUGTELEMETRY": "v" + } + + let sampleRepoFolder: string; // The path to test runner // Passed to --extensionTestsPath - const extensionTestsPath = path.resolve(__dirname, './index'); + let extensionTestsPath: string; + + console.log("### Running Unit Tests ###") + extensionTestsPath = path.resolve(__dirname, './UnitTestsSuite'); + await runTests({ launchArgs: [], extensionDevelopmentPath, extensionTestsPath, extensionTestsEnv }); + + console.log("### Running Static Website on Windows WebApp Test ####") + extensionTestsPath = path.resolve(__dirname, './E2ETests/Static_Win_WebApp_Suite'); + sampleRepoFolder = await setupGitHubRepoFolderForStaticWebApp(); + await runTests({ launchArgs: [sampleRepoFolder], extensionDevelopmentPath, extensionTestsPath, extensionTestsEnv }); - // Download VS Code, unzip it and run the integration test - await runTests({ launchArgs: ["/Users/vineetmimrot/work/raw-work/repo/github/staticwebapp"], extensionDevelopmentPath, extensionTestsPath }); } catch (err) { console.error('Failed to run tests. Error : ' + err); process.exit(1); } } -testHost(); +async function setupGitHubRepoFolderForStaticWebApp(): Promise { + const projectPath = fs.mkdtempSync(path.join(os.tmpdir(), 'staticwebapp-')); + console.log("## Static WebApp ProjectPath: " + projectPath); + const gitUrl = "https://github.com/vineetmimrot/StaticWebapp.git"; + await git(projectPath).clone(gitUrl, projectPath); + return projectPath; +} + +testHost(); \ No newline at end of file diff --git a/src/configure/test/suite/E2ETests/GitHubWithWinWebapp.test.ts b/src/configure/test/suite/E2ETests/GitHubWithWinWebapp.test.ts deleted file mode 100644 index dd2978b0..00000000 --- a/src/configure/test/suite/E2ETests/GitHubWithWinWebapp.test.ts +++ /dev/null @@ -1,149 +0,0 @@ -import * as vscode from 'vscode'; -import { ControlProvider } from "../../../helper/controlProvider"; -import { Messages } from "../../../resources/messages"; -// var path = require('path'); -// var os = require('os'); -// var fs = require('fs'); -let sinon = require('sinon'); -let chai = require("chai"); -let chaiAsPromised = require("chai-as-promised"); - -chai.use(chaiAsPromised); -//let expect = chai.expect; - -const extensionId = "ms-vscode-deploy-azure.azure-deploy"; - -let subscriptionData = { - label: "RMDev", - data: { - session: { - userId: "vimimrot@microsoft.com", - tenantId: "72f988bf-86f1-41af-91ab-2d7cd011db47" - }, - subscription: { - id: "/subscriptions/c00d16c7-6c1f-4c03-9be1-6934a4c49682", - subscriptionId: "c00d16c7-6c1f-4c03-9be1-6934a4c49682", - displayName: "RMDev", - } - }, - description: "c00d16c7-6c1f-4c03-9be1-6934a4c49682" -}; - -let webappResourceData = { - label: "vnm-demo", - data: { - id: "/subscriptions/c00d16c7-6c1f-4c03-9be1-6934a4c49682/resourceGroups/vnmtestlinux93c8/providers/Microsoft.Web/sites/vnm-demo", - name: "vnm-demo", - type: "Microsoft.Web/sites", - kind: "app" - } -}; - -describe('# Should start extension @vscode-deploy-azure ', function () { - context('Should start extension @vscode-deploy-azure', function () { - it('should be able to activate the extension', async function () { - this.timeout(60 * 1000); - await sleep(2000); - const extension = vscode.extensions.getExtension(extensionId); - if (!extension.isActive) { - chai.expect(extension.activate()).should.be.fulfilled; - } - }); - }); - - - context('Mock - Should configure pipeline @vscode-deploy-azure', function () { - - // before(function () { - // this.timeout(0); - // var projectPath: string; - - // var localGitDirPath = fs.mkdtempSync(path.join(os.tmpdir(), 'sample-')); - // const gitUrl = "https://github.com/microsoft/devops-project-samples.git"; - // return LocalGitRepoHelper.GitCloneRepo(gitUrl, localGitDirPath).then(() => { - // fs.rmdirSync(path.join(localGitDirPath, ".git"), { recursive: true }); - // projectPath = path.join(localGitDirPath, "html", "webapp", "Application"); - // let uri = vscode.Uri.file(projectPath); - // return vscode.commands.executeCommand('vscode.openFolder', uri).then((success) => { - // }, (err) => { - // throw new Error("Unable to open folder: " + projectPath); - // }); - // }); - // }); - - it('Mock - configure pipeline @vscode-deploy-azure', function () { - this.timeout(0); - - let mockGetInput, mockShowQuickPick, mockShowInformationMessage; - return sleep(5000).then(() => { - return vscode.extensions.getExtension(extensionId).activate(); - }).then(() => { - mockGetInput = sinon.stub(ControlProvider.prototype, 'showInputBox'); - mockGetInput.onFirstCall().resolves('bf025851a48bfe18d7b49e7ec7f7bb6c854645d8'); - - mockShowQuickPick = sinon.stub(ControlProvider.prototype, 'showQuickPick'); - mockShowQuickPick - .onFirstCall().resolves(subscriptionData) - .onSecondCall().resolves(webappResourceData); - - mockShowInformationMessage = sinon.stub(ControlProvider.prototype, 'showInformationBox'); - mockShowInformationMessage.onFirstCall().resolves(Messages.discardPipeline); - return sleep(5000); - }).then(() => { - return vscode.commands.executeCommand("configure-cicd-pipeline"); - }).then(() => { - sinon.assert.calledOnce(mockGetInput); - sinon.assert.calledTwice(mockShowQuickPick); - sinon.assert.calledOnce(mockShowInformationMessage); - }); - }); - - after(function () { - sinon.restore(); - }); - }); - - // context('Mock - Should configure pipeline @vscode-deploy-azure', function () { - // it('Mock - configure pipeline @vscode-deploy-azure', async function () { - // this.timeout(0); - // await sleep(5000); - // await vscode.extensions.getExtension(extensionId).activate(); - // // await sleep(2000); - // let mockControlProvider; - // mockControlProvider = sinon.createStubInstance(ControlProvider); - // mockControlProvider.showInputBox.onFirstCall().resolves('bf025851a48bfe18d7b49e7ec7f7bb6c854645d8'); - - // // mockShowQuickPick = sinon.stub(ControlProvider.prototype, 'showQuickPick'); - // mockControlProvider.showQuickPick - // .onFirstCall().resolves(subscriptionData) - // .onSecondCall().resolves(webappResourceData) - // .onThirdCall().resolves("vnm-test2"); - - // // mockShowInformationMessage = sinon.stub(ControlProvider.prototype, 'showInformationBox'); - // mockControlProvider.showInformationBox.onFirstCall().resolves(Messages.commitAndPush); - // await sleep(2000); - // await vscode.commands.executeCommand("configure-cicd-pipeline"); - // // await sleep(2000); - // expect(mockControlProvider.showInputBox.calledOnce, "showInputBox.calledOnce").to.be.true; - // expect(mockControlProvider.showQuickPick.calledThrice, "showQuickPick.calledThrice").to.be.true; - // expect(mockControlProvider.showInformationBox.calledOnce, "showInformationBox.calledOnce").to.be.true; - - // }); - - // after(() => { - // sinon.restore(); - // }) - // }); - - - -}); - -// afterEach(() => { -// // Restore the default sandbox here -// sinon.restore(); -// }); - -async function sleep(ms: number) { - return new Promise((resolve) => setTimeout(resolve, ms)); -} diff --git a/src/configure/utilities/utilities.ts b/src/configure/utilities/utilities.ts index 686c32f7..bf2b6b19 100644 --- a/src/configure/utilities/utilities.ts +++ b/src/configure/utilities/utilities.ts @@ -1,9 +1,14 @@ import * as crypto from 'crypto'; +import uuid = require('uuid/v4'); export class Utilities { public static createSha256Hash(input: string): string { return crypto.createHash('sha256').update(input).digest('hex'); } + + public static shortGuid(len: number = 5): string { + return uuid().substr(0, len) + } } export class WhiteListedError extends Error { From 9020d3af6253cd0668210945d476644ab22cd2a9 Mon Sep 17 00:00:00 2001 From: Vineet Date: Wed, 16 Sep 2020 22:18:42 +0530 Subject: [PATCH 12/31] set env var --- src/configure/test/E2ETests/testConstants.ts | 16 ++++++++-------- .../Static_Windows_WebApp_Workflow.yml | 2 +- src/configure/test/runTest.ts | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/configure/test/E2ETests/testConstants.ts b/src/configure/test/E2ETests/testConstants.ts index 4aa41fe9..399a2db9 100644 --- a/src/configure/test/E2ETests/testConstants.ts +++ b/src/configure/test/E2ETests/testConstants.ts @@ -5,9 +5,9 @@ import { AzureEnvironment } from 'ms-rest-azure'; export class TestConstants { public static extensionId = "ms-vscode-deploy-azure.azure-deploy"; - public static userName = process.env.Azure_UserName || "vimimrot@microsoft.com"; - public static AzurePAT = process.env.Azure_PAT || "ltieun33kps4sn7ys4a7zbybc73w7htynjypxpaesr2bnb2nvdfq"; - public static GithubPAT = process.env.GithubPAT || "f3a7efaeebab40560a706b5b5a79fc61edf4c358"; + public static userName = process.env.Azure_UserName; + public static AzurePAT = process.env.Azure_PAT; + public static GithubPAT = process.env.GITHUB_TOKEN; public static PublishProfile = process.env.PublishProfile || "DummyPublishProfile"; public static credentials = new BasicAuthenticationCredentials(TestConstants.userName, TestConstants.AzurePAT); @@ -16,14 +16,14 @@ export class TestConstants { public static session = { userId: TestConstants.userName, - tenantId: "72f988bf-86f1-41af-91ab-2d7cd011db47", + tenantId: "f7841ef5-a478-4164-8a1e-e8e95a786cd7", credentials: TestConstants.credentials, environment: AzureEnvironment.Azure } public static subscription = { - id: "/subscriptions/c00d16c7-6c1f-4c03-9be1-6934a4c49682", - subscriptionId: "c00d16c7-6c1f-4c03-9be1-6934a4c49682", + id: "/subscriptions/8f67c458-5874-41fe-8cf9-f3b0429be6ff", + subscriptionId: "8f67c458-5874-41fe-8cf9-f3b0429be6ff", displayName: "RMDev" } @@ -37,8 +37,8 @@ export class TestConstants { }; public static windowsWebAppResource = { - id: "/subscriptions/c00d16c7-6c1f-4c03-9be1-6934a4c49682/resourceGroups/vnmtestlinux93c8/providers/Microsoft.Web/sites/vnm-demo", - name: "vnm-demo", + id: "/subscriptions/8f67c458-5874-41fe-8cf9-f3b0429be6ff/resourceGroups/vnmtestlinux93c8/providers/Microsoft.Web/sites/test-app", + name: "test-app", type: "Microsoft.Web/sites", kind: "app" }; diff --git a/src/configure/test/E2ETests/testFixtures/workflows/Static_Windows_WebApp_Workflow.yml b/src/configure/test/E2ETests/testFixtures/workflows/Static_Windows_WebApp_Workflow.yml index c73d0036..45f4c072 100644 --- a/src/configure/test/E2ETests/testFixtures/workflows/Static_Windows_WebApp_Workflow.yml +++ b/src/configure/test/E2ETests/testFixtures/workflows/Static_Windows_WebApp_Workflow.yml @@ -15,6 +15,6 @@ jobs: # deploy web app using publish profile credentials - uses: azure/webapps-deploy@v1 with: - app-name: vnm-demo + app-name: test-app package: . publish-profile: ${{ secrets.AZURE_CREDENTIALS_test }} \ No newline at end of file diff --git a/src/configure/test/runTest.ts b/src/configure/test/runTest.ts index dae0fecc..85fbbbc8 100644 --- a/src/configure/test/runTest.ts +++ b/src/configure/test/runTest.ts @@ -8,6 +8,7 @@ async function testHost() { try { // The folder containing the Extension Manifest package.json // Passed to `--extensionDevelopmentPath` + validateEnvironmentVariables(); const extensionDevelopmentPath = path.resolve(__dirname, '../../../'); const extensionTestsEnv = { @@ -43,4 +44,22 @@ async function setupGitHubRepoFolderForStaticWebApp(): Promise { return projectPath; } +function validateEnvironmentVariables() { + let unsetVariables: string = ""; + if (!process.env.Azure_UserName) { + unsetVariables += "Azure_UserName, " + } + + if (!process.env.Azure_PAT) { + unsetVariables += "Azure_PAT, " + } + + if (!process.env.GITHUB_TOKEN) { + unsetVariables += "GITHUB_TOKEN" + } + if (unsetVariables != "") { + throw new Error(`Env variable ${unsetVariables} are not set`); + } +} + testHost(); \ No newline at end of file From d0708c649d6a0b84f900fe1366bc943daff84323 Mon Sep 17 00:00:00 2001 From: Vineet Date: Wed, 16 Sep 2020 22:23:56 +0530 Subject: [PATCH 13/31] undo commit --- src/configure/helper/gitHubHelper.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/configure/helper/gitHubHelper.ts b/src/configure/helper/gitHubHelper.ts index 2b39d96c..32112ca7 100644 --- a/src/configure/helper/gitHubHelper.ts +++ b/src/configure/helper/gitHubHelper.ts @@ -1,7 +1,6 @@ export class GitHubProvider { // private gitHubPatToken: string; - private static GitHubUrl1 = 'https://github.com/'; - private static GitHubUrl2 = 'https://www.github.com/'; + private static GitHubUrl = 'https://github.com/'; private static SSHGitHubUrl = 'git@github.com:'; // constructor(gitHubPat: string) { @@ -9,7 +8,7 @@ export class GitHubProvider { // } public static isGitHubUrl(remoteUrl: string): boolean { - return remoteUrl.startsWith(GitHubProvider.GitHubUrl1) || remoteUrl.startsWith(GitHubProvider.GitHubUrl2) || remoteUrl.startsWith(GitHubProvider.SSHGitHubUrl); + return remoteUrl.startsWith(GitHubProvider.GitHubUrl) || remoteUrl.startsWith(GitHubProvider.SSHGitHubUrl); } public static getRepositoryIdFromUrl(remoteUrl: string): string { @@ -18,13 +17,12 @@ export class GitHubProvider { return remoteUrl.substring(GitHubProvider.SSHGitHubUrl.length); } - let endCount: number = remoteUrl.indexOf('.git', remoteUrl.lastIndexOf('/') + 1); + let endCount: number = remoteUrl.indexOf('.git'); if (endCount < 0) { endCount = remoteUrl.length; } - return remoteUrl.startsWith(GitHubProvider.GitHubUrl1) ? - remoteUrl.substring(GitHubProvider.GitHubUrl1.length, endCount) : remoteUrl.substring(GitHubProvider.GitHubUrl2.length, endCount); + return remoteUrl.substring(GitHubProvider.GitHubUrl.length, endCount); } public static getFormattedRemoteUrl(remoteUrl: string): string { From 4514ecfa91777dec2ee62b4541b0257eca4208fd Mon Sep 17 00:00:00 2001 From: Vineet Date: Wed, 16 Sep 2020 22:26:41 +0530 Subject: [PATCH 14/31] minor fix --- src/configure/test/E2ETests/testMocks.ts | 2 +- src/configure/test/commonIndexUtilities.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/configure/test/E2ETests/testMocks.ts b/src/configure/test/E2ETests/testMocks.ts index 1fc997c6..e6686a3f 100644 --- a/src/configure/test/E2ETests/testMocks.ts +++ b/src/configure/test/E2ETests/testMocks.ts @@ -83,6 +83,6 @@ export class TestMocks { public assertMocks() { this.mockedObjectArray.forEach(({ mockObject: object, count: cnt }) => { sinon.assert.callCount(object, cnt); - }) + }); } } \ No newline at end of file diff --git a/src/configure/test/commonIndexUtilities.ts b/src/configure/test/commonIndexUtilities.ts index daee7e36..c804e874 100644 --- a/src/configure/test/commonIndexUtilities.ts +++ b/src/configure/test/commonIndexUtilities.ts @@ -21,7 +21,6 @@ export function setupTest(suiteName: string, suitePath: string): Promise { return new Promise((c, e) => { glob(suitePath + '/**.test.js', { cwd: testsRoot }, (err, files) => { - // glob('**/suite/**/**.test.js', { cwd: testsRoot }, (err, files) => { if (err) { return e(err); } From dd06f2104c74c176b9461db356f0d6d754c97210 Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 17 Sep 2020 11:20:59 +0530 Subject: [PATCH 15/31] Adding workflow --- .../test-failed-issue-template.md | 16 ++++++++ .github/workflows/extension-tests.yml | 40 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/test-failed-issue-template.md create mode 100644 .github/workflows/extension-tests.yml diff --git a/.github/ISSUE_TEMPLATE/test-failed-issue-template.md b/.github/ISSUE_TEMPLATE/test-failed-issue-template.md new file mode 100644 index 00000000..3ec6b3c3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/test-failed-issue-template.md @@ -0,0 +1,16 @@ +--- +name: Build Failed Issue +about: Something went wrong with CI build +title: Build Failed Issue [{{payload.sender.login}}] +labels: Build Failed +assignees: bishal-pdMSFT, vineetmimrot, kanika1894 + +--- + +Event triggered by: {{payload.sender.login}} +Workflow: {{ workflow }} +Branch: {{ref}} + +Something went wrong with GitHub checks for {{ workflow }}. For more info visit- + +https://github.com/microsoft/vscode-deploy-azure/actions?query=workflow%3A%22Extension%20Test%20analysis%22%20is%3Afailure \ No newline at end of file diff --git a/.github/workflows/extension-tests.yml b/.github/workflows/extension-tests.yml new file mode 100644 index 00000000..fd82b809 --- /dev/null +++ b/.github/workflows/extension-tests.yml @@ -0,0 +1,40 @@ +name: "Extension Test analysis" + +on: [push] + +jobs: + build: + + strategy: + fail-fast: false + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + + - name: Setup node + - uses: actions/setup-node@v2-beta + with: + node-version: '12' + + - run: npm install + name: npm install + + - run: npm run compile + name: Build extension + + - name: Running Tests + run: npm test + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + Azure_UserName: ${{ secrets.Azure_UserName }} + Azure_PAT: ${{ secrets.Azure_PAT }} + + - name: Create an issue + uses: JasonEtco/create-an-issue@v2.4.0 + if: ${{ failure() && github.ref == 'refs/heads/master' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + filename: .github/ISSUE_TEMPLATE/build-failed-issue.md \ No newline at end of file From 6b820ebcb927af303c7965e15b11097017d3bf0e Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 17 Sep 2020 11:23:35 +0530 Subject: [PATCH 16/31] Update extension-tests.yml --- .github/workflows/extension-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/extension-tests.yml b/.github/workflows/extension-tests.yml index fd82b809..6deea0c2 100644 --- a/.github/workflows/extension-tests.yml +++ b/.github/workflows/extension-tests.yml @@ -13,8 +13,8 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Setup node - uses: actions/setup-node@v2-beta + name: Setup node with: node-version: '12' @@ -37,4 +37,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - filename: .github/ISSUE_TEMPLATE/build-failed-issue.md \ No newline at end of file + filename: .github/ISSUE_TEMPLATE/build-failed-issue.md From 1dec0d2faf0e6bdeaba5aacd48a424c91a189fcd Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 17 Sep 2020 11:25:10 +0530 Subject: [PATCH 17/31] Update extension-tests.yml --- .github/workflows/extension-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/extension-tests.yml b/.github/workflows/extension-tests.yml index 6deea0c2..4a135b9a 100644 --- a/.github/workflows/extension-tests.yml +++ b/.github/workflows/extension-tests.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - uses: actions/setup-node@v2-beta name: Setup node From 5256400dc09dda012a98f6e03d277309ef1dcb0a Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 17 Sep 2020 11:29:08 +0530 Subject: [PATCH 18/31] workflow fix --- .github/workflows/extension-tests.yml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/extension-tests.yml b/.github/workflows/extension-tests.yml index 4a135b9a..36ba4bcd 100644 --- a/.github/workflows/extension-tests.yml +++ b/.github/workflows/extension-tests.yml @@ -7,25 +7,29 @@ jobs: strategy: fail-fast: false + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v2-beta - name: Setup node + - name: Setup node + uses: actions/setup-node@v2-beta with: node-version: '12' - - run: npm install - name: npm install + - name: npm install + run: npm install - - run: npm run compile - name: Build extension + - name: Build extension + run: npm run compile - - name: Running Tests - run: npm test + - name: Run tests + uses: GabrielBB/xvfb-action@v1.2 + with: + run: npm test env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} Azure_UserName: ${{ secrets.Azure_UserName }} From 869df54f1e4ba5541e1257a65179169899bccca5 Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 17 Sep 2020 11:51:49 +0530 Subject: [PATCH 19/31] minor fix --- .vscode/launch.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index ba88b3aa..497405a3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -27,8 +27,10 @@ "request": "launch", "runtimeExecutable": "${execPath}", "args": [ - "/Users/vineetmimrot/work/raw-work/repo/github/staticwebapp/", + // Add repository path on which you want to test + "", "--extensionDevelopmentPath=${workspaceFolder}", + // Change this to whatever test you want to debug "--extensionTestsPath=${workspaceFolder}/out/configure/test/E2ETests/Static_Win_WebApp_Suite" ], "outFiles": [ From 3ea0031dbdd8392ad5a55eae073e42a274a4b8fe Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 17 Sep 2020 12:01:43 +0530 Subject: [PATCH 20/31] minor fix --- .github/workflows/extension-tests.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/extension-tests.yml b/.github/workflows/extension-tests.yml index 36ba4bcd..a0abf83d 100644 --- a/.github/workflows/extension-tests.yml +++ b/.github/workflows/extension-tests.yml @@ -35,6 +35,11 @@ jobs: Azure_UserName: ${{ secrets.Azure_UserName }} Azure_PAT: ${{ secrets.Azure_PAT }} + - name: view result files + shell: bash + run: | + echo $(Build.SourceBranch) | sed "s|refs/[^/]*/||" > branch.txt + - name: Create an issue uses: JasonEtco/create-an-issue@v2.4.0 if: ${{ failure() && github.ref == 'refs/heads/master' }} From e1d0e6e9cdde8f354e0dce1ae5e16f7c36c18b51 Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 17 Sep 2020 12:02:31 +0530 Subject: [PATCH 21/31] m2 --- .../Static_Win_WebApp_Suite/Static_Windows_WebApp.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/configure/test/E2ETests/Static_Win_WebApp_Suite/Static_Windows_WebApp.test.ts b/src/configure/test/E2ETests/Static_Win_WebApp_Suite/Static_Windows_WebApp.test.ts index d923d632..730819cc 100644 --- a/src/configure/test/E2ETests/Static_Win_WebApp_Suite/Static_Windows_WebApp.test.ts +++ b/src/configure/test/E2ETests/Static_Win_WebApp_Suite/Static_Windows_WebApp.test.ts @@ -13,12 +13,13 @@ let expect = chai.expect; describe('# Configure Pipeline for Static Website on Windows AppSvc @vscode-deploy-azure ', function () { context('Should start extension @vscode-deploy-azure', function () { - it('should be able to activate the extension', async function () { + it('should be able to activate the extension', async function (done) { this.timeout(2000); const extension = vscode.extensions.getExtension(TestConstants.extensionId); if (!extension.isActive) { expect(extension.activate()).should.be.fulfilled; } + done(); }); }); From b3a5769d596be2d1c71e9b3c07a98744f3b3899c Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 17 Sep 2020 13:27:36 +0530 Subject: [PATCH 22/31] show tests results --- .github/workflows/extension-tests.yml | 5 ----- src/configure/test/commonIndexUtilities.ts | 4 ++-- src/configure/test/runTest.ts | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/extension-tests.yml b/.github/workflows/extension-tests.yml index a0abf83d..36ba4bcd 100644 --- a/.github/workflows/extension-tests.yml +++ b/.github/workflows/extension-tests.yml @@ -35,11 +35,6 @@ jobs: Azure_UserName: ${{ secrets.Azure_UserName }} Azure_PAT: ${{ secrets.Azure_PAT }} - - name: view result files - shell: bash - run: | - echo $(Build.SourceBranch) | sed "s|refs/[^/]*/||" > branch.txt - - name: Create an issue uses: JasonEtco/create-an-issue@v2.4.0 if: ${{ failure() && github.ref == 'refs/heads/master' }} diff --git a/src/configure/test/commonIndexUtilities.ts b/src/configure/test/commonIndexUtilities.ts index c804e874..a271cc8a 100644 --- a/src/configure/test/commonIndexUtilities.ts +++ b/src/configure/test/commonIndexUtilities.ts @@ -4,8 +4,8 @@ import * as Mocha from 'mocha'; import * as path from 'path'; export function setupTest(suiteName: string, suitePath: string): Promise { - const testsRoot = path.resolve(__dirname, '..'); - const testResultDir = path.join(testsRoot, 'test', 'deploy-azure-extension-testResult'); + const testsRoot = path.resolve(__dirname); + const testResultDir = path.join(testsRoot, 'deploy-azure-extension-testResult'); if (!fs.existsSync(testResultDir)) { fs.mkdirSync(testResultDir); } diff --git a/src/configure/test/runTest.ts b/src/configure/test/runTest.ts index 85fbbbc8..53740942 100644 --- a/src/configure/test/runTest.ts +++ b/src/configure/test/runTest.ts @@ -29,9 +29,10 @@ async function testHost() { extensionTestsPath = path.resolve(__dirname, './E2ETests/Static_Win_WebApp_Suite'); sampleRepoFolder = await setupGitHubRepoFolderForStaticWebApp(); await runTests({ launchArgs: [sampleRepoFolder], extensionDevelopmentPath, extensionTestsPath, extensionTestsEnv }); - + printTestResultFiles(); } catch (err) { console.error('Failed to run tests. Error : ' + err); + printTestResultFiles(); process.exit(1); } } @@ -62,4 +63,18 @@ function validateEnvironmentVariables() { } } +function printTestResultFiles() { + const testsRoot = path.resolve(__dirname); + const testResultDir = path.join(testsRoot, 'deploy-azure-extension-testResult'); + let filenames = fs.readdirSync(testResultDir); + + console.log("\n### Test Report ###"); + let count = 1; + filenames.forEach((file) => { + console.log("### " + count++ + ". Test Suite:" + path.parse(file).name + " ###"); + console.log("\n" + fs.readFileSync(path.resolve(testResultDir, file), 'utf-8')); + console.log("\n"); + }); +} + testHost(); \ No newline at end of file From 81b8b5d513594c413eb7fe9bb8c720f45c151c64 Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 17 Sep 2020 14:01:33 +0530 Subject: [PATCH 23/31] fix workflow failure --- src/configure/test/runTest.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/configure/test/runTest.ts b/src/configure/test/runTest.ts index 53740942..d1c45171 100644 --- a/src/configure/test/runTest.ts +++ b/src/configure/test/runTest.ts @@ -1,8 +1,9 @@ +import * as cp from 'child_process'; import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; import * as git from 'simple-git/promise'; -import { runTests } from 'vscode-test'; +import { downloadAndUnzipVSCode, resolveCliPathFromVSCodeExecutablePath, runTests } from 'vscode-test'; async function testHost() { try { @@ -21,6 +22,14 @@ async function testHost() { // Passed to --extensionTestsPath let extensionTestsPath: string; + const vscodeExecutablePath = await downloadAndUnzipVSCode(); + const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath); + cp.spawnSync(cliPath, ['--install-extension', 'ms-vscode.azure-account'], { + encoding: 'utf-8', + stdio: 'inherit' + }); + + console.log("### Running Unit Tests ###") extensionTestsPath = path.resolve(__dirname, './UnitTestsSuite'); await runTests({ launchArgs: [], extensionDevelopmentPath, extensionTestsPath, extensionTestsEnv }); @@ -71,7 +80,7 @@ function printTestResultFiles() { console.log("\n### Test Report ###"); let count = 1; filenames.forEach((file) => { - console.log("### " + count++ + ". Test Suite:" + path.parse(file).name + " ###"); + console.log("### " + count++ + ". Test Suite: " + path.parse(file).name + " ###"); console.log("\n" + fs.readFileSync(path.resolve(testResultDir, file), 'utf-8')); console.log("\n"); }); From 5347e8a49548cd7488881391072e1c14e9b6ece6 Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 17 Sep 2020 14:57:51 +0530 Subject: [PATCH 24/31] test failure scenario --- .github/workflows/extension-tests.yml | 4 +--- src/configure/test/runTest.ts | 15 +++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/extension-tests.yml b/.github/workflows/extension-tests.yml index 36ba4bcd..824a8868 100644 --- a/.github/workflows/extension-tests.yml +++ b/.github/workflows/extension-tests.yml @@ -27,9 +27,7 @@ jobs: run: npm run compile - name: Run tests - uses: GabrielBB/xvfb-action@v1.2 - with: - run: npm test + run: npm test env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} Azure_UserName: ${{ secrets.Azure_UserName }} diff --git a/src/configure/test/runTest.ts b/src/configure/test/runTest.ts index d1c45171..c430ec8e 100644 --- a/src/configure/test/runTest.ts +++ b/src/configure/test/runTest.ts @@ -1,9 +1,8 @@ -import * as cp from 'child_process'; import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; import * as git from 'simple-git/promise'; -import { downloadAndUnzipVSCode, resolveCliPathFromVSCodeExecutablePath, runTests } from 'vscode-test'; +import { runTests } from 'vscode-test'; async function testHost() { try { @@ -22,12 +21,12 @@ async function testHost() { // Passed to --extensionTestsPath let extensionTestsPath: string; - const vscodeExecutablePath = await downloadAndUnzipVSCode(); - const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath); - cp.spawnSync(cliPath, ['--install-extension', 'ms-vscode.azure-account'], { - encoding: 'utf-8', - stdio: 'inherit' - }); + // const vscodeExecutablePath = await downloadAndUnzipVSCode(); + // const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath); + // cp.spawnSync(cliPath, ['--install-extension', 'ms-vscode.azure-account'], { + // encoding: 'utf-8', + // stdio: 'inherit' + // }); console.log("### Running Unit Tests ###") From 756838447e5f263e508440a52513ba55a1a9e1b2 Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 17 Sep 2020 15:08:07 +0530 Subject: [PATCH 25/31] workflow fix --- .github/workflows/extension-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/extension-tests.yml b/.github/workflows/extension-tests.yml index 824a8868..d834face 100644 --- a/.github/workflows/extension-tests.yml +++ b/.github/workflows/extension-tests.yml @@ -32,6 +32,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} Azure_UserName: ${{ secrets.Azure_UserName }} Azure_PAT: ${{ secrets.Azure_PAT }} + continue-on-error: true - name: Create an issue uses: JasonEtco/create-an-issue@v2.4.0 From 6c9f762c32ec22ad9679dd150c064a511490db10 Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 17 Sep 2020 15:12:13 +0530 Subject: [PATCH 26/31] m1 --- .github/workflows/extension-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/extension-tests.yml b/.github/workflows/extension-tests.yml index d834face..ec516016 100644 --- a/.github/workflows/extension-tests.yml +++ b/.github/workflows/extension-tests.yml @@ -36,7 +36,6 @@ jobs: - name: Create an issue uses: JasonEtco/create-an-issue@v2.4.0 - if: ${{ failure() && github.ref == 'refs/heads/master' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: From 21bf24a7c5eea9c0fb8a23298fe0e8618ab6b04b Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 17 Sep 2020 15:17:19 +0530 Subject: [PATCH 27/31] m2 --- .../{test-failed-issue-template.md => test-failed-issue.md} | 0 .github/workflows/extension-tests.yml | 3 +-- 2 files changed, 1 insertion(+), 2 deletions(-) rename .github/ISSUE_TEMPLATE/{test-failed-issue-template.md => test-failed-issue.md} (100%) diff --git a/.github/ISSUE_TEMPLATE/test-failed-issue-template.md b/.github/ISSUE_TEMPLATE/test-failed-issue.md similarity index 100% rename from .github/ISSUE_TEMPLATE/test-failed-issue-template.md rename to .github/ISSUE_TEMPLATE/test-failed-issue.md diff --git a/.github/workflows/extension-tests.yml b/.github/workflows/extension-tests.yml index ec516016..693c7465 100644 --- a/.github/workflows/extension-tests.yml +++ b/.github/workflows/extension-tests.yml @@ -32,11 +32,10 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} Azure_UserName: ${{ secrets.Azure_UserName }} Azure_PAT: ${{ secrets.Azure_PAT }} - continue-on-error: true - name: Create an issue uses: JasonEtco/create-an-issue@v2.4.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - filename: .github/ISSUE_TEMPLATE/build-failed-issue.md + filename: .github/ISSUE_TEMPLATE/test-failed-issue.md From e738bf720cc3e542cdea8f7b8ebe2dfc7a6a4336 Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 17 Sep 2020 15:28:31 +0530 Subject: [PATCH 28/31] m3 --- .github/workflows/extension-tests.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/extension-tests.yml b/.github/workflows/extension-tests.yml index 693c7465..daea8249 100644 --- a/.github/workflows/extension-tests.yml +++ b/.github/workflows/extension-tests.yml @@ -27,7 +27,9 @@ jobs: run: npm run compile - name: Run tests - run: npm test + uses: GabrielBB/xvfb-action@v1.2 + with: + run: npm test env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} Azure_UserName: ${{ secrets.Azure_UserName }} @@ -35,7 +37,8 @@ jobs: - name: Create an issue uses: JasonEtco/create-an-issue@v2.4.0 + if: failed() env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - filename: .github/ISSUE_TEMPLATE/test-failed-issue.md + filename: .github/ISSUE_TEMPLATE/test-failed-issue.md \ No newline at end of file From 8fa0653e442898841feacb3c0d86bb17b8a4c31a Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 17 Sep 2020 15:32:58 +0530 Subject: [PATCH 29/31] m4 --- .github/workflows/extension-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/extension-tests.yml b/.github/workflows/extension-tests.yml index daea8249..585d4866 100644 --- a/.github/workflows/extension-tests.yml +++ b/.github/workflows/extension-tests.yml @@ -37,7 +37,7 @@ jobs: - name: Create an issue uses: JasonEtco/create-an-issue@v2.4.0 - if: failed() + if: ${{ failure() }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: From ad7ce25c32ffe522d2fe78f3c33de1f26f9541de Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 17 Sep 2020 16:07:25 +0530 Subject: [PATCH 30/31] final fix --- .github/workflows/extension-tests.yml | 2 +- src/configure/test/runTest.ts | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/extension-tests.yml b/.github/workflows/extension-tests.yml index 585d4866..1d9eefa9 100644 --- a/.github/workflows/extension-tests.yml +++ b/.github/workflows/extension-tests.yml @@ -37,7 +37,7 @@ jobs: - name: Create an issue uses: JasonEtco/create-an-issue@v2.4.0 - if: ${{ failure() }} + if: ${{ failure() && github.ref == 'refs/heads/master' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: diff --git a/src/configure/test/runTest.ts b/src/configure/test/runTest.ts index c430ec8e..33aa59a3 100644 --- a/src/configure/test/runTest.ts +++ b/src/configure/test/runTest.ts @@ -1,8 +1,9 @@ +import * as cp from 'child_process'; import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; import * as git from 'simple-git/promise'; -import { runTests } from 'vscode-test'; +import { downloadAndUnzipVSCode, resolveCliPathFromVSCodeExecutablePath, runTests } from 'vscode-test'; async function testHost() { try { @@ -21,12 +22,12 @@ async function testHost() { // Passed to --extensionTestsPath let extensionTestsPath: string; - // const vscodeExecutablePath = await downloadAndUnzipVSCode(); - // const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath); - // cp.spawnSync(cliPath, ['--install-extension', 'ms-vscode.azure-account'], { - // encoding: 'utf-8', - // stdio: 'inherit' - // }); + const vscodeExecutablePath = await downloadAndUnzipVSCode(); + const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath); + cp.spawnSync(cliPath, ['--install-extension', 'ms-vscode.azure-account'], { + encoding: 'utf-8', + stdio: 'inherit' + }); console.log("### Running Unit Tests ###") @@ -74,6 +75,10 @@ function validateEnvironmentVariables() { function printTestResultFiles() { const testsRoot = path.resolve(__dirname); const testResultDir = path.join(testsRoot, 'deploy-azure-extension-testResult'); + if (!fs.existsSync(testResultDir)) { + return; + } + let filenames = fs.readdirSync(testResultDir); console.log("\n### Test Report ###"); From 8ff630d6c2354788a317235b2d47ebcc31712bb8 Mon Sep 17 00:00:00 2001 From: Vineet Date: Thu, 17 Sep 2020 16:09:06 +0530 Subject: [PATCH 31/31] m1 --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..23a746b6 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @bishal-pdmsft @vineetmimrot @kanika1894 @anuragc617