Skip to content

Commit ed2cf5d

Browse files
Merge pull request #24 from DevExpress-Examples/update-for-automated-testing
Update test-example.ps1
2 parents 8d8b618 + 854582f commit ed2cf5d

File tree

1 file changed

+20
-89
lines changed

1 file changed

+20
-89
lines changed

test-example.ps1

Lines changed: 20 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,38 @@
1-
# For local testing, you can pass branchName and/or buildVersion.
2-
# If both parameters are specified, only buildVersion will be used.
1+
# For local testing, you can pass buildVersion.
32
# Example usage:
4-
# ./test-example.ps1 -branchName 23.1.3+
53
# ./test-example.ps1 -buildVersion 23.1.13
64
param (
7-
[string]$branchName = [Environment]::GetEnvironmentVariable("BRANCH_NAME", [EnvironmentVariableTarget]::Machine),
8-
[string]$buildVersion = [Environment]::GetEnvironmentVariable("BUILD_VERSION", [EnvironmentVariableTarget]::Machine)
5+
[string]$buildVersion = $Env:CodeCentralBuildVersion
96
)
107

11-
$global:CODE_CENTRAL_BUILD_VERSION = $Env:CodeCentralBuildVersion
12-
13-
# Repository's branch name, e.g. 24.1.3+
14-
$global:BRANCH_NAME = $branchName
15-
# Masstest-specific parameter. Specifies the minor version (example: '21.1.5') !or daily build (example: '21.2.2005')
8+
# Masstest-specific parameter. Specifies the minor version (example: '21.1.5')
169
$global:BUILD_VERSION = $buildVersion
1710

1811
$global:ERROR_CODE = 0
1912
$global:FAILED_PROJECTS = @()
2013

21-
$global:ALL_VERSIONS = @(
22-
"14.1", "14.2",
23-
"15.1", "15.2",
24-
"16.1", "16.2",
25-
"17.1", "17.2",
26-
"18.1", "18.2",
27-
"19.1", "19.2",
28-
"20.1", "20.2",
29-
"21.1", "21.2",
30-
"22.1", "22.2",
31-
"23.1", "23.2",
32-
"24.1", "24.2",
33-
"25.1", "25.2"
34-
)
35-
3614
function Install-Packages {
3715
param (
3816
[string]$folderName,
3917
[string[]]$packages,
4018
[string]$buildVersion
4119
)
20+
4221
Write-Output "`nInstalling packages in folder: $folderName"
43-
44-
$packageList = $packages | ForEach-Object { "$_@$buildVersion" }
45-
Write-Output "`nPackages to install: $($packageList -join ", ")"
46-
# TODO: Uninstall DevExtreme packages to avoid potential peer-dependency issues
47-
npm install @($packageList) --save --save-exact --no-fund
48-
if (-not $?) {
49-
Write-Error "`nERROR: Failed to install DevExtreme packages in $folderName"
50-
throw "Installation failed in $folderName"
22+
23+
# Loop through each package and install it individually
24+
foreach ($package in $packages) {
25+
$packageWithVersion = "$package@$buildVersion"
26+
Write-Output "Installing $packageWithVersion..."
27+
28+
npm install --save --save-exact --no-fund --loglevel=error --force $packageWithVersion
29+
if (-not $?) {
30+
Write-Error "`nERROR: Failed to install $packageWithVersion in $folderName"
31+
throw "Installation failed for $packageWithVersion in $folderName"
32+
}
5133
}
34+
35+
Write-Output "`nAll packages installed successfully in $folderName"
5236
}
5337

5438
function Build-Project {
@@ -100,6 +84,9 @@ function Process-JavaScriptProjects {
10084
Push-Location $folderName
10185

10286
try {
87+
Write-Output "`nRemoving node_modules & package-lock.json: $pwd"
88+
Remove-Item -Recurse -Force node_modules -ErrorAction SilentlyContinue
89+
Remove-Item -Force package-lock.json -ErrorAction SilentlyContinue
10390
Install-Packages -folderName $folderName -packages $packages -buildVersion $buildVersion
10491
Write-Output "`nInstalling remaining packages in $folderName"
10592
npm install --save --save-exact --no-fund --loglevel=error
@@ -157,73 +144,17 @@ function Process-DotNetProjects {
157144
Write-Output "`nCompleted .NET project processing."
158145
}
159146

160-
function Set-BuildVersion {
161-
Write-Output "`n--== Starting Set-BuildVersion process. ==--"
162-
163-
$BUILD_VERSION = $global:BUILD_VERSION
164-
if ($BUILD_VERSION) {
165-
Write-Output "BUILD_VERSION is already set: $BUILD_VERSION"
166-
return
167-
}
168-
169-
$BUILD_VERSIONS_LIST = "BUILD_VERSIONS_LIST"
170-
171-
$inputMajorMinor = $global:BRANCH_NAME -replace "\.\d+\+$", ""
172-
Write-Output "Extracted major.minor version from branch name: $inputMajorMinor"
173-
174-
$filteredList = $global:ALL_VERSIONS | Where-Object {
175-
($_ -replace "\." -as [double]) -ge ($inputMajorMinor -replace "\." -as [double])
176-
}
177-
Write-Output "Filtered versions list: $filteredList"
178-
179-
$currentValue = [Environment]::GetEnvironmentVariable($BUILD_VERSIONS_LIST, [EnvironmentVariableTarget]::Machine)
180-
$currentList = if ($currentValue) {
181-
$currentValue -split ";"
182-
} else {
183-
$filteredList
184-
}
185-
Write-Output "Current versions list: $currentList"
186-
187-
if ($currentList.Count -gt 1) {
188-
$inputMajorMinor = $currentList[0]
189-
$updatedList = $currentList[1..($currentList.Count - 1)]
190-
} else {
191-
Write-Output "The list in the environment variable has only one item."
192-
$inputMajorMinor = $currentList[0]
193-
$updatedList = @()
194-
}
195-
196-
$global:BUILD_VERSION = $inputMajorMinor
197-
Write-Output "BUILD_VERSION set to: $global:BUILD_VERSION"
198-
199-
$newValue = $updatedList -join ";"
200-
[Environment]::SetEnvironmentVariable($BUILD_VERSIONS_LIST, $newValue, [EnvironmentVariableTarget]::Machine)
201-
202-
Write-Output "Environment variable '$BUILD_VERSIONS_LIST' updated."
203-
Write-Output "New list: $updatedList"
204-
}
205-
206147
function Write-BuildInfo {
207-
$BRANCH_NAME = if ($global:BRANCH_NAME -ne $null -and $global:BRANCH_NAME -ne "") {
208-
$global:BRANCH_NAME
209-
} else {
210-
"(empty)"
211-
}
212-
213148
$BUILD_VERSION = if ($global:BUILD_VERSION -ne $null -and $global:BUILD_VERSION -ne "") {
214149
$global:BUILD_VERSION
215150
} else {
216151
"(empty)"
217152
}
218153

219-
Write-Output "`nBranch Name: $BRANCH_NAME"
220154
Write-Output "Build Version: $BUILD_VERSION"
221155
}
222156

223-
Write-Output "Code central build version:"
224-
Write-Output $global:CODE_CENTRAL_BUILD_VERSION
225157
Write-BuildInfo
226-
Set-BuildVersion
227158
Process-JavaScriptProjects -buildVersion $global:BUILD_VERSION
228159
Process-DotNetProjects
229160

0 commit comments

Comments
 (0)