We have decided to stop uploading selective tests from pull requests because of some edge case scenario:
- Create PR with code changes in Framework1, but no updates on snapshot images
- Get red test result because snapshots don’t match
- Push another commit with fixed snapshots
- Get green result
- Push another commit that moves/renames/deletes snapshots for some reason
- Get green result - no tests to execute because there was no code changed
- Merge
Now back on main
it would at first also be green, thanks to selective tests being uploaded from pull requests. Later when somebody changes Framework1
again the tests will be red.
We’re adding the snapshots already as additional files to a target:
var tuistTargets: [Target] {
targets.map { target in
.target(
name: target.name,
destinations: .iOS,
[...],
additionalFiles: target.additionalFiles(package: self)
)
}
}
func additionalFiles(package: KAPackage) -> [FileElement] {
let packageRoot = URL.projectRoot.appending(path: "Packages/\(package.path.rawValue)/\(package.name)")
return [
packageRoot.appending(path: "README.md"),
packageRoot.appending(path: "Tests/\(name)/__Snapshots__"),
packageRoot.appending(path: "Templates")
].filter(\.fileExistsAtPath).map { url in
.glob(pattern: .relativeToRoot(url.relativePath))
}
}