PowerToys/.pipelines/verifyDepsJsonLibraryVersions.ps1
Seraphima Zykova f6e7635a4e
[FancyZones]UI testing that works in CI (#29453)
* added test project

* run fz test

* rename proj

* editor test project

* check if FZ is running

* rename

* added assert messages

* spelling

* dev docs

* spelling

* update to latest stable

* exclude ui tests deps

* update packages list in notice.md

* added sample tests

* added file for tests run

* removed unrecognized

* removed run

* fix test configuration

* rename job

* change dependance

* run test template

* removed condition

* tabulation fix

* removed arg

* removed dependance

* removed log

* removed parameters

* test

* test

* added parameters

* pool

* pool

* vs test

* dependance

* download artifact

* publish artifact

* artifact publish conditions

* artifact name, default download path

* set folders

* prepare dotnet and vstest platform

* copy all

* target dotnet8

* test build agents

* set vs test version

* spellcheck

* set test platform version

* package feed selector

* hardcoded vstest location

* are other tests running?

* location

* vstest.console

* upd command

* script path

* search vstest.console

* vs path

* tools dir

* check files

* try full path

* try vstest task

* try full path in vstest task

* change path, remove unnecessary

* test with full vsconsole path

* winappdriver task

* changed args and condition

* default address

* added start operation type

* task name

* remove resolution

* Update run-ui-tests-ci.yml

* Update run-ui-tests-ci.yml

* Update run-ui-tests-ci.yml

* Update run-ui-tests-ci.yml

* AgentResolution should be a string

* Update run-ui-tests-ci.yml

testing against what WinUI gallery has for agent

* Update run-ui-tests-ci.yml

* Update run-ui-tests-ci.yml

* added WinAppDriver.exe

* spellcheck

* remove task

* checkout

* path

* src dir variable

* added init to the second project

* set longer timeout

* try waiting

* rerun

* log session info

* exclude WinAppDriver files from spell-check

* split io class: editor params

* remove unnecessary

* move data to the common project

* io test helper

* write retry

* Moved constants

* file utils

* prepare editor files before launch

* remove unused file

* spellcheck

* create directory

* fixed cleaning up

* remove WinAppDriver from deps

* start WinAppDriver from the default installation path

* installation script

* Revert "spellcheck"

This reverts commit 4bdc395730.

* Revert "exclude WinAppDriver files from spell-check"

This reverts commit 21ee6db3f5.

* install

* installation argument

* spellcheck

* change winappdriver path in fz tests

* delete iohelper

* update docs

* deleted obsolete winappdriver tests

* net version

* try without vstest location

* spellcheck

* Revert "try without vstest location"

This reverts commit 7cd39f3ae6.

* moved json tag constants to the common project
2024-03-22 12:10:10 +00:00

84 lines
3.9 KiB
PowerShell

[CmdletBinding()]
Param(
[Parameter(Mandatory = $True, Position = 1)]
[string]$targetDir
)
# This script will check every deps.json file in the target directory to see if for each dll mentioned,
#all the deps.json files that mention it will mention the same version.
# The main goal is to catch when different versions for the same module might be copied to the same directory
#at build time and might create flaky builds that get the wrong version of the dll sometimes.
# A dictionary of dictionaries of lists to save which files reference each version of each dll.
# Logic is DllName > fileVersion > list with deps.json files that reference it.
# If for a specific dll there's more than one referenced file version, we have build collisions.
$referencedFileVersionsPerDll = @{}
$totalFailures = 0
Get-ChildItem $targetDir -Recurse -Filter *.deps.json -Exclude UITests-FancyZones* | ForEach-Object {
# Temporarily exclude FancyZones UI tests because of Appium.WebDriver dependencies
$depsJsonFullFileName = $_.FullName
$depsJsonFileName = $_.Name
$depsJson = Get-Content $depsJsonFullFileName | ConvertFrom-Json
# We're doing a breadth first search to look for every runtime object.
$iterateThroughEveryField = New-Object System.Collections.Generic.Queue[System.Object]
$iterateThroughEveryField.Enqueue($depsJson)
while($iterateThroughEveryField.Count -gt 0)
{
$currentObject = $iterateThroughEveryField.Dequeue();
$currentObject.PSObject.Properties | ForEach-Object {
if($_.Name -ne 'SyncRoot') {
# Skip SyncRoot to avoid looping in array objects.
# Care only about objects, not value types.
$iterateThroughEveryField.Enqueue($_.Value)
if($_.Name -eq 'runtime')
{
# Cycle through each dll.
$_.Value.PSObject.Properties | ForEach-Object {
if($_.Name.EndsWith('.dll')) {
$dllName = Split-Path $_.Name -leaf
if([bool]($_.Value.PSObject.Properties.name -match 'fileVersion')) {
$dllFileVersion = $_.Value.fileVersion
# Add the entry to the dictionary of dictionary of lists
if(-Not $referencedFileVersionsPerDll.ContainsKey($dllName)) {
$referencedFileVersionsPerDll[$dllName] = @{ $dllFileVersion = New-Object System.Collections.Generic.List[System.String] }
} elseif(-Not $referencedFileVersionsPerDll[$dllName].ContainsKey($dllFileVersion)) {
$referencedFileVersionsPerDll[$dllName][$dllFileVersion] = New-Object System.Collections.Generic.List[System.String]
}
$referencedFileVersionsPerDll[$dllName][$dllFileVersion].Add($depsJsonFileName)
}
}
}
}
}
}
}
}
# Report on the files that are referenced for more than one version.
$referencedFileVersionsPerDll.keys | ForEach-Object {
if($referencedFileVersionsPerDll[$_].Count -gt 1) {
$dllName = $_
Write-Host $dllName
$referencedFileVersionsPerDll[$dllName].keys | ForEach-Object {
Write-Host "`t" $_
$referencedFileVersionsPerDll[$dllName][$_] | ForEach-Object {
Write-Host "`t`t" $_
}
}
$totalFailures++;
}
}
if ($totalFailures -gt 0) {
Write-Host -ForegroundColor Red "Detected " $totalFailures " libraries that are mentioned with different version across the dependencies.`r`n"
exit 1
}
Write-Host -ForegroundColor Green "All " $referencedFileVersionsPerDll.keys.Count " libraries are mentioned with the same version across the dependencies.`r`n"
exit 0