Skip to content

Commit

Permalink
* Change the logic to validate image regardless of the OS subtype. (#57)
Browse files Browse the repository at this point in the history
* Update filtering logic & README.md.
  • Loading branch information
AndreyKoltsov1997 authored Feb 14, 2023
1 parent 586bb8f commit 75c8834
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
10 changes: 10 additions & 0 deletions tool/automation/framework/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ The application could be built using Gradle Wrapper.
```
./gradlew <option> --args="<parameters>"
```
Example:
```
./gradlew clean build run --args="validate jetbrains/teamcity-agent:2022.10.2-windowsservercore-2004"
...
##teamcity[buildStatisticValue key='SIZE-teamcity-agent:windowsservercore-2004' value='5066342155']
jetbrains/teamcity-agent:2022.10.2-windowsservercore-2004-windows-10.0.19041.1415-amd64:
- Original size: 5066342155 (jetbrains/teamcity-agent:2022.10.2-windowsservercore-2004)
- Previous size: 5067986140 (2022.10.1-windowsservercore-2004)
- Percentage change: 0.03% (max allowable - 5.0%)
```

### 3.1 Available Options

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class DockerRegistryAccessor(private val uri: String, credentials: DockerhubCred
try {
return@filter it.name.contains(currentImage.tag.split("-", limit = 2)[1])
} catch (e: Exception) {
print("Image name does not match the expected pattern, thus would be filtered out: ${it.name}")
println("Image name does not match the expected pattern, thus would be filtered out: ${it.name}")
return@filter false
}
}
Expand All @@ -115,14 +115,24 @@ class DockerRegistryAccessor(private val uri: String, credentials: DockerhubCred
return null
}

// filter by target OS
// Apply filtering to the found Docker images.

// -- 1. Filter by OS type
previousImageRepository.images = previousImageRepository.images.filter { it.os == targetOs }
if (previousImageRepository.images.isNotEmpty() && !osVersion.isNullOrEmpty()) {

// --- 2. Filter by OS version (e.g. specific version of Windows, Linux)
val imagesFilteredByTarget = previousImageRepository.images.filter { it.osVersion.equals(osVersion) }
if (imagesFilteredByTarget.isEmpty()) {
// Logging such event as it's hard to investigate such differences
println("$currentImage - found previous image - ${previousImageRepository.name}, but OS version is different - $osVersion and ${previousImageRepository.images.first().osVersion}")
// Found images that matches OS type, but doesn't match OS version, e.g. ...
// ... - Previous: teamcity-agent:2022.10.1--windowsservercore-2004 (Windows 10.0.17763.3650)
// ... - Current : teamcity-agent:2022.10.2-windowsservercore-2004 (Windows 10.0.17763.3887)
println("$currentImage - found previous image - ${previousImageRepository.name}, but OS version is "
+ "different - $osVersion and ${previousImageRepository.images.first().osVersion} \n"
+ "Images with mismatching OS versions, but matching tags will be compared.")
return previousImageRepository
}

previousImageRepository.images = imagesFilteredByTarget
}

Expand Down

0 comments on commit 75c8834

Please sign in to comment.