Skip to content

Commit 9327c95

Browse files
authored
fix: driver instance created after every session (#179)
1 parent 15f3287 commit 9327c95

File tree

6 files changed

+5
-227
lines changed

6 files changed

+5
-227
lines changed

azure-pipelines-pull-request.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,4 @@ pool:
99
vmImage: 'windows-latest'
1010

1111
stages:
12-
- template: templates/build-and-test-stages.yml
13-
parameters:
14-
environmentIdentifier: $(Build.BuildId)
15-
environmentDisplayName: SpecFlow Bindings - pr
16-
environmentDomainName: sfb-pr
17-
buildUrl: https://dev.azure.com/capgeminiuk/GitHub%20Support/_build/results?buildId=$(Build.BuildId)
18-
repositoryName: $(Build.Repository.Name)
12+
- template: templates/build-and-test-stages.yml

azure-pipelines.yml

+1-9
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,9 @@ pr: none
1111
pool:
1212
vmImage: windows-latest
1313
stages:
14-
- template: templates/build-and-test-stages.yml
15-
parameters:
16-
environmentIdentifier: $(Build.BuildId)
17-
environmentDisplayName: SpecFlow Bindings - CI
18-
environmentDomainName: sfb-ci
19-
buildUrl: https://dev.azure.com/capgeminiuk/GitHub%20Support/_build/results?buildId=$(Build.BuildId)
20-
repositoryName: $(Build.Repository.Name)
21-
14+
- template: templates/build-and-test-stages.yml
2215
- stage: Publish
2316
displayName: Publish
24-
dependsOn: ManualValidation
2517
jobs:
2618
- job: PublishJob
2719
displayName: Publish

bindings/src/Capgemini.PowerApps.SpecFlowBindings/PowerAppsStepDefiner.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,7 @@ protected static void Quit()
223223
.ExecuteAndCapture(() =>
224224
{
225225
xrmApp?.Dispose();
226-
227-
// Ensuring that the driver gets disposed. Previously we were left with orphan processes and were unable to clean up profile folders. We cannot rely on xrmApp.Dispose to properly dispose of the web driver.
228-
var driver = client?.Browser?.Driver;
229-
driver?.Dispose();
226+
client?.Dispose();
230227
});
231228

232229
xrmApp = null;

driver/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"karma-typescript": "^5.5.3",
3333
"ts-loader": "^8.0.5",
3434
"typescript": "^4.0.3",
35-
"webpack": "^4.44.2",
35+
"webpack": "^5.91.0",
3636
"webpack-cli": "^4.0.0"
3737
},
3838
"dependencies": {

templates/build-and-test-job.yml

-57
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,10 @@
1-
parameters:
2-
- name: environmentUrl
3-
displayName: Environment URL
4-
type: string
5-
- name: environmentName
6-
displayName: environmentName
7-
type: string
8-
- name: username
9-
displayName: Username
10-
type: string
11-
- name: password
12-
displayName: Password
13-
type: string
14-
151
jobs:
162
# build and tests executed in single job in order to allow SonarCloud to capture coverage
173
- job: BuildAndTestJob
184
displayName: Build and Test
195
variables:
206
- name: GitVersion.SemVer
217
value: ''
22-
- group: Cap Dev - CI
238
- name: solution
249
value: '**/*.sln'
2510
- name: buildPlatform
@@ -50,19 +35,6 @@ jobs:
5035
inputs:
5136
verbose: false
5237
workingDir: driver
53-
- task: SonarCloudPrepare@1
54-
displayName: Prepare SonarCloud
55-
inputs:
56-
SonarCloud: 'SonarCloud'
57-
organization: 'capgemini-1'
58-
scannerMode: 'MSBuild'
59-
projectKey: 'Capgemini_powerapps-specflow-bindings'
60-
projectName: 'powerapps-specflow-bindings'
61-
projectVersion: '$(GitVersion.SemVer)'
62-
extraProperties: |
63-
sonar.javascript.lcov.reportPaths=driver/test_results/coverage/lcov/lcov.info
64-
sonar.coverage.exclusions=**\*spec.ts, bindings/tests/**/*, bindings/src/Capgemini.PowerApps.SpecFlowBindings.MSBuild/**/*, bindings\src\Capgemini.PowerApps.SpecFlowBindings\Extensions\WebClientExtensions.cs
65-
sonar.eslint.reportPaths=$(Build.SourcesDirectory)/driver/test_results/analysis/eslint.json
6638
- task: VSBuild@1
6739
displayName: Build solution
6840
inputs:
@@ -86,35 +58,6 @@ jobs:
8658
inputs:
8759
codeCoverageTool: Cobertura
8860
summaryFileLocation: driver/test_results/coverage/cobertura/cobertura.xml
89-
- task: VSTest@2
90-
displayName: Run UI tests
91-
inputs:
92-
uiTests: true
93-
runInParallel: true
94-
codeCoverageEnabled: true
95-
runSettingsFile: bindings\tests\Capgemini.PowerApps.SpecFlowBindings.UiTests\CodeCoverage.runsettings
96-
testAssemblyVer2: |
97-
**\*UiTests.dll
98-
!**\*TestAdapter.dll
99-
!**\obj\**
100-
searchFolder: bindings\tests\Capgemini.PowerApps.SpecFlowBindings.UiTests
101-
rerunFailedTests: true
102-
rerunMaxAttempts: 2
103-
env:
104-
POWERAPPS_SPECFLOW_BINDINGS_TEST_TENANTID: $(Application User Tenant ID)
105-
POWERAPPS_SPECFLOW_BINDINGS_TEST_CLIENTID: $(Application User Client ID)
106-
POWERAPPS_SPECFLOW_BINDINGS_TEST_CLIENTSECRET: $(Application User Client Secret)
107-
POWERAPPS_SPECFLOW_BINDINGS_TEST_ADMIN_USERNAME: ${{ parameters.username }}
108-
POWERAPPS_SPECFLOW_BINDINGS_TEST_ADMIN_PASSWORD: ${{ parameters.password }}
109-
POWERAPPS_SPECFLOW_BINDINGS_TEST_ADMIN_USERNAME2: $(Extra Admin User Username)
110-
POWERAPPS_SPECFLOW_BINDINGS_TEST_ADMIN_PASSWORD2: $(Extra Admin User Password)
111-
POWERAPPS_SPECFLOW_BINDINGS_TEST_URL: ${{ parameters.environmentUrl }}
112-
- task: SonarCloudAnalyze@1
113-
displayName: Analyse with SonarCloud
114-
- task: SonarCloudPublish@1
115-
displayName: Publish SonarCloud results
116-
inputs:
117-
pollingTimeoutSec: '300'
11861
- task: WhiteSource Bolt@20
11962
displayName: Detect security and licence issues
12063
inputs:

templates/build-and-test-stages.yml

+1-149
Original file line numberDiff line numberDiff line change
@@ -1,154 +1,6 @@
1-
parameters:
2-
- name: environmentIdentifier
3-
displayName: Environment identifier
4-
type: string
5-
- name: environmentDisplayName
6-
displayName: Environment display name
7-
type: string
8-
- name: environmentDomainName
9-
displayName: Environment domain name
10-
type: string
11-
- name: buildUrl
12-
displayName: Build URL
13-
type: string
14-
- name: repositoryName
15-
displayName: Repository Name
16-
type: string
17-
181
stages:
19-
- stage: ProvisionEnvironment
20-
displayName: Provision environment
21-
variables:
22-
- name: Environment.Identifier
23-
value: ${{ parameters.environmentIdentifier }}
24-
- name: Environment.DisplayName
25-
value: ${{ parameters.environmentDisplayName }} $(Environment.Identifier)
26-
- name: TestEnvironment.DomainName
27-
value: ${{ parameters.environmentDomainName }}-$(Environment.Identifier)
28-
- group: Cap Dev - CI
29-
jobs:
30-
- job: ProvisionEnvironmentJob
31-
displayName: Provision environment
32-
steps:
33-
- task: PowerPlatformToolInstaller@0
34-
displayName: Install Power Platform Build Tools
35-
inputs:
36-
DefaultVersion: true
37-
- task: PowerPlatformCreateEnvironment@0
38-
displayName: Create environment
39-
inputs:
40-
authenticationType: PowerPlatformSPN
41-
PowerPlatformSPN: Dataverse (placeholder)
42-
DisplayName: $(Environment.DisplayName)
43-
EnvironmentSku: Sandbox
44-
LocationName: unitedkingdom
45-
LanguageName: 1033
46-
CurrencyName: GBP
47-
DomainName: $(TestEnvironment.DomainName)
48-
- powershell: |
49-
echo "##vso[task.setvariable variable=EnvironmentUrl;isOutput=true]$env:BUILDTOOLS_ENVIRONMENTURL"
50-
echo "##vso[task.setvariable variable=EnvironmentName;isOutput=true]$env:BUILDTOOLS_ENVIRONMENTID"
51-
displayName: Set output variables
52-
name: SetEnvironmentOutputVariables
53-
- task: PowerShell@2
54-
displayName: Sync required users
55-
inputs:
56-
filePath: '.\scripts\Sync-DataverseUsers.ps1'
57-
arguments: >
58-
-EnvironmentName $env:BUILDTOOLS_ENVIRONMENTID
59-
-ObjectIds @(
60-
"6bc9aff9-6f6e-49ac-96df-d862f20c3d63" <# ado.integration #>
61-
)
62-
-TenantId "f6dd1854-a44d-45a5-9537-c809a5d76c74"
63-
-ClientId $(Application User Client ID)
64-
-ClientSecret $(Application User Client Secret)
65-
- task: PowerShell@2
66-
displayName: Update user settings to English (United Kingdom)
67-
inputs:
68-
filePath: '.\scripts\Set-AllUserLocalesToUk.ps1'
69-
env:
70-
environmentUrl: $(SetEnvironmentOutputVariables.EnvironmentUrl)
71-
clientId: $(Application User Client ID)
72-
clientSecret: $(Application User Client Secret)
73-
2+
743
- stage: BuildAndTest
754
displayName: Build and Test
76-
dependsOn: ProvisionEnvironment
77-
variables:
78-
- name: BuildTools.EnvironmentUrl
79-
value: $[ stageDependencies.ProvisionEnvironment.ProvisionEnvironmentJob.outputs['SetEnvironmentOutputVariables.EnvironmentUrl'] ]
80-
- name: BuildTools.EnvironmentId
81-
value: $[ stageDependencies.ProvisionEnvironment.ProvisionEnvironmentJob.outputs['SetEnvironmentOutputVariables.EnvironmentName'] ]
82-
- group: Dataverse users
835
jobs:
846
- template: build-and-test-job.yml
85-
parameters:
86-
environmentUrl: $(BuildTools.EnvironmentUrl)
87-
environmentName: $(BuildTools.EnvironmentId)
88-
username: $(DataverseUsers.AzureDevOps.Username)
89-
password: $(DataverseUsers.AzureDevOps.Password)
90-
- stage: ManualValidation
91-
displayName: Manual validation
92-
dependsOn:
93-
- ProvisionEnvironment
94-
- BuildAndTest
95-
condition: and(not(canceled()), ne(dependencies.ProvisionEnvironment.outputs['ProvisionEnvironmentJob.SetEnvironmentOutputVariables.EnvironmentUrl'], ''))
96-
variables:
97-
RepositoryName: ${{ parameters.repositoryName }}
98-
BuildUrl: ${{ parameters.buildUrl }}
99-
BuildTools.EnvironmentUrl: $[ stageDependencies.ProvisionEnvironment.ProvisionEnvironmentJob.outputs['SetEnvironmentOutputVariables.EnvironmentUrl'] ]
100-
jobs:
101-
- job: ManualValidationCommentJob
102-
displayName: Manual validation (comment)
103-
steps:
104-
- task: GitHubAppCreateIssueComment@1
105-
name: CreateComment
106-
inputs:
107-
privateKey: capgemini-microsoft-bot.private-key.pem
108-
appId: 236185
109-
repo: $(Build.Repository.Name)
110-
body: |
111-
**Manual validation requested**
112-
Please perform any checks required on $(BuildTools.EnvironmentUrl) then approve $(BuildUrl).
113-
- job: ManualValidationJob
114-
displayName: Manual validation
115-
pool: server
116-
timeoutInMinutes: 8640
117-
steps:
118-
- task: ManualValidation@0
119-
displayName: Wait for manual validation
120-
timeoutInMinutes: 7200
121-
inputs:
122-
onTimeout: resume
123-
instructions: Please perform any checks required on $(BuildTools.EnvironmentUrl).
124-
- stage: DeleteEnvironment
125-
displayName: Delete environment
126-
dependsOn:
127-
- ProvisionEnvironment
128-
- ManualValidation
129-
condition: ne(dependencies.ProvisionEnvironment.outputs['ProvisionEnvironmentJob.SetEnvironmentOutputVariables.EnvironmentUrl'], '')
130-
variables:
131-
BuildTools.EnvironmentUrl: $[ stageDependencies.ProvisionEnvironment.ProvisionEnvironmentJob.outputs['SetEnvironmentOutputVariables.EnvironmentUrl'] ]
132-
CreateComment.CommentId: $[ stageDependencies.ManualValidation.ManualValidationCommentJob.outputs['CreateComment.CommentId'] ]
133-
jobs:
134-
- job: DeleteEnvironmentJob
135-
displayName: Delete environment
136-
steps:
137-
- checkout: none
138-
- task: PowerPlatformToolInstaller@0
139-
displayName: Install Power Platform Build Tools
140-
inputs:
141-
DefaultVersion: true
142-
- task: PowerPlatformDeleteEnvironment@0
143-
displayName: Delete environment
144-
continueOnError: true
145-
inputs:
146-
authenticationType: PowerPlatformSPN
147-
PowerPlatformSPN: Dataverse (placeholder)
148-
- task: GitHubAppDeleteIssueComment@1
149-
condition: ne(variables['CreateComment.CommentId'], '')
150-
inputs:
151-
privateKey: capgemini-microsoft-bot.private-key.pem
152-
appId: 236185
153-
repo: $(Build.Repository.Name)
154-
commentId: $(CreateComment.CommentId)

0 commit comments

Comments
 (0)